danger-rubocop 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -2
- data/lib/danger_plugin.rb +14 -1
- data/lib/version.rb +1 -1
- data/spec/danger_plugin_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 123e71c280e842bce2f03b4b6057a4e838a5337b
|
4
|
+
data.tar.gz: 896db4ec175e20179a7b4b23d6be8b2d01426953
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ee6a09ae722401c210e4cbf2c3d5ba825bfbcd16bcf533ab8c596d752d983ae9ffe2067cb04605fcaf361b7d3576563b60880cb8d09844b4fb87fe34999fa7f
|
7
|
+
data.tar.gz: 8248e12f7f623e3382807fd69210f14833f0e9878196fca099101c21dc93fb63d4f074f47c579090626d70add350a24d10d08149f740303786b0ee4c3fc33268
|
data/README.md
CHANGED
@@ -33,12 +33,21 @@ rubocop.lint public_files
|
|
33
33
|
|
34
34
|
#### Methods
|
35
35
|
|
36
|
+
`lint(config: Hash)`
|
36
37
|
|
37
|
-
|
38
|
+
Runs Ruby files through Rubocop. Generates a `markdown` list of warnings.
|
38
39
|
|
39
|
-
|
40
|
+
This method accepts configuration hash.
|
41
|
+
The following keys are supported:
|
40
42
|
|
43
|
+
* `files`: array of file names or glob patterns to determine files to lint
|
44
|
+
* `force_exclusion`: pass `true` to pass `--force-exclusion` argument to Rubocop.
|
45
|
+
* `inline_comment`: pass `true` to comment inline of the diffs.
|
46
|
+
|
47
|
+
(this option will instruct rubocop to ignore the files that your rubocop config ignores,
|
48
|
+
despite the plugin providing the list of files explicitely)
|
41
49
|
|
50
|
+
Passing `files` as only argument is also supported for backward compatibility.
|
42
51
|
|
43
52
|
## License
|
44
53
|
|
data/lib/danger_plugin.rb
CHANGED
@@ -30,13 +30,18 @@ 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
|
+
inline_comment = config[:inline_comment] || false
|
33
34
|
|
34
35
|
files_to_lint = fetch_files_to_lint(files)
|
35
36
|
files_to_report = rubocop(files_to_lint, force_exclusion)
|
36
37
|
|
37
38
|
return if files_to_report.empty?
|
38
39
|
|
39
|
-
|
40
|
+
if inline_comment
|
41
|
+
warn_each_line(files_to_report)
|
42
|
+
else
|
43
|
+
markdown offenses_message(files_to_report)
|
44
|
+
end
|
40
45
|
end
|
41
46
|
|
42
47
|
private
|
@@ -67,6 +72,14 @@ module Danger
|
|
67
72
|
message + table.split("\n")[1..-2].join("\n")
|
68
73
|
end
|
69
74
|
|
75
|
+
def warn_each_line(offending_files)
|
76
|
+
offending_files.flat_map do |file|
|
77
|
+
file['offenses'].map do |offense|
|
78
|
+
warn(offense['message'], file: file['path'], line: offense['location']['line'])
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
70
83
|
def fetch_files_to_lint(files = nil)
|
71
84
|
to_lint = (files ? Dir.glob(files) : (git.modified_files + git.added_files))
|
72
85
|
Shellwords.join(to_lint)
|
data/lib/version.rb
CHANGED
data/spec/danger_plugin_spec.rb
CHANGED
@@ -129,6 +129,20 @@ EOS
|
|
129
129
|
expect(@rubocop.status_report[:markdowns].first.message).to eq(formatted_table.chomp)
|
130
130
|
end
|
131
131
|
|
132
|
+
it 'is reported as line by line' do
|
133
|
+
allow(@rubocop.git).to receive(:modified_files)
|
134
|
+
.and_return(['spec/fixtures/ruby_file.rb'])
|
135
|
+
allow(@rubocop.git).to receive(:added_files).and_return([])
|
136
|
+
allow(@rubocop).to receive(:`)
|
137
|
+
.with('bundle exec rubocop -f json spec/fixtures/ruby_file.rb')
|
138
|
+
.and_return(response_ruby_file)
|
139
|
+
|
140
|
+
@rubocop.lint(inline_comment: true)
|
141
|
+
|
142
|
+
expect(@rubocop.violation_report[:warnings].first.to_s)
|
143
|
+
.to eq("Violation Don't do that! { sticky: false, file: spec/fixtures/ruby_file.rb, line: 13 }")
|
144
|
+
end
|
145
|
+
|
132
146
|
describe 'a filename with special characters' do
|
133
147
|
it 'is shell escaped' do
|
134
148
|
modified_files = [
|
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.5.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: 2017-
|
11
|
+
date: 2017-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger
|