danger-rubocop 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +30 -0
- data/Gemfile.lock +2 -2
- data/README.md +2 -1
- data/danger-rubocop.gemspec +1 -1
- data/lib/danger_plugin.rb +11 -6
- data/lib/version.rb +1 -1
- data/spec/danger_plugin_spec.rb +18 -0
- metadata +6 -7
- data/circle.yml +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc7db75b5f4eff3caf643f1c9cc45c5d9014e8361351b8868fb79a2082618507
|
4
|
+
data.tar.gz: 0bbc72b3cd32ad873d8137717ea82a0ed5fd630dbda61d46433c5cd4b5bf50a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 272cbd2cdefced6ef5a1f0de44251ec358bbd37522c73035104294d320a0c0defdd95598bec5ce3973435c006b4583121a01f562e693dc699ed1c427ea5fbd18
|
7
|
+
data.tar.gz: 78750720159477b7db8d97a6d963f0443b16839785387682597aa4058e75a692132a09674516f02a561c6f228c4d21760498a4eb193dd53137a2eafc820db530
|
@@ -0,0 +1,30 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
docker:
|
5
|
+
- image: circleci/ruby:2.6
|
6
|
+
|
7
|
+
working_directory: ~/repo
|
8
|
+
|
9
|
+
steps:
|
10
|
+
- checkout
|
11
|
+
|
12
|
+
- restore_cache:
|
13
|
+
keys:
|
14
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
15
|
+
# fallback to using the latest cache if no exact match is found
|
16
|
+
- v1-dependencies-
|
17
|
+
|
18
|
+
- run:
|
19
|
+
name: install dependencies
|
20
|
+
command: |
|
21
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
22
|
+
|
23
|
+
- save_cache:
|
24
|
+
paths:
|
25
|
+
- ./vendor/bundle
|
26
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
27
|
+
|
28
|
+
- run:
|
29
|
+
name: run tests
|
30
|
+
command: bundle exec rake spec
|
data/Gemfile.lock
CHANGED
@@ -91,7 +91,7 @@ GEM
|
|
91
91
|
slop (~> 3.4)
|
92
92
|
public_suffix (4.0.1)
|
93
93
|
rainbow (3.0.0)
|
94
|
-
rake (
|
94
|
+
rake (13.0.1)
|
95
95
|
rb-fsevent (0.9.7)
|
96
96
|
rb-inotify (0.9.7)
|
97
97
|
ffi (>= 0.5.0)
|
@@ -141,7 +141,7 @@ DEPENDENCIES
|
|
141
141
|
mocha-on-bacon
|
142
142
|
prettybacon
|
143
143
|
pry
|
144
|
-
rake (~>
|
144
|
+
rake (~> 13.0)
|
145
145
|
rspec (~> 3.4)
|
146
146
|
yard
|
147
147
|
|
data/README.md
CHANGED
@@ -43,7 +43,7 @@ rubocop.lint inline_comment: true
|
|
43
43
|
|
44
44
|
Runs Ruby files through Rubocop. Generates a `markdown` list of warnings.
|
45
45
|
|
46
|
-
This method accepts configuration hash.
|
46
|
+
This method accepts a configuration hash.
|
47
47
|
The following keys are supported:
|
48
48
|
|
49
49
|
* `files`: array of file names or glob patterns to determine files to lint
|
@@ -56,6 +56,7 @@ The following keys are supported:
|
|
56
56
|
* `config`: path to the `.rubocop.yml` file.
|
57
57
|
* `only_report_new_offenses`: pass `true` to only report offenses that are in current user's scope.
|
58
58
|
Note that this won't mark offenses for _Metrics/XXXLength_ if you add lines to an already existing scope.
|
59
|
+
* `include_cop_names`: Prepends cop names to the output messages. Example: "Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body end."
|
59
60
|
|
60
61
|
|
61
62
|
Passing `files` as only argument is also supported for backward compatibility.
|
data/danger-rubocop.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
# General ruby development
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
|
-
spec.add_development_dependency 'rake', '~>
|
25
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
26
26
|
|
27
27
|
# For validating the plugin lints
|
28
28
|
spec.add_development_dependency 'yard'
|
data/lib/danger_plugin.rb
CHANGED
@@ -35,6 +35,7 @@ module Danger
|
|
35
35
|
only_report_new_offenses = config[:only_report_new_offenses] || false
|
36
36
|
inline_comment = config[:inline_comment] || false
|
37
37
|
fail_on_inline_comment = config[:fail_on_inline_comment] || false
|
38
|
+
include_cop_names = config[:include_cop_names] || false
|
38
39
|
|
39
40
|
files_to_lint = fetch_files_to_lint(files)
|
40
41
|
files_to_report = rubocop(files_to_lint, force_exclusion, only_report_new_offenses, config_path: config_path)
|
@@ -43,9 +44,9 @@ module Danger
|
|
43
44
|
return report_failures files_to_report if report_danger
|
44
45
|
|
45
46
|
if inline_comment
|
46
|
-
add_violation_for_each_line(files_to_report, fail_on_inline_comment)
|
47
|
+
add_violation_for_each_line(files_to_report, fail_on_inline_comment, include_cop_names: include_cop_names)
|
47
48
|
else
|
48
|
-
markdown offenses_message(files_to_report)
|
49
|
+
markdown offenses_message(files_to_report, include_cop_names: include_cop_names)
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -93,7 +94,7 @@ module Danger
|
|
93
94
|
end
|
94
95
|
end
|
95
96
|
|
96
|
-
def offenses_message(offending_files)
|
97
|
+
def offenses_message(offending_files, include_cop_names: false)
|
97
98
|
require 'terminal-table'
|
98
99
|
|
99
100
|
message = "### Rubocop violations\n\n"
|
@@ -102,7 +103,9 @@ module Danger
|
|
102
103
|
style: { border_i: '|' },
|
103
104
|
rows: offending_files.flat_map do |file|
|
104
105
|
file['offenses'].map do |offense|
|
105
|
-
|
106
|
+
offense_message = offense['message']
|
107
|
+
offense_message = offense['cop_name'] + ': ' + offense_message if include_cop_names
|
108
|
+
[file['path'], offense['location']['line'], offense_message]
|
106
109
|
end
|
107
110
|
end
|
108
111
|
).to_s
|
@@ -117,11 +120,13 @@ module Danger
|
|
117
120
|
end
|
118
121
|
end
|
119
122
|
|
120
|
-
def add_violation_for_each_line(offending_files, fail_on_inline_comment)
|
123
|
+
def add_violation_for_each_line(offending_files, fail_on_inline_comment, include_cop_names: false)
|
121
124
|
offending_files.flat_map do |file|
|
122
125
|
file['offenses'].map do |offense|
|
126
|
+
offense_message = offense['message']
|
127
|
+
offense_message = offense['cop_name'] + ': ' + offense_message if include_cop_names
|
123
128
|
arguments = [
|
124
|
-
|
129
|
+
offense_message,
|
125
130
|
{
|
126
131
|
file: file['path'],
|
127
132
|
line: offense['location']['line']
|
data/lib/version.rb
CHANGED
data/spec/danger_plugin_spec.rb
CHANGED
@@ -117,6 +117,7 @@ module Danger
|
|
117
117
|
'path' => 'spec/fixtures/ruby_file.rb',
|
118
118
|
'offenses' => [
|
119
119
|
{
|
120
|
+
'cop_name' => 'Syntax/WhetherYouShouldDoThat',
|
120
121
|
'message' => "Don't do that!",
|
121
122
|
'location' => { 'line' => 13 }
|
122
123
|
}
|
@@ -133,6 +134,7 @@ module Danger
|
|
133
134
|
'path' => 'spec/fixtures/another_ruby_file.rb',
|
134
135
|
'offenses' => [
|
135
136
|
{
|
137
|
+
'cop_name' => 'Syntax/WhetherYouShouldDoThat',
|
136
138
|
'message' => "Don't do that!",
|
137
139
|
'location' => { 'line' => 23 }
|
138
140
|
}
|
@@ -158,6 +160,22 @@ module Danger
|
|
158
160
|
expect(output).to include("spec/fixtures/ruby_file.rb | 13 | Don't do that!")
|
159
161
|
end
|
160
162
|
|
163
|
+
it 'includes cop names when include_cop_names is set' do
|
164
|
+
allow(@rubocop).to receive(:`)
|
165
|
+
.with('bundle exec rubocop -f json --config path/to/rubocop.yml spec/fixtures/ruby_file.rb')
|
166
|
+
.and_return(response_ruby_file)
|
167
|
+
|
168
|
+
# Do it
|
169
|
+
@rubocop.lint(files: 'spec/fixtures/ruby*.rb', config: 'path/to/rubocop.yml', include_cop_names: true)
|
170
|
+
|
171
|
+
output = @rubocop.status_report[:markdowns].first.message
|
172
|
+
|
173
|
+
# A title
|
174
|
+
expect(output).to include('Rubocop violations')
|
175
|
+
# A warning
|
176
|
+
expect(output).to include("spec/fixtures/ruby_file.rb | 13 | Syntax/WhetherYouShouldDoThat: Don't do that!")
|
177
|
+
end
|
178
|
+
|
161
179
|
it 'handles a rubocop report for specified files (legacy)' do
|
162
180
|
allow(@rubocop).to receive(:`)
|
163
181
|
.with('bundle exec rubocop -f json spec/fixtures/ruby_file.rb')
|
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.7.
|
4
|
+
version: 0.7.2
|
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: 2020-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '13.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '13.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,6 +156,7 @@ executables: []
|
|
156
156
|
extensions: []
|
157
157
|
extra_rdoc_files: []
|
158
158
|
files:
|
159
|
+
- ".circleci/config.yml"
|
159
160
|
- ".gitignore"
|
160
161
|
- Gemfile
|
161
162
|
- Gemfile.lock
|
@@ -163,7 +164,6 @@ files:
|
|
163
164
|
- LICENSE
|
164
165
|
- README.md
|
165
166
|
- Rakefile
|
166
|
-
- circle.yml
|
167
167
|
- danger-rubocop.gemspec
|
168
168
|
- lib/danger_plugin.rb
|
169
169
|
- lib/version.rb
|
@@ -192,8 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
192
|
- !ruby/object:Gem::Version
|
193
193
|
version: '0'
|
194
194
|
requirements: []
|
195
|
-
|
196
|
-
rubygems_version: 2.7.6
|
195
|
+
rubygems_version: 3.0.6
|
197
196
|
signing_key:
|
198
197
|
specification_version: 4
|
199
198
|
summary: A Danger plugin for running Ruby files through Rubocop.
|
data/circle.yml
DELETED