danger-rubocop 0.6.1 → 0.8.1
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 +47 -35
- data/README.md +11 -1
- data/danger-rubocop.gemspec +1 -1
- data/lib/danger_plugin.rb +50 -15
- data/lib/version.rb +1 -1
- data/spec/danger_plugin_spec.rb +120 -5
- 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: bb5d7eb8397ac2e653dbb40f1d36578709c9167d1c58edcf03755317bae9a1d9
|
4
|
+
data.tar.gz: 29663b37df5566b315562381f690738a96fde57537be19a3aaa2c6ac9d227519
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7786b81d1acd3476b3a64c672c9a1164bda1f427c29e1379a84bed948a6d46eb1dfe506d7b1316246d61c4a710508e1c15b5378fbaa51de111fd9aba78b6a0dc
|
7
|
+
data.tar.gz: e7e7aa14b45ad941d1be7a1e39f070a1f01e124c97e3eb2c099cd8934ca113018a834a5e51fa71b765a82807b3cbda1e6a25f4a7111cc50f89138be17df1048e
|
@@ -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
@@ -1,18 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
danger-rubocop (0.
|
4
|
+
danger-rubocop (0.8.1)
|
5
5
|
danger
|
6
6
|
rubocop
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
addressable (2.
|
12
|
-
public_suffix (>= 2.0.2, <
|
13
|
-
ast (2.
|
11
|
+
addressable (2.7.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
|
+
ast (2.4.1)
|
14
14
|
bacon (1.2.0)
|
15
|
-
claide (1.0.
|
15
|
+
claide (1.0.3)
|
16
16
|
claide-plugins (0.9.2)
|
17
17
|
cork
|
18
18
|
nap
|
@@ -21,26 +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.4)
|
25
25
|
claide (~> 1.0)
|
26
26
|
claide-plugins (>= 0.9.2)
|
27
27
|
colored2 (~> 3.1)
|
28
28
|
cork (~> 0.1)
|
29
|
-
faraday (
|
30
|
-
faraday-http-cache (~>
|
31
|
-
git (~> 1)
|
32
|
-
kramdown (~>
|
29
|
+
faraday (>= 0.9.0, < 2.0)
|
30
|
+
faraday-http-cache (~> 2.0)
|
31
|
+
git (~> 1.7)
|
32
|
+
kramdown (~> 2.0)
|
33
|
+
kramdown-parser-gfm (~> 1.0)
|
33
34
|
no_proxy_fix
|
34
35
|
octokit (~> 4.7)
|
35
36
|
terminal-table (~> 1)
|
36
37
|
diff-lcs (1.2.5)
|
37
|
-
faraday (0.
|
38
|
+
faraday (1.0.1)
|
38
39
|
multipart-post (>= 1.2, < 3)
|
39
|
-
faraday-http-cache (
|
40
|
-
faraday (
|
40
|
+
faraday-http-cache (2.2.0)
|
41
|
+
faraday (>= 0.8)
|
41
42
|
ffi (1.9.10)
|
42
43
|
formatador (0.2.5)
|
43
|
-
git (1.
|
44
|
+
git (1.7.0)
|
45
|
+
rchardet (~> 1.8)
|
44
46
|
guard (2.14.0)
|
45
47
|
formatador (>= 0.2.4)
|
46
48
|
listen (>= 2.7, < 4.0)
|
@@ -55,7 +57,10 @@ GEM
|
|
55
57
|
guard (~> 2.1)
|
56
58
|
guard-compat (~> 1.1)
|
57
59
|
rspec (>= 2.99.0, < 4.0)
|
58
|
-
kramdown (
|
60
|
+
kramdown (2.3.0)
|
61
|
+
rexml
|
62
|
+
kramdown-parser-gfm (1.1.0)
|
63
|
+
kramdown (~> 2.0)
|
59
64
|
listen (3.0.7)
|
60
65
|
rb-fsevent (>= 0.9.3)
|
61
66
|
rb-inotify (>= 0.9.7)
|
@@ -66,32 +71,35 @@ GEM
|
|
66
71
|
metaclass (~> 0.0.1)
|
67
72
|
mocha-on-bacon (0.2.2)
|
68
73
|
mocha (>= 0.13.0)
|
69
|
-
multipart-post (2.
|
74
|
+
multipart-post (2.1.1)
|
70
75
|
nap (1.1.0)
|
71
76
|
nenv (0.3.0)
|
72
77
|
no_proxy_fix (0.1.2)
|
73
78
|
notiffany (0.1.0)
|
74
79
|
nenv (~> 0.1)
|
75
80
|
shellany (~> 0.0)
|
76
|
-
octokit (4.
|
81
|
+
octokit (4.18.0)
|
82
|
+
faraday (>= 0.9)
|
77
83
|
sawyer (~> 0.8.0, >= 0.5.3)
|
78
84
|
open4 (1.3.4)
|
79
|
-
parallel (1.
|
80
|
-
parser (2.
|
81
|
-
ast (~> 2.
|
82
|
-
powerpack (0.1.1)
|
85
|
+
parallel (1.19.2)
|
86
|
+
parser (2.7.1.4)
|
87
|
+
ast (~> 2.4.1)
|
83
88
|
prettybacon (0.0.2)
|
84
89
|
bacon (~> 1.2)
|
85
90
|
pry (0.10.3)
|
86
91
|
coderay (~> 1.1.0)
|
87
92
|
method_source (~> 0.8.1)
|
88
93
|
slop (~> 3.4)
|
89
|
-
public_suffix (
|
94
|
+
public_suffix (4.0.5)
|
90
95
|
rainbow (3.0.0)
|
91
|
-
rake (
|
96
|
+
rake (13.0.1)
|
92
97
|
rb-fsevent (0.9.7)
|
93
98
|
rb-inotify (0.9.7)
|
94
99
|
ffi (>= 0.5.0)
|
100
|
+
rchardet (1.8.0)
|
101
|
+
regexp_parser (1.7.1)
|
102
|
+
rexml (3.2.4)
|
95
103
|
rspec (3.4.0)
|
96
104
|
rspec-core (~> 3.4.0)
|
97
105
|
rspec-expectations (~> 3.4.0)
|
@@ -105,24 +113,28 @@ GEM
|
|
105
113
|
diff-lcs (>= 1.2.0, < 2.0)
|
106
114
|
rspec-support (~> 3.4.0)
|
107
115
|
rspec-support (3.4.1)
|
108
|
-
rubocop (0.
|
116
|
+
rubocop (0.89.1)
|
109
117
|
parallel (~> 1.10)
|
110
|
-
parser (>= 2.
|
111
|
-
powerpack (~> 0.1)
|
118
|
+
parser (>= 2.7.1.1)
|
112
119
|
rainbow (>= 2.2.2, < 4.0)
|
120
|
+
regexp_parser (>= 1.7)
|
121
|
+
rexml
|
122
|
+
rubocop-ast (>= 0.3.0, < 1.0)
|
113
123
|
ruby-progressbar (~> 1.7)
|
114
|
-
unicode-display_width (
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
124
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
125
|
+
rubocop-ast (0.3.0)
|
126
|
+
parser (>= 2.7.1.4)
|
127
|
+
ruby-progressbar (1.10.1)
|
128
|
+
sawyer (0.8.2)
|
129
|
+
addressable (>= 2.3.5)
|
130
|
+
faraday (> 0.8, < 2.0)
|
119
131
|
shellany (0.0.1)
|
120
132
|
slop (3.6.0)
|
121
133
|
terminal-table (1.8.0)
|
122
134
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
123
135
|
thor (0.19.1)
|
124
|
-
unicode-display_width (1.
|
125
|
-
yard (0.9.
|
136
|
+
unicode-display_width (1.7.0)
|
137
|
+
yard (0.9.20)
|
126
138
|
|
127
139
|
PLATFORMS
|
128
140
|
ruby
|
@@ -138,7 +150,7 @@ DEPENDENCIES
|
|
138
150
|
mocha-on-bacon
|
139
151
|
prettybacon
|
140
152
|
pry
|
141
|
-
rake (~>
|
153
|
+
rake (~> 13.0)
|
142
154
|
rspec (~> 3.4)
|
143
155
|
yard
|
144
156
|
|
@@ -146,4 +158,4 @@ RUBY VERSION
|
|
146
158
|
ruby 2.3.1p112
|
147
159
|
|
148
160
|
BUNDLED WITH
|
149
|
-
1.
|
161
|
+
1.17.3
|
data/README.md
CHANGED
@@ -30,6 +30,12 @@ public_files = (git.modified_files + git.added_files).select { |path| path.inclu
|
|
30
30
|
rubocop.lint public_files
|
31
31
|
```
|
32
32
|
|
33
|
+
> Submit comments only for changed lines
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
github.dismiss_out_of_range_messages
|
37
|
+
rubocop.lint inline_comment: true
|
38
|
+
```
|
33
39
|
|
34
40
|
#### Methods
|
35
41
|
|
@@ -37,7 +43,7 @@ rubocop.lint public_files
|
|
37
43
|
|
38
44
|
Runs Ruby files through Rubocop. Generates a `markdown` list of warnings.
|
39
45
|
|
40
|
-
This method accepts configuration hash.
|
46
|
+
This method accepts a configuration hash.
|
41
47
|
The following keys are supported:
|
42
48
|
|
43
49
|
* `files`: array of file names or glob patterns to determine files to lint
|
@@ -47,6 +53,10 @@ The following keys are supported:
|
|
47
53
|
* `inline_comment`: pass `true` to comment inline of the diffs.
|
48
54
|
* `fail_on_inline_comment`: pass `true` to use `fail` instead of `warn` on inline comment.
|
49
55
|
* `report_danger`: pass true to report errors to Danger, and break CI.
|
56
|
+
* `config`: path to the `.rubocop.yml` file.
|
57
|
+
* `only_report_new_offenses`: pass `true` to only report offenses that are in current user's scope.
|
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."
|
50
60
|
|
51
61
|
|
52
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
@@ -30,40 +30,71 @@ module Danger
|
|
30
30
|
config = config.is_a?(Hash) ? config : { files: config }
|
31
31
|
files = config[:files]
|
32
32
|
force_exclusion = config[:force_exclusion] || false
|
33
|
-
|
33
|
+
config_path = config[:config]
|
34
34
|
report_danger = config[:report_danger] || false
|
35
|
+
only_report_new_offenses = config[:only_report_new_offenses] || false
|
35
36
|
inline_comment = config[:inline_comment] || false
|
36
37
|
fail_on_inline_comment = config[:fail_on_inline_comment] || false
|
38
|
+
include_cop_names = config[:include_cop_names] || false
|
37
39
|
|
38
40
|
files_to_lint = fetch_files_to_lint(files)
|
39
|
-
files_to_report = rubocop(files_to_lint, force_exclusion)
|
41
|
+
files_to_report = rubocop(files_to_lint, force_exclusion, only_report_new_offenses, config_path: config_path)
|
40
42
|
|
41
43
|
return if files_to_report.empty?
|
42
44
|
return report_failures files_to_report if report_danger
|
43
45
|
|
44
46
|
if inline_comment
|
45
|
-
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)
|
46
48
|
else
|
47
|
-
markdown offenses_message(files_to_report)
|
49
|
+
markdown offenses_message(files_to_report, include_cop_names: include_cop_names)
|
48
50
|
end
|
49
|
-
|
50
51
|
end
|
51
52
|
|
52
53
|
private
|
53
54
|
|
54
|
-
def rubocop(files_to_lint, force_exclusion)
|
55
|
-
base_command = 'rubocop -f json'
|
56
|
-
base_command
|
55
|
+
def rubocop(files_to_lint, force_exclusion, only_report_new_offenses, config_path: nil)
|
56
|
+
base_command = ['rubocop', '-f', 'json']
|
57
|
+
base_command.concat(['--force-exclusion']) if force_exclusion
|
58
|
+
base_command.concat(['--config', config_path.shellescape]) unless config_path.nil?
|
57
59
|
|
58
|
-
rubocop_output = `#{'bundle exec ' if File.exist?('Gemfile')}#{base_command} #{files_to_lint}`
|
60
|
+
rubocop_output = `#{'bundle exec ' if File.exist?('Gemfile')}#{base_command.join(' ')} #{files_to_lint}`
|
59
61
|
|
60
62
|
return [] if rubocop_output.empty?
|
61
63
|
|
62
|
-
JSON.parse(rubocop_output)['files']
|
63
|
-
|
64
|
+
files = JSON.parse(rubocop_output)['files']
|
65
|
+
|
66
|
+
filter_out_offenses(files) if only_report_new_offenses
|
67
|
+
|
68
|
+
files.select { |f| f['offenses'].any? }
|
69
|
+
end
|
70
|
+
|
71
|
+
def filter_out_offenses(files)
|
72
|
+
files.each do |file|
|
73
|
+
added_lines = added_lines(file['path']).to_set
|
74
|
+
file['offenses'].select! do |offense|
|
75
|
+
added_lines.include?(offense['location']['line'])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def added_lines(path)
|
81
|
+
git.diff_for_file(path)
|
82
|
+
.patch
|
83
|
+
.split("\n@@")
|
84
|
+
.tap(&:shift)
|
85
|
+
.flat_map do |chunk|
|
86
|
+
first_line, *diff = chunk.split("\n")
|
87
|
+
# Get start from diff.
|
88
|
+
lineno = first_line.match(/\+(\d+),(\d+)/).captures.first.to_i
|
89
|
+
diff.each_with_object([]) do |current_line, added_lines|
|
90
|
+
added_lines << lineno if current_line.start_with?('+')
|
91
|
+
lineno += 1 unless current_line.start_with?('-')
|
92
|
+
added_lines
|
93
|
+
end
|
94
|
+
end
|
64
95
|
end
|
65
96
|
|
66
|
-
def offenses_message(offending_files)
|
97
|
+
def offenses_message(offending_files, include_cop_names: false)
|
67
98
|
require 'terminal-table'
|
68
99
|
|
69
100
|
message = "### Rubocop violations\n\n"
|
@@ -72,7 +103,9 @@ module Danger
|
|
72
103
|
style: { border_i: '|' },
|
73
104
|
rows: offending_files.flat_map do |file|
|
74
105
|
file['offenses'].map do |offense|
|
75
|
-
|
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]
|
76
109
|
end
|
77
110
|
end
|
78
111
|
).to_s
|
@@ -87,11 +120,13 @@ module Danger
|
|
87
120
|
end
|
88
121
|
end
|
89
122
|
|
90
|
-
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)
|
91
124
|
offending_files.flat_map do |file|
|
92
125
|
file['offenses'].map do |offense|
|
126
|
+
offense_message = offense['message']
|
127
|
+
offense_message = offense['cop_name'] + ': ' + offense_message if include_cop_names
|
93
128
|
arguments = [
|
94
|
-
|
129
|
+
offense_message,
|
95
130
|
{
|
96
131
|
file: file['path'],
|
97
132
|
line: offense['location']['line']
|
data/lib/version.rb
CHANGED
data/spec/danger_plugin_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('spec_helper', __dir__)
|
2
2
|
|
3
3
|
module Danger
|
4
4
|
describe DangerRubocop do
|
@@ -12,6 +12,103 @@ module Danger
|
|
12
12
|
@rubocop = testing_dangerfile.rubocop
|
13
13
|
end
|
14
14
|
|
15
|
+
describe "#filter_out_offenses" do
|
16
|
+
let(:files_within_pr) do
|
17
|
+
[
|
18
|
+
{
|
19
|
+
'path' => 'lib/version.rb',
|
20
|
+
'offenses' => [
|
21
|
+
{
|
22
|
+
'message' => 'No.',
|
23
|
+
'location' => { 'line' => 41 }
|
24
|
+
}
|
25
|
+
]
|
26
|
+
}
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
let(:files_outside_pr) do
|
31
|
+
[
|
32
|
+
{
|
33
|
+
'path' => 'lib/version.rb',
|
34
|
+
'offenses' => [
|
35
|
+
{
|
36
|
+
'message' => 'No.',
|
37
|
+
'location' => { 'line' => 20 }
|
38
|
+
}
|
39
|
+
]
|
40
|
+
}
|
41
|
+
]
|
42
|
+
end
|
43
|
+
subject { @rubocop }
|
44
|
+
|
45
|
+
before do
|
46
|
+
allow(@rubocop.git).to receive(:diff_for_file).with('lib/version.rb') do
|
47
|
+
instance_double('Git::Diff::DiffFile', patch: <<~DIFF)
|
48
|
+
diff --git a/lib/version.rb b/lib/version.rb
|
49
|
+
index 66d3a986..5e8074a8 100644
|
50
|
+
--- a/lib/version.rb
|
51
|
+
+++ b/lib/version.rb
|
52
|
+
@@ -32,4 +40,3 @@
|
53
|
+
line 1
|
54
|
+
-removed
|
55
|
+
-line 2 old version
|
56
|
+
+line 2 with offense
|
57
|
+
line 3
|
58
|
+
DIFF
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'filters out offenses not in the pr' do
|
63
|
+
p described_class
|
64
|
+
expect(subject.send(:filter_out_offenses, files_outside_pr)).to eq(
|
65
|
+
[
|
66
|
+
{
|
67
|
+
'path' => 'lib/version.rb',
|
68
|
+
'offenses' => []
|
69
|
+
}
|
70
|
+
]
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'keeps offenses in the pr' do
|
75
|
+
expect(subject.send(:filter_out_offenses, files_within_pr.dup)).to eq(
|
76
|
+
[
|
77
|
+
{
|
78
|
+
'path' => 'lib/version.rb',
|
79
|
+
'offenses' => [
|
80
|
+
{
|
81
|
+
'message' => 'No.',
|
82
|
+
'location' => { 'line' => 41 }
|
83
|
+
}
|
84
|
+
]
|
85
|
+
}
|
86
|
+
]
|
87
|
+
)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe :added_lines do
|
92
|
+
before do
|
93
|
+
allow(@rubocop.git).to receive(:diff_for_file).with('SAMPLE') do
|
94
|
+
instance_double('Git::Diff::DiffFile', patch: <<~DIFF)
|
95
|
+
diff --git a/SAMPLE b/SAMPLE
|
96
|
+
new file mode 100644
|
97
|
+
index 0000000..7bba8c8
|
98
|
+
--- /dev/null
|
99
|
+
+++ b/SAMPLE
|
100
|
+
@@ -0,0 +1,2 @@
|
101
|
+
+line 1
|
102
|
+
+line 2
|
103
|
+
DIFF
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'handles git diff' do
|
108
|
+
expect(@rubocop.send(:added_lines, 'SAMPLE')).to eq([1, 2])
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
15
112
|
describe :lint_files do
|
16
113
|
let(:response_ruby_file) do
|
17
114
|
{
|
@@ -20,6 +117,7 @@ module Danger
|
|
20
117
|
'path' => 'spec/fixtures/ruby_file.rb',
|
21
118
|
'offenses' => [
|
22
119
|
{
|
120
|
+
'cop_name' => 'Syntax/WhetherYouShouldDoThat',
|
23
121
|
'message' => "Don't do that!",
|
24
122
|
'location' => { 'line' => 13 }
|
25
123
|
}
|
@@ -36,6 +134,7 @@ module Danger
|
|
36
134
|
'path' => 'spec/fixtures/another_ruby_file.rb',
|
37
135
|
'offenses' => [
|
38
136
|
{
|
137
|
+
'cop_name' => 'Syntax/WhetherYouShouldDoThat',
|
39
138
|
'message' => "Don't do that!",
|
40
139
|
'location' => { 'line' => 23 }
|
41
140
|
}
|
@@ -47,11 +146,11 @@ module Danger
|
|
47
146
|
|
48
147
|
it 'handles a rubocop report for specified files' do
|
49
148
|
allow(@rubocop).to receive(:`)
|
50
|
-
.with('bundle exec rubocop -f json spec/fixtures/ruby_file.rb')
|
149
|
+
.with('bundle exec rubocop -f json --config path/to/rubocop.yml spec/fixtures/ruby_file.rb')
|
51
150
|
.and_return(response_ruby_file)
|
52
151
|
|
53
152
|
# Do it
|
54
|
-
@rubocop.lint(files: 'spec/fixtures/ruby*.rb')
|
153
|
+
@rubocop.lint(files: 'spec/fixtures/ruby*.rb', config: 'path/to/rubocop.yml')
|
55
154
|
|
56
155
|
output = @rubocop.status_report[:markdowns].first.message
|
57
156
|
|
@@ -61,6 +160,22 @@ module Danger
|
|
61
160
|
expect(output).to include("spec/fixtures/ruby_file.rb | 13 | Don't do that!")
|
62
161
|
end
|
63
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
|
+
|
64
179
|
it 'handles a rubocop report for specified files (legacy)' do
|
65
180
|
allow(@rubocop).to receive(:`)
|
66
181
|
.with('bundle exec rubocop -f json spec/fixtures/ruby_file.rb')
|
@@ -143,7 +258,7 @@ EOS
|
|
143
258
|
@rubocop.lint(inline_comment: true)
|
144
259
|
|
145
260
|
expect(@rubocop.violation_report[:warnings].first.to_s)
|
146
|
-
.to eq("Violation Don't do that! { sticky: false, file: spec/fixtures/ruby_file.rb, line: 13 }")
|
261
|
+
.to eq("Violation Don't do that! { sticky: false, file: spec/fixtures/ruby_file.rb, line: 13, type: warning }")
|
147
262
|
end
|
148
263
|
end
|
149
264
|
|
@@ -159,7 +274,7 @@ EOS
|
|
159
274
|
@rubocop.lint(fail_on_inline_comment: true, inline_comment: true)
|
160
275
|
|
161
276
|
expect(@rubocop.violation_report[:errors].first.to_s)
|
162
|
-
.to eq("Violation Don't do that! { sticky: false, file: spec/fixtures/ruby_file.rb, line: 13 }")
|
277
|
+
.to eq("Violation Don't do that! { sticky: false, file: spec/fixtures/ruby_file.rb, line: 13, type: error }")
|
163
278
|
end
|
164
279
|
end
|
165
280
|
end
|
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.8.1
|
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-08-12 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.8
|
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