danger-todoist 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/todoist/diff_todo_finder.rb +6 -5
- data/lib/todoist/gem_version.rb +1 -1
- data/lib/todoist/plugin.rb +25 -8
- data/spec/diff_todo_finder_spec.rb +25 -1
- data/spec/todoist_spec.rb +11 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 963bf19dfcad9629d89f40c8f237618c1f69c2a1
|
4
|
+
data.tar.gz: 89e8d53b71cc005750a9d96eda9243b604c12125
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5153ffc9cc8daeae7f893a440399a3e0a1a227db1fd9a8c7880ca14c5122656df3aca73baffea70ac56af3631477bb6a57e858471d1201ee05f3cc0e33dd8354
|
7
|
+
data.tar.gz: aad90c81b1f8f581a2732b29080f78885a61a2ff303b4c7043e9744c83b53326d77efd07cd87a53489fa134db37ab2a000bb1ab94d007492e3fe9a5638691db9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## master
|
2
2
|
|
3
|
+
## 0.2.0
|
4
|
+
|
5
|
+
* warning is not sticky anymore - hanneskaeufler
|
6
|
+
* add `fail_for_todos` to fail instead of warn - hanneskaeufler
|
7
|
+
* find multiple todos in the same diff - hanneskaeufler
|
8
|
+
|
3
9
|
## 0.1.0
|
4
10
|
|
5
11
|
* extract and show todo text as well - hanneskaeufler
|
@@ -4,7 +4,7 @@ module Danger
|
|
4
4
|
TODO_REGEXP = /
|
5
5
|
^\+ # we only look at additions, marked by + in diffs
|
6
6
|
\s* # followed by optional space
|
7
|
-
[^a-z0-9]*
|
7
|
+
[^a-z0-9\+]* # anything looking like a comment indicator, not a +
|
8
8
|
\s+ # followed by at least one space
|
9
9
|
(TODO|FIXME) # our todo indicator
|
10
10
|
[\s:]{1} # followed by a space or colon
|
@@ -14,11 +14,12 @@ module Danger
|
|
14
14
|
def find_diffs_containing_todos(diffs)
|
15
15
|
todos = []
|
16
16
|
diffs.each do |diff|
|
17
|
-
matches = diff.patch.
|
18
|
-
next if matches.
|
17
|
+
matches = diff.patch.scan(TODO_REGEXP)
|
18
|
+
next if matches.empty?
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
matches.each do |match|
|
21
|
+
todos << Todo.new(diff.path, match.first.strip)
|
22
|
+
end
|
22
23
|
end
|
23
24
|
todos
|
24
25
|
end
|
data/lib/todoist/gem_version.rb
CHANGED
data/lib/todoist/plugin.rb
CHANGED
@@ -2,13 +2,17 @@ module Danger
|
|
2
2
|
#
|
3
3
|
# This is a danger plugin to detect any TODO/FIXME entries left in the code.
|
4
4
|
#
|
5
|
-
# @example Ensure there are no TODOS left in the modified code
|
5
|
+
# @example Ensure, by warning, there are no TODOS left in the modified code
|
6
6
|
#
|
7
7
|
# todoist.warn_for_todos
|
8
8
|
#
|
9
|
-
# @example
|
9
|
+
# @example Ensure, by failing the build, no TODOS left in the modified code
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# todoist.fail_for_todos
|
12
|
+
#
|
13
|
+
# @example Set custom warning message for warning
|
14
|
+
#
|
15
|
+
# todoist.message = "Please fix all TODOS"
|
12
16
|
# todoist.warn_for_todos
|
13
17
|
#
|
14
18
|
# @example List every todo item
|
@@ -36,12 +40,16 @@ module Danger
|
|
36
40
|
# @return [void]
|
37
41
|
#
|
38
42
|
def warn_for_todos
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
@todos = DiffTodoFinder.new.find_diffs_containing_todos(diffs_of_interest)
|
43
|
+
call_method_for_todos(:warn)
|
44
|
+
end
|
43
45
|
|
44
|
-
|
46
|
+
#
|
47
|
+
# Adds an error if there are todos found in the modified code
|
48
|
+
#
|
49
|
+
# @return [void]
|
50
|
+
#
|
51
|
+
def fail_for_todos
|
52
|
+
call_method_for_todos(:fail)
|
45
53
|
end
|
46
54
|
|
47
55
|
#
|
@@ -63,6 +71,15 @@ module Danger
|
|
63
71
|
|
64
72
|
private
|
65
73
|
|
74
|
+
def call_method_for_todos(method)
|
75
|
+
@todos = []
|
76
|
+
return if files_of_interest.empty?
|
77
|
+
|
78
|
+
@todos = DiffTodoFinder.new.find_diffs_containing_todos(diffs_of_interest)
|
79
|
+
|
80
|
+
public_send(method, message, sticky: false) unless @todos.empty?
|
81
|
+
end
|
82
|
+
|
66
83
|
def message
|
67
84
|
return @message unless @message.nil?
|
68
85
|
DEFAULT_MESSAGE
|
@@ -58,7 +58,8 @@ module Danger
|
|
58
58
|
"+ def todo foo",
|
59
59
|
"+ * this looks like a todo but isnt",
|
60
60
|
"+ TODO_REGEXP = /",
|
61
|
-
"+ todos = subject.find_diffs_containing_todos(diffs)"
|
61
|
+
"+ todos = subject.find_diffs_containing_todos(diffs)",
|
62
|
+
"++ # FIXME: with you the force is"
|
62
63
|
].each do |patch|
|
63
64
|
it "does not identify occurences in '#{patch}'" do
|
64
65
|
diffs = [
|
@@ -88,6 +89,29 @@ module Danger
|
|
88
89
|
|
89
90
|
expect(todos.first.text).to eql("practice you must")
|
90
91
|
end
|
92
|
+
|
93
|
+
it "finds multiple todos in the same diff" do
|
94
|
+
patch = <<PATCH
|
95
|
+
+ # TODO: practice you must
|
96
|
+
+ def practice
|
97
|
+
+ return false
|
98
|
+
+ end
|
99
|
+
+ # FIXME: with you the force is
|
100
|
+
PATCH
|
101
|
+
|
102
|
+
diffs = [
|
103
|
+
Git::Diff::DiffFile.new(
|
104
|
+
"base",
|
105
|
+
path: "some/file.rb",
|
106
|
+
patch: patch
|
107
|
+
)
|
108
|
+
]
|
109
|
+
|
110
|
+
todos = subject.find_diffs_containing_todos(diffs)
|
111
|
+
|
112
|
+
expect(todos.map(&:text))
|
113
|
+
.to eql(["practice you must", "with you the force is"])
|
114
|
+
end
|
91
115
|
end
|
92
116
|
end
|
93
117
|
end
|
data/spec/todoist_spec.rb
CHANGED
@@ -34,9 +34,9 @@ module Danger
|
|
34
34
|
.and_return(added)
|
35
35
|
|
36
36
|
allow(@dangerfile.git).to receive(:modified_files)
|
37
|
-
.and_return([
|
37
|
+
.and_return(["some/file.rb"])
|
38
38
|
allow(@dangerfile.git).to receive(:added_files)
|
39
|
-
.and_return([
|
39
|
+
.and_return(["another/stuff.rb"])
|
40
40
|
end
|
41
41
|
|
42
42
|
it "warns when files in the changeset" do
|
@@ -45,6 +45,12 @@ module Danger
|
|
45
45
|
expect(warnings).to eq([DangerTodoist::DEFAULT_MESSAGE])
|
46
46
|
end
|
47
47
|
|
48
|
+
it "fails when files in the changeset" do
|
49
|
+
@todoist.fail_for_todos
|
50
|
+
|
51
|
+
expect(failures).to eq([DangerTodoist::DEFAULT_MESSAGE])
|
52
|
+
end
|
53
|
+
|
48
54
|
it "allows the message to be changed" do
|
49
55
|
@todoist.message = "changed message"
|
50
56
|
@todoist.warn_for_todos
|
@@ -78,7 +84,7 @@ module Danger
|
|
78
84
|
.and_return(modified)
|
79
85
|
|
80
86
|
allow(@dangerfile.git).to receive(:modified_files)
|
81
|
-
.and_return([
|
87
|
+
.and_return(["some/file.rb"])
|
82
88
|
allow(@dangerfile.git).to receive(:added_files).and_return([])
|
83
89
|
end
|
84
90
|
|
@@ -103,12 +109,8 @@ module Danger
|
|
103
109
|
end
|
104
110
|
end
|
105
111
|
|
106
|
-
def
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
def added_with_todo
|
111
|
-
"another/stuff.rb"
|
112
|
+
def failures
|
113
|
+
@dangerfile.status_report[:errors]
|
112
114
|
end
|
113
115
|
|
114
116
|
def warnings
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-todoist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hannes Käufler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|