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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a9300d0182df857bcceb2f773095c36924e04dc
4
- data.tar.gz: 89cb101a4effda323f9fa5e8937ee1d8c4809a4e
3
+ metadata.gz: ece9544107e09397ee672b6f3a0f0aad2797c664
4
+ data.tar.gz: 93e8a542c62490dbb51f3adf378abc17f72f92c5
5
5
  SHA512:
6
- metadata.gz: 1135e1b4d7a58c5a49c8d071719f7a088a63c49bcd8da113558799e2af3b860e8fd97bc6504307076cef47f7c24ff6a97fdb61afc8ece63a44bde34de0559ebd
7
- data.tar.gz: 558aac3afe414446e3730bdeb8229793b88612c1f2cc073f4ec8c7e0b34d68bf7b61891a2bc5aa7593258ef3859a45ebd1425c1b1003677ed83a86a59bf1a0c8
6
+ metadata.gz: 8ba5ef9e357c74f9194bac0348134d761cb4a8bdf9265f0879dc2414ac464be5fb17545fbf05b4de3282e85f608824825f8f6f33a2fe59e85a54dd15c43dac7d
7
+ data.tar.gz: 27351b576938f30b197705f3731af8b382d3be794208e6c72a7e68ecadca63a9e220afbf2dd2a6b7ea93b133c5f2c0df05e683e4ee8749ed3de9c2855ae92cb5
@@ -0,0 +1,3 @@
1
+ engines:
2
+ fixme:
3
+ enabled: false
data/.gitignore CHANGED
@@ -1,3 +1,6 @@
1
1
  .DS_Store
2
- pkg
3
2
  .idea/
3
+ .yardoc/
4
+ Gemfile.lock
5
+ coverage/
6
+ pkg
@@ -12,4 +12,7 @@ before_script:
12
12
  - bundle exec danger
13
13
 
14
14
  script:
15
- - bundle exec rake spec
15
+ - COVERAGE=true bundle exec rake spec
16
+
17
+ after_script:
18
+ - bundle exec codeclimate-test-reporter
@@ -1,5 +1,10 @@
1
1
  ## master
2
2
 
3
+ ## 1.2.0
4
+
5
+ * fixes crash when git returns nil - hanneskaeufler
6
+ * allow to specify todo keywords - hanneskaeufler
7
+
3
8
  ## 1.1.0
4
9
 
5
10
  * add support for multiline comments - hanneskaeufler
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in danger-todoist.gemspec
4
4
  gemspec
data/Guardfile CHANGED
@@ -3,8 +3,8 @@
3
3
 
4
4
  # To run, use `bundle exec guard`.
5
5
 
6
- guard :rspec, cmd: 'bundle exec rspec' do
7
- require 'guard/rspec/dsl'
6
+ guard :rspec, cmd: "bundle exec rspec" do
7
+ require "guard/rspec/dsl"
8
8
  dsl = Guard::RSpec::Dsl.new(self)
9
9
 
10
10
  # RSpec files
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 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
- require 'rubocop/rake_task'
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['specs'].invoke
11
- Rake::Task['rubocop'].invoke
12
- Rake::Task['spec_docs'].invoke
10
+ Rake::Task["specs"].invoke
11
+ Rake::Task["rubocop"].invoke
12
+ Rake::Task["spec_docs"].invoke
13
13
  end
14
14
 
15
- desc 'Run RuboCop on the lib/specs directory'
15
+ desc "Run RuboCop on the lib/specs directory"
16
16
  RuboCop::RakeTask.new(:rubocop) do |task|
17
- task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
17
+ task.patterns = ["lib/**/*.rb", "spec/**/*.rb"]
18
18
  end
19
19
 
20
- desc 'Ensure that the plugin passes `danger plugins lint`'
20
+ desc "Ensure that the plugin passes `danger plugins lint`"
21
21
  task :spec_docs do
22
- sh 'bundle exec danger plugins lint'
22
+ sh "bundle exec danger plugins lint"
23
23
  end
@@ -1,49 +1,51 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'todoist/gem_version.rb'
4
+ require "todoist/gem_version.rb"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = 'danger-todoist'
7
+ spec.name = "danger-todoist"
8
8
  spec.version = Todoist::VERSION
9
- spec.authors = ['Hannes Käufler']
10
- spec.email = ['hannes.kaeufler@gmail.com']
11
- spec.description = %q{A danger plugin for spotting introduced todos.}
12
- spec.summary = %q{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'
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 = ['lib']
19
+ spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
21
+ spec.add_runtime_dependency "danger-plugin-api", "~> 1.0"
22
22
 
23
23
  # General ruby development
24
- spec.add_development_dependency 'bundler', '~> 1.3'
25
- spec.add_development_dependency 'rake', '~> 10.0'
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 'rspec', '~> 3.4'
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 'guard', '~> 2.14'
36
- spec.add_development_dependency 'guard-rspec', '~> 4.7'
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 'listen', '3.0.7'
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 'pry'
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 'pry'
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
- TODO_REGEXP = /
5
- ^\+ # we only look at additions, marked by + in diffs
6
- \s* # followed by optional space
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(TODO_REGEXP)
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
@@ -1,3 +1,3 @@
1
1
  module Todoist
2
- VERSION = "1.1.0".freeze
2
+ VERSION = "1.2.0".freeze
3
3
  end
@@ -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.find_diffs_containing_todos(diffs_of_interest)
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) { Danger::DiffTodoFinder.new }
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
@@ -1,3 +1,10 @@
1
+ require "simplecov"
2
+ if ENV["COVERAGE"]
3
+ SimpleCov.start do
4
+ add_filter "/spec/"
5
+ end
6
+ end
7
+
1
8
  require "pathname"
2
9
  ROOT = Pathname.new(File.expand_path("../../", __FILE__))
3
10
  $LOAD_PATH.unshift((ROOT + "lib").to_s)
@@ -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.1.0
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-09-30 00:00:00.000000000 Z
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"