danger-todoist 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7782f6aba04d5997bb0d3ef2c5e1d50e89565a92
4
- data.tar.gz: e02a1a37c15ff38f7b1a0050c5ab9e72f0d69dab
3
+ metadata.gz: 45658ff29d4eb2568b06f4243fe8c986c1167cef
4
+ data.tar.gz: 7e772b86afd289fa5340d70fe6b5234b28e64dc9
5
5
  SHA512:
6
- metadata.gz: 09aadc7a07af5ff482941b9926b40412e4c8d857c065d7fbf94f99d65e715d8b9b25e416cb0dfb2ecfd04823821228c71eda28af095dd7c2090b8733c1ce023d
7
- data.tar.gz: 5e82b7e875b6878601c53698e7e63fd558ef0301fc432e9396381b2c0b0ceae205ba63eea79c91ee7dba2bd182f567ede97a6fe483ae4b44fb5d28582c6e4158
6
+ metadata.gz: 7547e35d1ed8baf09bdca508d9bc61a589f4a94ab5537552aad116dec55cc79b0028a7bbe3b684639c318cae57cf29214e662e0c672df29b45980584685ed4dc
7
+ data.tar.gz: 279263f5a9fea83c92a67124661456e35e77c305b59bf34e7cfb2cc1d7c07fa7d0432f4b610d893ac3115353769fccff1bf12dfc2f044cc169259fe318124927
@@ -8,5 +8,8 @@ rvm:
8
8
  - 2.1.3
9
9
  - 2.3.1
10
10
 
11
+ before_script:
12
+ - bundle exec danger
13
+
11
14
  script:
12
- - bundle exec rake spec
15
+ - bundle exec rake spec
@@ -0,0 +1,14 @@
1
+ ## master
2
+
3
+ ## 0.0.3
4
+
5
+ * Only find newly introduced todos - hanneskaeufler
6
+ * Don't find todos obviously occuring in code - hanneskaeufler
7
+
8
+ ## 0.0.2
9
+
10
+ * Add documentation - hanneskaeufler
11
+
12
+ ## 0.0.1
13
+
14
+ * Initial release - hanneskaeufler
@@ -0,0 +1,16 @@
1
+ # Make it more obvious that a PR is a work in progress and shouldn't be merged yet
2
+ warn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]"
3
+
4
+ # Warn when there is a big PR
5
+ warn("Big PR") if git.lines_of_code > 500
6
+
7
+ # Identify leftover todos
8
+ todoist.message = "There are still some things to do in this PR."
9
+ todoist.warn_for_todos
10
+ todoist.print_todos_table
11
+
12
+ # Mainly to encourage writing up some reasoning about the PR, rather than
13
+ # just leaving a title
14
+ if github.pr_body.length < 5
15
+ fail "Please provide a summary in the Pull Request description"
16
+ end
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/hanneskaeufler/danger-todoist.svg?branch=master)](https://travis-ci.org/hanneskaeufler/danger-todoist)
1
+ [![Build Status](https://travis-ci.org/hanneskaeufler/danger-todoist.svg?branch=master)](https://travis-ci.org/hanneskaeufler/danger-todoist) [![Gem Version](https://badge.fury.io/rb/danger-todoist.svg)](https://badge.fury.io/rb/danger-todoist)
2
2
 
3
3
  # danger-todoist
4
4
 
@@ -1 +1,2 @@
1
1
  require "todoist/plugin"
2
+ require "todoist/diff_todo_finder"
@@ -0,0 +1,22 @@
1
+ module Danger
2
+ # Identify todos in a set of diffs
3
+ class DiffTodoFinder
4
+ TODO_REGEXP = /\+.*(TODO|FIXME)[\s:]/i
5
+
6
+ def find_diffs_containing_todos(diffs)
7
+ diffs
8
+ .select { |diff| contains_new_todo(diff) }
9
+ .map { |diff| Todo.new(diff.path) }
10
+ end
11
+
12
+ private
13
+
14
+ def contains_new_todo(diff)
15
+ # TODO: This will match removed todos as well
16
+ !(diff.patch =~ TODO_REGEXP).nil?
17
+ end
18
+
19
+ class Todo < Struct.new(:file)
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Todoist
2
- VERSION = "0.0.2".freeze
2
+ VERSION = "0.0.3".freeze
3
3
  end
@@ -21,7 +21,6 @@ module Danger
21
21
  #
22
22
  class DangerTodoist < Plugin
23
23
  DEFAULT_MESSAGE = "There remain todo items in the modified code.".freeze
24
- TODO_REGEXP = /TODO|FIXME/i
25
24
 
26
25
  #
27
26
  # Message to be shown
@@ -40,8 +39,7 @@ module Danger
40
39
  @todos = []
41
40
  return if files_of_interest.empty?
42
41
 
43
- diffs_containing_todo_markers
44
- .each { |diff| @todos << Todo.new(diff.path) }
42
+ @todos = DiffTodoFinder.new.find_diffs_containing_todos(diffs_of_interest)
45
43
 
46
44
  warn(message) unless @todos.empty?
47
45
  end
@@ -75,17 +73,5 @@ module Danger
75
73
  files_of_interest
76
74
  .map { |file| git.diff_for_file(file) }
77
75
  end
78
-
79
- def diffs_containing_todo_markers
80
- diffs_of_interest
81
- .select { |diff| contains_new_todo(diff) }
82
- end
83
-
84
- def contains_new_todo(diff)
85
- !(diff.patch =~ TODO_REGEXP).nil?
86
- end
87
-
88
- class Todo < Struct.new(:file)
89
- end
90
76
  end
91
77
  end
@@ -0,0 +1,59 @@
1
+ require File.expand_path("../spec_helper", __FILE__)
2
+
3
+ module Danger
4
+ describe Danger::DiffTodoFinder do
5
+ let(:subject) { Danger::DiffTodoFinder.new }
6
+
7
+ describe "#find_diffs_containing_todos" do
8
+ %w(TODO TODO: todo todo: FIXME fixme FIXME: fixme).each do |marker|
9
+ it "identifies a new '#{marker}' as a todo" do
10
+ diffs = [
11
+ Git::Diff::DiffFile.new(
12
+ "base",
13
+ path: "some/file.rb",
14
+ patch: "+ #{marker} some todo"
15
+ )
16
+ ]
17
+
18
+ todos = subject.find_diffs_containing_todos(diffs)
19
+
20
+ expect(todos).to_not be_empty
21
+ end
22
+ end
23
+
24
+ it "does not identify removed todos as a todo" do
25
+ diffs = [
26
+ Git::Diff::DiffFile.new(
27
+ "base",
28
+ path: "some/file.rb",
29
+ patch: "- TODO: some todo"
30
+ )
31
+ ]
32
+
33
+ todos = subject.find_diffs_containing_todos(diffs)
34
+
35
+ expect(todos).to be_empty
36
+ end
37
+
38
+ [
39
+ "+ class TodosController",
40
+ "+ function foo(todo) {",
41
+ "+ def todo()"
42
+ ].each do |patch|
43
+ it "does not identify occurences in e.g. a new class name" do
44
+ diffs = [
45
+ Git::Diff::DiffFile.new(
46
+ "base",
47
+ path: "some/file.rb",
48
+ patch: patch
49
+ )
50
+ ]
51
+
52
+ todos = subject.find_diffs_containing_todos(diffs)
53
+
54
+ expect(todos).to be_empty
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -12,7 +12,7 @@ module Danger
12
12
  @todoist = @dangerfile.todoist
13
13
  end
14
14
 
15
- context "changed files containing a todo" do
15
+ context "changed files containing newly introduced todos" do
16
16
  before do
17
17
  modified = Git::Diff::DiffFile.new(
18
18
  "base",
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.0.2
4
+ version: 0.0.3
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-03 00:00:00.000000000 Z
11
+ date: 2016-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api
@@ -160,6 +160,8 @@ files:
160
160
  - ".gitignore"
161
161
  - ".rubocop.yml"
162
162
  - ".travis.yml"
163
+ - CHANGELOG.md
164
+ - Dangerfile
163
165
  - Gemfile
164
166
  - Guardfile
165
167
  - LICENSE.txt
@@ -168,8 +170,10 @@ files:
168
170
  - danger-todoist.gemspec
169
171
  - lib/danger_plugin.rb
170
172
  - lib/danger_todoist.rb
173
+ - lib/todoist/diff_todo_finder.rb
171
174
  - lib/todoist/gem_version.rb
172
175
  - lib/todoist/plugin.rb
176
+ - spec/diff_todo_finder_spec.rb
173
177
  - spec/spec_helper.rb
174
178
  - spec/todoist_spec.rb
175
179
  homepage: https://github.com/hanneskaeufler/danger-todoist
@@ -198,5 +202,6 @@ specification_version: 4
198
202
  summary: Marking something with a todo is very common during implementing a new feature.
199
203
  Often those todos will get missed in code review.
200
204
  test_files:
205
+ - spec/diff_todo_finder_spec.rb
201
206
  - spec/spec_helper.rb
202
207
  - spec/todoist_spec.rb