danger-todoist 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +3 -0
- data/.gitignore +4 -1
- data/.travis.yml +4 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/Guardfile +2 -2
- data/README.md +2 -2
- data/Rakefile +10 -10
- data/danger-todoist.gemspec +21 -19
- data/lib/todoist/diff_todo_finder.rb +20 -11
- data/lib/todoist/gem_version.rb +1 -1
- data/lib/todoist/plugin.rb +16 -1
- data/spec/diff_todo_finder_spec.rb +21 -1
- data/spec/spec_helper.rb +7 -0
- data/spec/todoist_spec.rb +16 -0
- metadata +33 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ece9544107e09397ee672b6f3a0f0aad2797c664
|
4
|
+
data.tar.gz: 93e8a542c62490dbb51f3adf378abc17f72f92c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ba5ef9e357c74f9194bac0348134d761cb4a8bdf9265f0879dc2414ac464be5fb17545fbf05b4de3282e85f608824825f8f6f33a2fe59e85a54dd15c43dac7d
|
7
|
+
data.tar.gz: 27351b576938f30b197705f3731af8b382d3be794208e6c72a7e68ecadca63a9e220afbf2dd2a6b7ea93b133c5f2c0df05e683e4ee8749ed3de9c2855ae92cb5
|
data/.codeclimate.yml
ADDED
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Guardfile
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
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)
|
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) [![Code Climate](https://codeclimate.com/github/hanneskaeufler/danger-todoist/badges/gpa.svg)](https://codeclimate.com/github/hanneskaeufler/danger-todoist) [![Test Coverage](https://codeclimate.com/github/hanneskaeufler/danger-todoist/badges/coverage.svg)](https://codeclimate.com/github/hanneskaeufler/danger-todoist/coverage)
|
2
2
|
|
3
3
|
# danger-todoist
|
4
4
|
|
5
|
-
danger-todoist is a [https://danger.systems](danger) plugin to automatically notify you of
|
5
|
+
danger-todoist is a [https://danger.systems](https://danger.systems) plugin to automatically notify you of
|
6
6
|
todos left in the code of a pull/merge request.
|
7
7
|
|
8
8
|
## Installation
|
data/Rakefile
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require "rubocop/rake_task"
|
4
4
|
|
5
5
|
RSpec::Core::RakeTask.new(:specs)
|
6
6
|
|
7
7
|
task default: :specs
|
8
8
|
|
9
9
|
task :spec do
|
10
|
-
Rake::Task[
|
11
|
-
Rake::Task[
|
12
|
-
Rake::Task[
|
10
|
+
Rake::Task["specs"].invoke
|
11
|
+
Rake::Task["rubocop"].invoke
|
12
|
+
Rake::Task["spec_docs"].invoke
|
13
13
|
end
|
14
14
|
|
15
|
-
desc
|
15
|
+
desc "Run RuboCop on the lib/specs directory"
|
16
16
|
RuboCop::RakeTask.new(:rubocop) do |task|
|
17
|
-
task.patterns = [
|
17
|
+
task.patterns = ["lib/**/*.rb", "spec/**/*.rb"]
|
18
18
|
end
|
19
19
|
|
20
|
-
desc
|
20
|
+
desc "Ensure that the plugin passes `danger plugins lint`"
|
21
21
|
task :spec_docs do
|
22
|
-
sh
|
22
|
+
sh "bundle exec danger plugins lint"
|
23
23
|
end
|
data/danger-todoist.gemspec
CHANGED
@@ -1,49 +1,51 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require "todoist/gem_version.rb"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = "danger-todoist"
|
8
8
|
spec.version = Todoist::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.description =
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ["Hannes Käufler"]
|
10
|
+
spec.email = ["hannes.kaeufler@gmail.com"]
|
11
|
+
spec.description = "A danger plugin for spotting introduced todos."
|
12
|
+
spec.summary = "Marking something with a todo is very common during implementing a new feature. Often those todos will get missed in code review."
|
13
|
+
spec.homepage = "https://github.com/hanneskaeufler/danger-todoist"
|
14
|
+
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency
|
21
|
+
spec.add_runtime_dependency "danger-plugin-api", "~> 1.0"
|
22
22
|
|
23
23
|
# General ruby development
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
26
|
|
27
27
|
# Testing support
|
28
|
-
spec.add_development_dependency
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.4"
|
29
|
+
spec.add_development_dependency "simplecov", "~> 0.12"
|
30
|
+
spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
|
29
31
|
|
30
32
|
# Linting code and docs
|
31
33
|
spec.add_development_dependency "rubocop", "~> 0.41"
|
32
34
|
spec.add_development_dependency "yard", "~> 0.8"
|
33
35
|
|
34
36
|
# Makes testing easy via `bundle exec guard`
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
37
|
+
spec.add_development_dependency "guard", "~> 2.14"
|
38
|
+
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
37
39
|
|
38
40
|
# If you want to work on older builds of ruby
|
39
|
-
spec.add_development_dependency
|
41
|
+
spec.add_development_dependency "listen", "3.0.7"
|
40
42
|
|
41
43
|
# This gives you the chance to run a REPL inside your tests
|
42
44
|
# via:
|
43
45
|
#
|
44
|
-
# require
|
46
|
+
# require "pry"
|
45
47
|
# binding.pry
|
46
48
|
#
|
47
49
|
# This will stop test execution and let you inspect the results
|
48
|
-
spec.add_development_dependency
|
50
|
+
spec.add_development_dependency "pry", "~> 0"
|
49
51
|
end
|
@@ -1,21 +1,15 @@
|
|
1
1
|
module Danger
|
2
2
|
# Identify todos in a set of diffs
|
3
3
|
class DiffTodoFinder
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
[^a-z0-9\+\s]+ # anything looking like a comment indicator
|
8
|
-
(\n\+)? # allow multiline comment markers
|
9
|
-
\s+ # followed by at least one space
|
10
|
-
(TODO|FIXME) # our todo indicator
|
11
|
-
[\s:]{1} # followed by a space or colon
|
12
|
-
(?<text>.*)$ # matching any text until the end of the line
|
13
|
-
/ix
|
4
|
+
def initialize(keywords)
|
5
|
+
@keywords = keywords
|
6
|
+
end
|
14
7
|
|
15
8
|
def find_diffs_containing_todos(diffs)
|
16
9
|
todos = []
|
10
|
+
regexp = todo_regexp
|
17
11
|
diffs.each do |diff|
|
18
|
-
matches = diff.patch.scan(
|
12
|
+
matches = diff.patch.scan(regexp)
|
19
13
|
next if matches.empty?
|
20
14
|
|
21
15
|
matches.each do |match|
|
@@ -24,5 +18,20 @@ module Danger
|
|
24
18
|
end
|
25
19
|
todos
|
26
20
|
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def todo_regexp
|
25
|
+
/
|
26
|
+
^\+ # we only look at additions, marked by + in diffs
|
27
|
+
\s* # followed by optional space
|
28
|
+
[^a-z0-9\+\s]+ # anything looking like a comment indicator
|
29
|
+
(\n\+)? # allow multiline comment markers
|
30
|
+
\s+ # followed by at least one space
|
31
|
+
(#{@keywords.join("|")}) # our todo indicator
|
32
|
+
[\s:]{1} # followed by a space or colon
|
33
|
+
(?<text>.*)$ # matching any text until the end of the line
|
34
|
+
/ix
|
35
|
+
end
|
27
36
|
end
|
28
37
|
end
|
data/lib/todoist/gem_version.rb
CHANGED
data/lib/todoist/plugin.rb
CHANGED
@@ -29,6 +29,7 @@ module Danger
|
|
29
29
|
#
|
30
30
|
class DangerTodoist < Plugin
|
31
31
|
DEFAULT_MESSAGE = "There remain todo items in the modified code.".freeze
|
32
|
+
DEFAULT_KEYWORDS = %w(TODO FIXME).freeze
|
32
33
|
|
33
34
|
#
|
34
35
|
# Message to be shown
|
@@ -38,6 +39,13 @@ module Danger
|
|
38
39
|
#
|
39
40
|
attr_writer :message
|
40
41
|
|
42
|
+
#
|
43
|
+
# Keywords to recognize as todos
|
44
|
+
#
|
45
|
+
# @attr_writer [Array] keywords Custom array of strings to identify todos
|
46
|
+
# @return [void]
|
47
|
+
attr_writer :keywords
|
48
|
+
|
41
49
|
#
|
42
50
|
# Adds a warning if there are todos found in the modified code
|
43
51
|
#
|
@@ -100,7 +108,13 @@ module Danger
|
|
100
108
|
@todos = []
|
101
109
|
return if files_of_interest.empty?
|
102
110
|
|
103
|
-
@todos = DiffTodoFinder.new
|
111
|
+
@todos = DiffTodoFinder.new(keywords)
|
112
|
+
.find_diffs_containing_todos(diffs_of_interest)
|
113
|
+
end
|
114
|
+
|
115
|
+
def keywords
|
116
|
+
return @keywords unless @keywords.nil?
|
117
|
+
DEFAULT_KEYWORDS
|
104
118
|
end
|
105
119
|
|
106
120
|
def message
|
@@ -114,6 +128,7 @@ module Danger
|
|
114
128
|
|
115
129
|
def diffs_of_interest
|
116
130
|
files_of_interest
|
131
|
+
.compact
|
117
132
|
.map { |file| git.diff_for_file(file) }
|
118
133
|
end
|
119
134
|
end
|
@@ -2,7 +2,9 @@ require File.expand_path("../spec_helper", __FILE__)
|
|
2
2
|
|
3
3
|
module Danger
|
4
4
|
describe Danger::DiffTodoFinder do
|
5
|
-
let(:subject)
|
5
|
+
let(:subject) do
|
6
|
+
Danger::DiffTodoFinder.new(%w(TODO FIXME))
|
7
|
+
end
|
6
8
|
|
7
9
|
describe "#find_diffs_containing_todos" do
|
8
10
|
%w(TODO TODO: todo todo: FIXME fixme FIXME: fixme).each do |marker|
|
@@ -15,6 +17,24 @@ module Danger
|
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
20
|
+
it "identifies todos with changed finder string" do
|
21
|
+
diff = sample_diff("+ # BUG some todo")
|
22
|
+
|
23
|
+
subject = described_class.new(["BUG"])
|
24
|
+
todos = subject.find_diffs_containing_todos([diff])
|
25
|
+
|
26
|
+
expect(todos).to_not be_empty
|
27
|
+
end
|
28
|
+
|
29
|
+
it "doesnt crash but also doesnt find anything with empty keywords" do
|
30
|
+
diff = sample_diff("+ # BUG some todo")
|
31
|
+
|
32
|
+
subject = described_class.new([])
|
33
|
+
todos = subject.find_diffs_containing_todos([diff])
|
34
|
+
|
35
|
+
expect(todos).to be_empty
|
36
|
+
end
|
37
|
+
|
18
38
|
# those comment indicators are ripped off https://github.com/pgilad/leasot
|
19
39
|
%w(# {{ -- // /* <!-- <%# % / -# {{! {{!-- {# <%--).each do |comment|
|
20
40
|
it "identifies todos in languages with '#{comment}' as comments" do
|
data/spec/spec_helper.rb
CHANGED
data/spec/todoist_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.expand_path("../spec_helper", __FILE__)
|
2
2
|
|
3
|
+
# rubocop:disable Metrics/ModuleLength
|
3
4
|
module Danger
|
4
5
|
describe Danger::DangerTodoist do
|
5
6
|
it "should be a plugin" do
|
@@ -63,6 +64,13 @@ PATCH
|
|
63
64
|
expect(warnings).to eq(["changed message"])
|
64
65
|
end
|
65
66
|
|
67
|
+
it "allows the keywords to be changed" do
|
68
|
+
@todoist.keywords = ["find-nothing"]
|
69
|
+
@todoist.warn_for_todos
|
70
|
+
|
71
|
+
expect(warnings).to be_empty
|
72
|
+
end
|
73
|
+
|
66
74
|
it "can print a report, even without warning first" do
|
67
75
|
@todoist.print_todos_table
|
68
76
|
|
@@ -121,6 +129,14 @@ PATCH
|
|
121
129
|
expect(failures).to be_empty
|
122
130
|
expect(markdowns).to be_empty
|
123
131
|
end
|
132
|
+
|
133
|
+
it "does not raise when git returns nil" do
|
134
|
+
invalid = [nil]
|
135
|
+
allow(@dangerfile.git).to receive(:modified_files).and_return(invalid)
|
136
|
+
allow(@dangerfile.git).to receive(:added_files).and_return([])
|
137
|
+
|
138
|
+
expect { @todoist.warn_for_todos }.to_not raise_error
|
139
|
+
end
|
124
140
|
end
|
125
141
|
end
|
126
142
|
end
|
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: 1.
|
4
|
+
version: 1.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-
|
11
|
+
date: 2016-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.12'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.12'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: codeclimate-test-reporter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.0.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.0.0
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: rubocop
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,14 +168,14 @@ dependencies:
|
|
140
168
|
name: pry
|
141
169
|
requirement: !ruby/object:Gem::Requirement
|
142
170
|
requirements:
|
143
|
-
- - "
|
171
|
+
- - "~>"
|
144
172
|
- !ruby/object:Gem::Version
|
145
173
|
version: '0'
|
146
174
|
type: :development
|
147
175
|
prerelease: false
|
148
176
|
version_requirements: !ruby/object:Gem::Requirement
|
149
177
|
requirements:
|
150
|
-
- - "
|
178
|
+
- - "~>"
|
151
179
|
- !ruby/object:Gem::Version
|
152
180
|
version: '0'
|
153
181
|
description: A danger plugin for spotting introduced todos.
|
@@ -157,6 +185,7 @@ executables: []
|
|
157
185
|
extensions: []
|
158
186
|
extra_rdoc_files: []
|
159
187
|
files:
|
188
|
+
- ".codeclimate.yml"
|
160
189
|
- ".gitignore"
|
161
190
|
- ".rubocop.yml"
|
162
191
|
- ".travis.yml"
|