danger-rubocop 0.9.3 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +65 -59
- data/README.md +8 -1
- data/lib/danger_plugin.rb +17 -13
- data/lib/version.rb +1 -1
- data/spec/danger_plugin_spec.rb +20 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e91901b79a6155f5d70feebbbd301fad023ea8a8fd4a37e8f04fe413d3859326
|
4
|
+
data.tar.gz: 469efcdadad9b126197d88d0d0aeaa51497a3542f1e6bb0d66977d8d195facde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d40eb3980c2456134e43cd12c0bb2dc7c0c2fce9739e8585a489c6db364f1c38a08e1576b16359a1da71e628ffe308b70b98ae58e5a2fbff38e2f679fff53cc5
|
7
|
+
data.tar.gz: a4d1dd07e6fa2f08498675ae3d1bef2faca730506cdbeb895b3c2586e8f28fb638bff4af95b2816faff68d7086a8f9da08abaebf743302588480e2e6ec9f881f
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
danger-rubocop (0.9.
|
4
|
+
danger-rubocop (0.9.5)
|
5
5
|
danger
|
6
6
|
rubocop (~> 1.0)
|
7
7
|
|
@@ -10,18 +10,18 @@ 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.2)
|
14
14
|
bacon (1.2.0)
|
15
15
|
claide (1.0.3)
|
16
16
|
claide-plugins (0.9.2)
|
17
17
|
cork
|
18
18
|
nap
|
19
19
|
open4 (~> 1.3)
|
20
|
-
coderay (1.1.
|
20
|
+
coderay (1.1.3)
|
21
21
|
colored2 (3.1.2)
|
22
22
|
cork (0.3.0)
|
23
23
|
colored2 (~> 3.1)
|
24
|
-
danger (8.2.
|
24
|
+
danger (8.2.3)
|
25
25
|
claide (~> 1.0)
|
26
26
|
claide-plugins (>= 0.9.2)
|
27
27
|
colored2 (~> 3.1)
|
@@ -33,110 +33,116 @@ GEM
|
|
33
33
|
kramdown-parser-gfm (~> 1.0)
|
34
34
|
no_proxy_fix
|
35
35
|
octokit (~> 4.7)
|
36
|
-
terminal-table (
|
37
|
-
diff-lcs (1.
|
38
|
-
faraday (1.
|
36
|
+
terminal-table (>= 1, < 4)
|
37
|
+
diff-lcs (1.4.4)
|
38
|
+
faraday (1.4.2)
|
39
|
+
faraday-em_http (~> 1.0)
|
40
|
+
faraday-em_synchrony (~> 1.0)
|
41
|
+
faraday-excon (~> 1.1)
|
42
|
+
faraday-net_http (~> 1.0)
|
43
|
+
faraday-net_http_persistent (~> 1.1)
|
39
44
|
multipart-post (>= 1.2, < 3)
|
40
|
-
ruby2_keywords
|
45
|
+
ruby2_keywords (>= 0.0.4)
|
46
|
+
faraday-em_http (1.0.0)
|
47
|
+
faraday-em_synchrony (1.0.0)
|
48
|
+
faraday-excon (1.1.0)
|
41
49
|
faraday-http-cache (2.2.0)
|
42
50
|
faraday (>= 0.8)
|
43
|
-
|
51
|
+
faraday-net_http (1.0.1)
|
52
|
+
faraday-net_http_persistent (1.1.0)
|
53
|
+
ffi (1.15.0)
|
44
54
|
formatador (0.2.5)
|
45
|
-
git (1.
|
55
|
+
git (1.8.1)
|
46
56
|
rchardet (~> 1.8)
|
47
|
-
guard (2.
|
57
|
+
guard (2.16.2)
|
48
58
|
formatador (>= 0.2.4)
|
49
59
|
listen (>= 2.7, < 4.0)
|
50
|
-
lumberjack (
|
60
|
+
lumberjack (>= 1.0.12, < 2.0)
|
51
61
|
nenv (~> 0.1)
|
52
62
|
notiffany (~> 0.0)
|
53
63
|
pry (>= 0.9.12)
|
54
64
|
shellany (~> 0.0)
|
55
65
|
thor (>= 0.18.1)
|
56
66
|
guard-compat (1.2.1)
|
57
|
-
guard-rspec (4.7.
|
67
|
+
guard-rspec (4.7.3)
|
58
68
|
guard (~> 2.1)
|
59
69
|
guard-compat (~> 1.1)
|
60
70
|
rspec (>= 2.99.0, < 4.0)
|
61
|
-
kramdown (2.3.
|
71
|
+
kramdown (2.3.1)
|
62
72
|
rexml
|
63
73
|
kramdown-parser-gfm (1.1.0)
|
64
74
|
kramdown (~> 2.0)
|
65
75
|
listen (3.0.7)
|
66
76
|
rb-fsevent (>= 0.9.3)
|
67
77
|
rb-inotify (>= 0.9.7)
|
68
|
-
lumberjack (1.
|
69
|
-
|
70
|
-
|
71
|
-
mocha (
|
72
|
-
metaclass (~> 0.0.1)
|
73
|
-
mocha-on-bacon (0.2.2)
|
78
|
+
lumberjack (1.2.8)
|
79
|
+
method_source (1.0.0)
|
80
|
+
mocha (1.12.0)
|
81
|
+
mocha-on-bacon (0.2.3)
|
74
82
|
mocha (>= 0.13.0)
|
75
83
|
multipart-post (2.1.1)
|
76
84
|
nap (1.1.0)
|
77
85
|
nenv (0.3.0)
|
78
86
|
no_proxy_fix (0.1.2)
|
79
|
-
notiffany (0.1.
|
87
|
+
notiffany (0.1.3)
|
80
88
|
nenv (~> 0.1)
|
81
89
|
shellany (~> 0.0)
|
82
|
-
octokit (4.
|
90
|
+
octokit (4.21.0)
|
83
91
|
faraday (>= 0.9)
|
84
92
|
sawyer (~> 0.8.0, >= 0.5.3)
|
85
93
|
open4 (1.3.4)
|
86
94
|
parallel (1.20.1)
|
87
|
-
parser (
|
95
|
+
parser (3.0.1.1)
|
88
96
|
ast (~> 2.4.1)
|
89
97
|
prettybacon (0.0.2)
|
90
98
|
bacon (~> 1.2)
|
91
|
-
pry (0.
|
92
|
-
coderay (~> 1.1
|
93
|
-
method_source (~> 0
|
94
|
-
slop (~> 3.4)
|
99
|
+
pry (0.14.1)
|
100
|
+
coderay (~> 1.1)
|
101
|
+
method_source (~> 1.0)
|
95
102
|
public_suffix (4.0.6)
|
96
103
|
rainbow (3.0.0)
|
97
|
-
rake (13.0.
|
98
|
-
rb-fsevent (0.
|
99
|
-
rb-inotify (0.
|
100
|
-
ffi (
|
104
|
+
rake (13.0.3)
|
105
|
+
rb-fsevent (0.10.4)
|
106
|
+
rb-inotify (0.10.1)
|
107
|
+
ffi (~> 1.0)
|
101
108
|
rchardet (1.8.0)
|
102
|
-
regexp_parser (2.
|
103
|
-
rexml (3.2.
|
104
|
-
rspec (3.
|
105
|
-
rspec-core (~> 3.
|
106
|
-
rspec-expectations (~> 3.
|
107
|
-
rspec-mocks (~> 3.
|
108
|
-
rspec-core (3.
|
109
|
-
rspec-support (~> 3.
|
110
|
-
rspec-expectations (3.
|
109
|
+
regexp_parser (2.1.1)
|
110
|
+
rexml (3.2.5)
|
111
|
+
rspec (3.10.0)
|
112
|
+
rspec-core (~> 3.10.0)
|
113
|
+
rspec-expectations (~> 3.10.0)
|
114
|
+
rspec-mocks (~> 3.10.0)
|
115
|
+
rspec-core (3.10.1)
|
116
|
+
rspec-support (~> 3.10.0)
|
117
|
+
rspec-expectations (3.10.1)
|
111
118
|
diff-lcs (>= 1.2.0, < 2.0)
|
112
|
-
rspec-support (~> 3.
|
113
|
-
rspec-mocks (3.
|
119
|
+
rspec-support (~> 3.10.0)
|
120
|
+
rspec-mocks (3.10.2)
|
114
121
|
diff-lcs (>= 1.2.0, < 2.0)
|
115
|
-
rspec-support (~> 3.
|
116
|
-
rspec-support (3.
|
117
|
-
rubocop (1.
|
122
|
+
rspec-support (~> 3.10.0)
|
123
|
+
rspec-support (3.10.2)
|
124
|
+
rubocop (1.16.0)
|
118
125
|
parallel (~> 1.10)
|
119
|
-
parser (>=
|
126
|
+
parser (>= 3.0.0.0)
|
120
127
|
rainbow (>= 2.2.2, < 4.0)
|
121
|
-
regexp_parser (>=
|
128
|
+
regexp_parser (>= 1.8, < 3.0)
|
122
129
|
rexml
|
123
|
-
rubocop-ast (>= 1.2.0)
|
130
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
124
131
|
ruby-progressbar (~> 1.7)
|
125
|
-
unicode-display_width (>= 1.4.0, <
|
126
|
-
rubocop-ast (1.
|
127
|
-
parser (>=
|
128
|
-
ruby-progressbar (1.
|
129
|
-
ruby2_keywords (0.0.
|
132
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
133
|
+
rubocop-ast (1.7.0)
|
134
|
+
parser (>= 3.0.1.1)
|
135
|
+
ruby-progressbar (1.11.0)
|
136
|
+
ruby2_keywords (0.0.4)
|
130
137
|
sawyer (0.8.2)
|
131
138
|
addressable (>= 2.3.5)
|
132
139
|
faraday (> 0.8, < 2.0)
|
133
140
|
shellany (0.0.1)
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
yard (0.9.20)
|
141
|
+
terminal-table (3.0.1)
|
142
|
+
unicode-display_width (>= 1.1.1, < 3)
|
143
|
+
thor (1.1.0)
|
144
|
+
unicode-display_width (2.0.0)
|
145
|
+
yard (0.9.26)
|
140
146
|
|
141
147
|
PLATFORMS
|
142
148
|
ruby
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Danger Rubocop
|
4
4
|
|
5
|
-
A [Danger](https://github.com/danger/danger) plugin for [Rubocop](https://github.com/bbatsov/rubocop).
|
5
|
+
A [Danger](https://github.com/danger/danger) plugin for [Rubocop](https://github.com/bbatsov/rubocop) (and compatible wrappers such as [Standard](https://github.com/testdouble/standard/)).
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -37,6 +37,12 @@ github.dismiss_out_of_range_messages
|
|
37
37
|
rubocop.lint inline_comment: true
|
38
38
|
```
|
39
39
|
|
40
|
+
> Format using `standardrb` instead of Rubocop
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
rubocop.lint rubocop_cmd: 'standardrb'
|
44
|
+
```
|
45
|
+
|
40
46
|
#### Methods
|
41
47
|
|
42
48
|
`lint(config: Hash)`
|
@@ -57,6 +63,7 @@ The following keys are supported:
|
|
57
63
|
* `only_report_new_offenses`: pass `true` to only report offenses that are in current user's scope.
|
58
64
|
Note that this won't mark offenses for _Metrics/XXXLength_ if you add lines to an already existing scope.
|
59
65
|
* `include_cop_names`: Prepends cop names to the output messages. Example: "Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body end."
|
66
|
+
* `rubocop_cmd`: Allows you to change the rubocop executable that's invoked. This is used to support rubocop wrappers like [Standard](https://github.com/testdouble/standard/) by passing `standardrb` as the value.
|
60
67
|
|
61
68
|
|
62
69
|
Passing `files` as only argument is also supported for backward compatibility.
|
data/lib/danger_plugin.rb
CHANGED
@@ -36,9 +36,10 @@ module Danger
|
|
36
36
|
inline_comment = config[:inline_comment] || false
|
37
37
|
fail_on_inline_comment = config[:fail_on_inline_comment] || false
|
38
38
|
include_cop_names = config[:include_cop_names] || false
|
39
|
+
rubocop_cmd = config[:rubocop_cmd] || 'rubocop'
|
39
40
|
|
40
41
|
files_to_lint = fetch_files_to_lint(files)
|
41
|
-
files_to_report = rubocop(files_to_lint, force_exclusion, only_report_new_offenses, config_path: config_path)
|
42
|
+
files_to_report = rubocop(files_to_lint, force_exclusion, only_report_new_offenses, cmd: rubocop_cmd, config_path: config_path)
|
42
43
|
|
43
44
|
return if files_to_report.empty?
|
44
45
|
return report_failures files_to_report if report_danger
|
@@ -52,8 +53,8 @@ module Danger
|
|
52
53
|
|
53
54
|
private
|
54
55
|
|
55
|
-
def rubocop(files_to_lint, force_exclusion, only_report_new_offenses, config_path: nil)
|
56
|
-
base_command = [
|
56
|
+
def rubocop(files_to_lint, force_exclusion, only_report_new_offenses, cmd: 'rubocop', config_path: nil)
|
57
|
+
base_command = [cmd, '-f', 'json', '--only-recognized-file-types']
|
57
58
|
base_command.concat(['--force-exclusion']) if force_exclusion
|
58
59
|
base_command.concat(['--config', config_path.shellescape]) unless config_path.nil?
|
59
60
|
|
@@ -128,24 +129,27 @@ module Danger
|
|
128
129
|
file['offenses'].map do |offense|
|
129
130
|
offense_message = offense['message']
|
130
131
|
offense_message = offense['cop_name'] + ': ' + offense_message if include_cop_names
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
line: offense['location']['line']
|
136
|
-
}
|
137
|
-
]
|
132
|
+
kargs = {
|
133
|
+
file: file['path'],
|
134
|
+
line: offense['location']['line']
|
135
|
+
}
|
138
136
|
if fail_on_inline_comment
|
139
|
-
fail(
|
137
|
+
fail(offense_message, **kargs)
|
140
138
|
else
|
141
|
-
warn(
|
139
|
+
warn(offense_message, **kargs)
|
142
140
|
end
|
143
141
|
end
|
144
142
|
end
|
145
143
|
end
|
146
144
|
|
147
145
|
def fetch_files_to_lint(files = nil)
|
148
|
-
to_lint =
|
146
|
+
to_lint = if files.nil?
|
147
|
+
# when files are renamed, git.modified_files contains the old name not the new one, so we need to do the convertion
|
148
|
+
renaming_map = (git.renamed_files || []).map { |e| [e[:before], e[:after]] }.to_h
|
149
|
+
(git.modified_files.map { |f| renaming_map[f] || f }) + git.added_files
|
150
|
+
else
|
151
|
+
Dir.glob(files)
|
152
|
+
end
|
149
153
|
Shellwords.join(to_lint)
|
150
154
|
end
|
151
155
|
end
|
data/lib/version.rb
CHANGED
data/spec/danger_plugin_spec.rb
CHANGED
@@ -241,10 +241,12 @@ module Danger
|
|
241
241
|
it 'handles a rubocop report for files changed in the PR' do
|
242
242
|
allow(@rubocop.git).to receive(:added_files).and_return([])
|
243
243
|
allow(@rubocop.git).to receive(:modified_files)
|
244
|
-
.and_return(["spec/fixtures/another_ruby_file.rb"])
|
244
|
+
.and_return(["spec/fixtures/old_file_name.rb", "spec/fixtures/another_ruby_file.rb"])
|
245
|
+
allow(@rubocop.git).to receive(:renamed_files)
|
246
|
+
.and_return([{before: "spec/fixtures/old_file_name.rb", after: "spec/fixtures/new_file_name.rb"}])
|
245
247
|
|
246
248
|
allow(@rubocop).to receive(:`)
|
247
|
-
.with('bundle exec rubocop -f json --only-recognized-file-types spec/fixtures/another_ruby_file.rb')
|
249
|
+
.with('bundle exec rubocop -f json --only-recognized-file-types spec/fixtures/new_file_name.rb spec/fixtures/another_ruby_file.rb')
|
248
250
|
.and_return(response_another_ruby_file)
|
249
251
|
|
250
252
|
@rubocop.lint
|
@@ -259,6 +261,7 @@ module Danger
|
|
259
261
|
allow(@rubocop.git).to receive(:modified_files)
|
260
262
|
.and_return(['spec/fixtures/ruby_file.rb'])
|
261
263
|
allow(@rubocop.git).to receive(:added_files).and_return([])
|
264
|
+
allow(@rubocop.git).to receive(:renamed_files).and_return([])
|
262
265
|
allow(@rubocop).to receive(:`)
|
263
266
|
.with('bundle exec rubocop -f json --only-recognized-file-types spec/fixtures/ruby_file.rb')
|
264
267
|
.and_return(response_ruby_file)
|
@@ -281,6 +284,7 @@ EOS
|
|
281
284
|
allow(@rubocop.git).to receive(:modified_files)
|
282
285
|
.and_return(['spec/fixtures/ruby_file.rb'])
|
283
286
|
allow(@rubocop.git).to receive(:added_files).and_return([])
|
287
|
+
allow(@rubocop.git).to receive(:renamed_files).and_return([])
|
284
288
|
allow(@rubocop).to receive(:`)
|
285
289
|
.with('bundle exec rubocop -f json --only-recognized-file-types spec/fixtures/ruby_file.rb')
|
286
290
|
.and_return(response_ruby_file)
|
@@ -297,6 +301,7 @@ EOS
|
|
297
301
|
allow(@rubocop.git).to receive(:modified_files)
|
298
302
|
.and_return(['spec/fixtures/ruby_file.rb'])
|
299
303
|
allow(@rubocop.git).to receive(:added_files).and_return([])
|
304
|
+
allow(@rubocop.git).to receive(:renamed_files).and_return([])
|
300
305
|
allow(@rubocop).to receive(:`)
|
301
306
|
.with('bundle exec rubocop -f json --only-recognized-file-types spec/fixtures/ruby_file.rb')
|
302
307
|
.and_return(response_ruby_file)
|
@@ -307,6 +312,17 @@ EOS
|
|
307
312
|
.to eq("Violation Don't do that! { sticky: false, file: spec/fixtures/ruby_file.rb, line: 13, type: error }")
|
308
313
|
end
|
309
314
|
end
|
315
|
+
|
316
|
+
context 'using standardrb cmd' do
|
317
|
+
it 'executes using the standardrb cmd' do
|
318
|
+
allow(@rubocop).to receive(:`)
|
319
|
+
.with('bundle exec standardrb -f json --only-recognized-file-types --config path/to/rubocop.yml spec/fixtures/ruby_file.rb')
|
320
|
+
.and_return(response_ruby_file)
|
321
|
+
|
322
|
+
# Do it
|
323
|
+
@rubocop.lint(files: 'spec/fixtures/ruby*.rb', rubocop_cmd: 'standardrb', config: 'path/to/rubocop.yml')
|
324
|
+
end
|
325
|
+
end
|
310
326
|
end
|
311
327
|
|
312
328
|
describe 'a filename with special characters' do
|
@@ -319,6 +335,7 @@ EOS
|
|
319
335
|
allow(@rubocop.git).to receive(:modified_files)
|
320
336
|
.and_return(modified_files)
|
321
337
|
allow(@rubocop.git).to receive(:added_files).and_return([])
|
338
|
+
allow(@rubocop.git).to receive(:renamed_files).and_return([])
|
322
339
|
|
323
340
|
expect { @rubocop.lint }.not_to raise_error
|
324
341
|
end
|
@@ -330,6 +347,7 @@ EOS
|
|
330
347
|
allow(@rubocop.git).to receive(:modified_files)
|
331
348
|
.and_return(['spec/fixtures/ruby_file.rb'])
|
332
349
|
allow(@rubocop.git).to receive(:added_files).and_return([])
|
350
|
+
allow(@rubocop.git).to receive(:renamed_files).and_return([])
|
333
351
|
allow(@rubocop).to receive(:`)
|
334
352
|
.with('bundle exec rubocop -f json --only-recognized-file-types spec/fixtures/ruby_file.rb')
|
335
353
|
.and_return(response_ruby_file)
|
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.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ash Furrow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger
|
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
192
|
- !ruby/object:Gem::Version
|
193
193
|
version: '0'
|
194
194
|
requirements: []
|
195
|
-
rubygems_version: 3.
|
195
|
+
rubygems_version: 3.2.1
|
196
196
|
signing_key:
|
197
197
|
specification_version: 4
|
198
198
|
summary: A Danger plugin for running Ruby files through Rubocop.
|