danger-rubocop 0.7.2 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +30 -21
- data/README.md +2 -2
- data/danger-rubocop.gemspec +1 -1
- data/lib/danger_plugin.rb +6 -3
- data/lib/version.rb +1 -1
- data/spec/danger_plugin_spec.rb +41 -11
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8b4d92dd5ddd493b1d27553041631f01e18d822778ff653d6efbede8c9df7b9
|
4
|
+
data.tar.gz: d925de6ae7e157a46ebdaa8194666d1bc0347f8c6c5fd964dd910b5a9151d934
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52c59f565ea64473fccfb198c570949a781f54c34bb063f6db0627133ce83d4e928990d93c7d5dc53e8a9936f7c50e5ab5f7d2c3a06577cc07a53d3a073753a3
|
7
|
+
data.tar.gz: ffb3de2dbead86c8a1fd98974cac247c96dcc639e6d510cd3c377ada6fca2857246664e6e4a41e4728ddf0f7e06449611abd7377b65572328269291269eddea7
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
danger-rubocop (0.
|
4
|
+
danger-rubocop (0.8.0)
|
5
5
|
danger
|
6
6
|
rubocop
|
7
7
|
|
@@ -10,7 +10,7 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
addressable (2.7.0)
|
12
12
|
public_suffix (>= 2.0.2, < 5.0)
|
13
|
-
ast (2.4.
|
13
|
+
ast (2.4.1)
|
14
14
|
bacon (1.2.0)
|
15
15
|
claide (1.0.3)
|
16
16
|
claide-plugins (0.9.2)
|
@@ -21,27 +21,28 @@ GEM
|
|
21
21
|
colored2 (3.1.2)
|
22
22
|
cork (0.3.0)
|
23
23
|
colored2 (~> 3.1)
|
24
|
-
danger (
|
24
|
+
danger (8.0.1)
|
25
25
|
claide (~> 1.0)
|
26
26
|
claide-plugins (>= 0.9.2)
|
27
27
|
colored2 (~> 3.1)
|
28
28
|
cork (~> 0.1)
|
29
|
-
faraday (
|
29
|
+
faraday (>= 0.9.0, < 2.0)
|
30
30
|
faraday-http-cache (~> 2.0)
|
31
|
-
git (~> 1.
|
31
|
+
git (~> 1.7)
|
32
32
|
kramdown (~> 2.0)
|
33
33
|
kramdown-parser-gfm (~> 1.0)
|
34
34
|
no_proxy_fix
|
35
35
|
octokit (~> 4.7)
|
36
36
|
terminal-table (~> 1)
|
37
37
|
diff-lcs (1.2.5)
|
38
|
-
faraday (0.
|
38
|
+
faraday (1.0.1)
|
39
39
|
multipart-post (>= 1.2, < 3)
|
40
|
-
faraday-http-cache (2.
|
41
|
-
faraday (
|
40
|
+
faraday-http-cache (2.2.0)
|
41
|
+
faraday (>= 0.8)
|
42
42
|
ffi (1.9.10)
|
43
43
|
formatador (0.2.5)
|
44
|
-
git (1.
|
44
|
+
git (1.7.0)
|
45
|
+
rchardet (~> 1.8)
|
45
46
|
guard (2.14.0)
|
46
47
|
formatador (>= 0.2.4)
|
47
48
|
listen (>= 2.7, < 4.0)
|
@@ -56,8 +57,8 @@ GEM
|
|
56
57
|
guard (~> 2.1)
|
57
58
|
guard-compat (~> 1.1)
|
58
59
|
rspec (>= 2.99.0, < 4.0)
|
59
|
-
|
60
|
-
|
60
|
+
kramdown (2.3.0)
|
61
|
+
rexml
|
61
62
|
kramdown-parser-gfm (1.1.0)
|
62
63
|
kramdown (~> 2.0)
|
63
64
|
listen (3.0.7)
|
@@ -77,11 +78,12 @@ GEM
|
|
77
78
|
notiffany (0.1.0)
|
78
79
|
nenv (~> 0.1)
|
79
80
|
shellany (~> 0.0)
|
80
|
-
octokit (4.
|
81
|
+
octokit (4.18.0)
|
82
|
+
faraday (>= 0.9)
|
81
83
|
sawyer (~> 0.8.0, >= 0.5.3)
|
82
84
|
open4 (1.3.4)
|
83
|
-
parallel (1.
|
84
|
-
parser (2.
|
85
|
+
parallel (1.19.1)
|
86
|
+
parser (2.7.1.3)
|
85
87
|
ast (~> 2.4.0)
|
86
88
|
prettybacon (0.0.2)
|
87
89
|
bacon (~> 1.2)
|
@@ -89,12 +91,15 @@ GEM
|
|
89
91
|
coderay (~> 1.1.0)
|
90
92
|
method_source (~> 0.8.1)
|
91
93
|
slop (~> 3.4)
|
92
|
-
public_suffix (4.0.
|
94
|
+
public_suffix (4.0.5)
|
93
95
|
rainbow (3.0.0)
|
94
96
|
rake (13.0.1)
|
95
97
|
rb-fsevent (0.9.7)
|
96
98
|
rb-inotify (0.9.7)
|
97
99
|
ffi (>= 0.5.0)
|
100
|
+
rchardet (1.8.0)
|
101
|
+
regexp_parser (1.7.1)
|
102
|
+
rexml (3.2.4)
|
98
103
|
rspec (3.4.0)
|
99
104
|
rspec-core (~> 3.4.0)
|
100
105
|
rspec-expectations (~> 3.4.0)
|
@@ -108,13 +113,17 @@ GEM
|
|
108
113
|
diff-lcs (>= 1.2.0, < 2.0)
|
109
114
|
rspec-support (~> 3.4.0)
|
110
115
|
rspec-support (3.4.1)
|
111
|
-
rubocop (0.
|
112
|
-
jaro_winkler (~> 1.5.1)
|
116
|
+
rubocop (0.85.1)
|
113
117
|
parallel (~> 1.10)
|
114
|
-
parser (>= 2.
|
118
|
+
parser (>= 2.7.0.1)
|
115
119
|
rainbow (>= 2.2.2, < 4.0)
|
120
|
+
regexp_parser (>= 1.7)
|
121
|
+
rexml
|
122
|
+
rubocop-ast (>= 0.0.3)
|
116
123
|
ruby-progressbar (~> 1.7)
|
117
|
-
unicode-display_width (>= 1.4.0, <
|
124
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
125
|
+
rubocop-ast (0.0.3)
|
126
|
+
parser (>= 2.7.0.1)
|
118
127
|
ruby-progressbar (1.10.1)
|
119
128
|
sawyer (0.8.2)
|
120
129
|
addressable (>= 2.3.5)
|
@@ -124,7 +133,7 @@ GEM
|
|
124
133
|
terminal-table (1.8.0)
|
125
134
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
126
135
|
thor (0.19.1)
|
127
|
-
unicode-display_width (1.
|
136
|
+
unicode-display_width (1.7.0)
|
128
137
|
yard (0.9.20)
|
129
138
|
|
130
139
|
PLATFORMS
|
@@ -146,7 +155,7 @@ DEPENDENCIES
|
|
146
155
|
yard
|
147
156
|
|
148
157
|
RUBY VERSION
|
149
|
-
ruby 2.
|
158
|
+
ruby 2.6.0p0
|
150
159
|
|
151
160
|
BUNDLED WITH
|
152
161
|
1.17.3
|
data/README.md
CHANGED
@@ -46,10 +46,10 @@ Runs Ruby files through Rubocop. Generates a `markdown` list of warnings.
|
|
46
46
|
This method accepts a configuration hash.
|
47
47
|
The following keys are supported:
|
48
48
|
|
49
|
-
* `files`: array of file names or glob patterns to determine files to lint
|
49
|
+
* `files`: array of file names or glob patterns to determine files to lint. If omitted, this will lint only the files changed in the pull request. To lint all files every time, pass an empty string; this is the equivalent of typing `rubocop` without specifying any files, and will follow the rules in your `.rubocop.yml`.
|
50
50
|
* `force_exclusion`: pass `true` to pass `--force-exclusion` argument to Rubocop.
|
51
51
|
(this option will instruct rubocop to ignore the files that your rubocop config ignores,
|
52
|
-
despite the plugin providing the list of files
|
52
|
+
despite the plugin providing the list of files explicitly)
|
53
53
|
* `inline_comment`: pass `true` to comment inline of the diffs.
|
54
54
|
* `fail_on_inline_comment`: pass `true` to use `fail` instead of `warn` on inline comment.
|
55
55
|
* `report_danger`: pass true to report errors to Danger, and break CI.
|
data/danger-rubocop.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
20
|
spec.add_dependency 'danger'
|
21
|
-
spec.add_dependency 'rubocop'
|
21
|
+
spec.add_dependency 'rubocop', '~> 0.83'
|
22
22
|
|
23
23
|
# General ruby development
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
data/lib/danger_plugin.rb
CHANGED
@@ -53,7 +53,7 @@ module Danger
|
|
53
53
|
private
|
54
54
|
|
55
55
|
def rubocop(files_to_lint, force_exclusion, only_report_new_offenses, config_path: nil)
|
56
|
-
base_command = ['rubocop', '-f', 'json']
|
56
|
+
base_command = ['rubocop', '-f', 'json', '--only-recognized-file-types']
|
57
57
|
base_command.concat(['--force-exclusion']) if force_exclusion
|
58
58
|
base_command.concat(['--config', config_path.shellescape]) unless config_path.nil?
|
59
59
|
|
@@ -78,14 +78,17 @@ module Danger
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def added_lines(path)
|
81
|
-
git.diff_for_file(path)
|
81
|
+
diff_for_file = git.diff_for_file(path)
|
82
|
+
return [] if diff_for_file.nil?
|
83
|
+
|
84
|
+
diff_for_file
|
82
85
|
.patch
|
83
86
|
.split("\n@@")
|
84
87
|
.tap(&:shift)
|
85
88
|
.flat_map do |chunk|
|
86
89
|
first_line, *diff = chunk.split("\n")
|
87
90
|
# Get start from diff.
|
88
|
-
lineno = first_line.match(/\+(\d+)
|
91
|
+
lineno = first_line.match(/\+(\d+),?(\d?)/).captures.first.to_i
|
89
92
|
diff.each_with_object([]) do |current_line, added_lines|
|
90
93
|
added_lines << lineno if current_line.start_with?('+')
|
91
94
|
lineno += 1 unless current_line.start_with?('-')
|
data/lib/version.rb
CHANGED
data/spec/danger_plugin_spec.rb
CHANGED
@@ -107,6 +107,36 @@ module Danger
|
|
107
107
|
it 'handles git diff' do
|
108
108
|
expect(@rubocop.send(:added_lines, 'SAMPLE')).to eq([1, 2])
|
109
109
|
end
|
110
|
+
|
111
|
+
context "single line added to a new file" do
|
112
|
+
before do
|
113
|
+
allow(@rubocop.git).to receive(:diff_for_file).with('SAMPLE') do
|
114
|
+
instance_double('Git::Diff::DiffFile', patch: <<~DIFF)
|
115
|
+
diff --git a/SAMPLE b/SAMPLE
|
116
|
+
new file mode 100644
|
117
|
+
index 0000000..7bba8c8
|
118
|
+
--- /dev/null
|
119
|
+
+++ b/SAMPLE
|
120
|
+
@@ -0,0 +1 @@
|
121
|
+
+line 1
|
122
|
+
DIFF
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'handles git diff' do
|
127
|
+
expect(@rubocop.send(:added_lines, 'SAMPLE')).to eq([1])
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'no such file' do
|
132
|
+
before do
|
133
|
+
allow(@rubocop.git).to receive(:diff_for_file).with('SAMPLE').and_return(nil)
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'return empty array' do
|
137
|
+
expect(@rubocop.send(:added_lines, 'SAMPLE')).to eq([])
|
138
|
+
end
|
139
|
+
end
|
110
140
|
end
|
111
141
|
|
112
142
|
describe :lint_files do
|
@@ -146,7 +176,7 @@ module Danger
|
|
146
176
|
|
147
177
|
it 'handles a rubocop report for specified files' do
|
148
178
|
allow(@rubocop).to receive(:`)
|
149
|
-
.with('bundle exec rubocop -f json --config path/to/rubocop.yml spec/fixtures/ruby_file.rb')
|
179
|
+
.with('bundle exec rubocop -f json --only-recognized-file-types --config path/to/rubocop.yml spec/fixtures/ruby_file.rb')
|
150
180
|
.and_return(response_ruby_file)
|
151
181
|
|
152
182
|
# Do it
|
@@ -162,7 +192,7 @@ module Danger
|
|
162
192
|
|
163
193
|
it 'includes cop names when include_cop_names is set' do
|
164
194
|
allow(@rubocop).to receive(:`)
|
165
|
-
.with('bundle exec rubocop -f json --config path/to/rubocop.yml spec/fixtures/ruby_file.rb')
|
195
|
+
.with('bundle exec rubocop -f json --only-recognized-file-types --config path/to/rubocop.yml spec/fixtures/ruby_file.rb')
|
166
196
|
.and_return(response_ruby_file)
|
167
197
|
|
168
198
|
# Do it
|
@@ -178,7 +208,7 @@ module Danger
|
|
178
208
|
|
179
209
|
it 'handles a rubocop report for specified files (legacy)' do
|
180
210
|
allow(@rubocop).to receive(:`)
|
181
|
-
.with('bundle exec rubocop -f json spec/fixtures/ruby_file.rb')
|
211
|
+
.with('bundle exec rubocop -f json --only-recognized-file-types spec/fixtures/ruby_file.rb')
|
182
212
|
.and_return(response_ruby_file)
|
183
213
|
|
184
214
|
# Do it
|
@@ -194,7 +224,7 @@ module Danger
|
|
194
224
|
|
195
225
|
it 'appends --force-exclusion argument when force_exclusion is set' do
|
196
226
|
allow(@rubocop).to receive(:`)
|
197
|
-
.with('bundle exec rubocop -f json --force-exclusion spec/fixtures/ruby_file.rb')
|
227
|
+
.with('bundle exec rubocop -f json --only-recognized-file-types --force-exclusion spec/fixtures/ruby_file.rb')
|
198
228
|
.and_return(response_ruby_file)
|
199
229
|
|
200
230
|
# Do it
|
@@ -214,7 +244,7 @@ module Danger
|
|
214
244
|
.and_return(["spec/fixtures/another_ruby_file.rb"])
|
215
245
|
|
216
246
|
allow(@rubocop).to receive(:`)
|
217
|
-
.with('bundle exec rubocop -f json spec/fixtures/another_ruby_file.rb')
|
247
|
+
.with('bundle exec rubocop -f json --only-recognized-file-types spec/fixtures/another_ruby_file.rb')
|
218
248
|
.and_return(response_another_ruby_file)
|
219
249
|
|
220
250
|
@rubocop.lint
|
@@ -230,7 +260,7 @@ module Danger
|
|
230
260
|
.and_return(['spec/fixtures/ruby_file.rb'])
|
231
261
|
allow(@rubocop.git).to receive(:added_files).and_return([])
|
232
262
|
allow(@rubocop).to receive(:`)
|
233
|
-
.with('bundle exec rubocop -f json spec/fixtures/ruby_file.rb')
|
263
|
+
.with('bundle exec rubocop -f json --only-recognized-file-types spec/fixtures/ruby_file.rb')
|
234
264
|
.and_return(response_ruby_file)
|
235
265
|
|
236
266
|
@rubocop.lint
|
@@ -252,13 +282,13 @@ EOS
|
|
252
282
|
.and_return(['spec/fixtures/ruby_file.rb'])
|
253
283
|
allow(@rubocop.git).to receive(:added_files).and_return([])
|
254
284
|
allow(@rubocop).to receive(:`)
|
255
|
-
.with('bundle exec rubocop -f json spec/fixtures/ruby_file.rb')
|
285
|
+
.with('bundle exec rubocop -f json --only-recognized-file-types spec/fixtures/ruby_file.rb')
|
256
286
|
.and_return(response_ruby_file)
|
257
287
|
|
258
288
|
@rubocop.lint(inline_comment: true)
|
259
289
|
|
260
290
|
expect(@rubocop.violation_report[:warnings].first.to_s)
|
261
|
-
.to eq("Violation Don't do that! { sticky: false, file: spec/fixtures/ruby_file.rb, line: 13 }")
|
291
|
+
.to eq("Violation Don't do that! { sticky: false, file: spec/fixtures/ruby_file.rb, line: 13, type: warning }")
|
262
292
|
end
|
263
293
|
end
|
264
294
|
|
@@ -268,13 +298,13 @@ EOS
|
|
268
298
|
.and_return(['spec/fixtures/ruby_file.rb'])
|
269
299
|
allow(@rubocop.git).to receive(:added_files).and_return([])
|
270
300
|
allow(@rubocop).to receive(:`)
|
271
|
-
.with('bundle exec rubocop -f json spec/fixtures/ruby_file.rb')
|
301
|
+
.with('bundle exec rubocop -f json --only-recognized-file-types spec/fixtures/ruby_file.rb')
|
272
302
|
.and_return(response_ruby_file)
|
273
303
|
|
274
304
|
@rubocop.lint(fail_on_inline_comment: true, inline_comment: true)
|
275
305
|
|
276
306
|
expect(@rubocop.violation_report[:errors].first.to_s)
|
277
|
-
.to eq("Violation Don't do that! { sticky: false, file: spec/fixtures/ruby_file.rb, line: 13 }")
|
307
|
+
.to eq("Violation Don't do that! { sticky: false, file: spec/fixtures/ruby_file.rb, line: 13, type: error }")
|
278
308
|
end
|
279
309
|
end
|
280
310
|
end
|
@@ -301,7 +331,7 @@ EOS
|
|
301
331
|
.and_return(['spec/fixtures/ruby_file.rb'])
|
302
332
|
allow(@rubocop.git).to receive(:added_files).and_return([])
|
303
333
|
allow(@rubocop).to receive(:`)
|
304
|
-
.with('bundle exec rubocop -f json spec/fixtures/ruby_file.rb')
|
334
|
+
.with('bundle exec rubocop -f json --only-recognized-file-types spec/fixtures/ruby_file.rb')
|
305
335
|
.and_return(response_ruby_file)
|
306
336
|
|
307
337
|
expect(@rubocop).to receive(:fail).with(fail_msg)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ash Furrow
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: rubocop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '0.83'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '0.83'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -177,7 +177,7 @@ homepage: https://github.com/ashfurrow/danger-rubocop
|
|
177
177
|
licenses:
|
178
178
|
- MIT
|
179
179
|
metadata: {}
|
180
|
-
post_install_message:
|
180
|
+
post_install_message:
|
181
181
|
rdoc_options: []
|
182
182
|
require_paths:
|
183
183
|
- lib
|
@@ -192,8 +192,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
192
|
- !ruby/object:Gem::Version
|
193
193
|
version: '0'
|
194
194
|
requirements: []
|
195
|
-
rubygems_version: 3.0.
|
196
|
-
signing_key:
|
195
|
+
rubygems_version: 3.0.8
|
196
|
+
signing_key:
|
197
197
|
specification_version: 4
|
198
198
|
summary: A Danger plugin for running Ruby files through Rubocop.
|
199
199
|
test_files:
|