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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c91b32a9db886ba98a9bb29e11e6fdec8b0aae1b344ef3bb41e281094e7cf2d4
4
- data.tar.gz: 6ce1784637f6ffd0de37de4aac28ff81c27154cbcf9b3e20ac46dab5c0ca0665
3
+ metadata.gz: e91901b79a6155f5d70feebbbd301fad023ea8a8fd4a37e8f04fe413d3859326
4
+ data.tar.gz: 469efcdadad9b126197d88d0d0aeaa51497a3542f1e6bb0d66977d8d195facde
5
5
  SHA512:
6
- metadata.gz: 560ace4a9f693783d80041b1ad88d4fe2dc3b4bcf946fced8195e30ce8f89ebc3cec698e9bdf09a9c3e377b7a7e7055f25710433ca4d1219583eb78e18ea513b
7
- data.tar.gz: b5f5ae9d8d821e75c95dbccaaf22858b7c8f1b790ec020711f55c0374dc8020d28393376c07337d500aaf87874234f9d6db6532447a7ac1bb7327d910da08def
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.1)
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.1)
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.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.1)
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 (~> 1)
37
- diff-lcs (1.2.5)
38
- faraday (1.1.0)
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
- ffi (1.9.10)
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.7.0)
55
+ git (1.8.1)
46
56
  rchardet (~> 1.8)
47
- guard (2.14.0)
57
+ guard (2.16.2)
48
58
  formatador (>= 0.2.4)
49
59
  listen (>= 2.7, < 4.0)
50
- lumberjack (~> 1.0)
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.2)
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.0)
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.0.10)
69
- metaclass (0.0.4)
70
- method_source (0.8.2)
71
- mocha (1.1.0)
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.0)
87
+ notiffany (0.1.3)
80
88
  nenv (~> 0.1)
81
89
  shellany (~> 0.0)
82
- octokit (4.19.0)
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 (2.7.2.0)
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.10.3)
92
- coderay (~> 1.1.0)
93
- method_source (~> 0.8.1)
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.1)
98
- rb-fsevent (0.9.7)
99
- rb-inotify (0.9.7)
100
- ffi (>= 0.5.0)
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.0.0)
103
- rexml (3.2.4)
104
- rspec (3.4.0)
105
- rspec-core (~> 3.4.0)
106
- rspec-expectations (~> 3.4.0)
107
- rspec-mocks (~> 3.4.0)
108
- rspec-core (3.4.4)
109
- rspec-support (~> 3.4.0)
110
- rspec-expectations (3.4.0)
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.4.0)
113
- rspec-mocks (3.4.1)
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.4.0)
116
- rspec-support (3.4.1)
117
- rubocop (1.5.0)
122
+ rspec-support (~> 3.10.0)
123
+ rspec-support (3.10.2)
124
+ rubocop (1.16.0)
118
125
  parallel (~> 1.10)
119
- parser (>= 2.7.1.5)
126
+ parser (>= 3.0.0.0)
120
127
  rainbow (>= 2.2.2, < 4.0)
121
- regexp_parser (>= 2.0)
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, < 2.0)
126
- rubocop-ast (1.3.0)
127
- parser (>= 2.7.1.5)
128
- ruby-progressbar (1.10.1)
129
- ruby2_keywords (0.0.2)
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
- slop (3.6.0)
135
- terminal-table (1.8.0)
136
- unicode-display_width (~> 1.1, >= 1.1.1)
137
- thor (0.19.1)
138
- unicode-display_width (1.7.0)
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 = ['rubocop', '-f', 'json', '--only-recognized-file-types']
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
- arguments = [
132
- offense_message,
133
- {
134
- file: file['path'],
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(*arguments)
137
+ fail(offense_message, **kargs)
140
138
  else
141
- warn(*arguments)
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 = (files ? Dir.glob(files) : (git.modified_files + git.added_files))
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
@@ -1,3 +1,3 @@
1
1
  module DangerRubocop
2
- VERSION = '0.9.3'.freeze
2
+ VERSION = '0.10.0'.freeze
3
3
  end
@@ -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.9.3
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: 2020-12-03 00:00:00.000000000 Z
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.0.8
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.