danger-rubocop 0.8.0 → 0.9.3

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: 2f4f324de45d03bd83bdfe10a4047a57a478d897894b78405aff02dcadfe62b1
4
- data.tar.gz: 40dea7d522d011835462370782a4441e231c1f9ed49374e8a606fedf39ce2e54
3
+ metadata.gz: c91b32a9db886ba98a9bb29e11e6fdec8b0aae1b344ef3bb41e281094e7cf2d4
4
+ data.tar.gz: 6ce1784637f6ffd0de37de4aac28ff81c27154cbcf9b3e20ac46dab5c0ca0665
5
5
  SHA512:
6
- metadata.gz: 894b86cde281f23c4f49721b5a059d7257bc6c622e60a2999d0bfef5eeeb1c8d90cd20fd713c37e679f4ef2882d6e5b314b70bd8350102c90b0cdd9d0340fce3
7
- data.tar.gz: 4a03ca834ad41fc8ecabd91268ceea09af5b2cdf6c622a5f0cbe88b2c62d92562a74e107c0964986111386ad54112d733a2b9ec0837ba29c3dccb6511bcb63d2
6
+ metadata.gz: 560ace4a9f693783d80041b1ad88d4fe2dc3b4bcf946fced8195e30ce8f89ebc3cec698e9bdf09a9c3e377b7a7e7055f25710433ca4d1219583eb78e18ea513b
7
+ data.tar.gz: b5f5ae9d8d821e75c95dbccaaf22858b7c8f1b790ec020711f55c0374dc8020d28393376c07337d500aaf87874234f9d6db6532447a7ac1bb7327d910da08def
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-rubocop (0.8.0)
4
+ danger-rubocop (0.9.1)
5
5
  danger
6
- rubocop
6
+ rubocop (~> 1.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -21,7 +21,7 @@ GEM
21
21
  colored2 (3.1.2)
22
22
  cork (0.3.0)
23
23
  colored2 (~> 3.1)
24
- danger (8.0.1)
24
+ danger (8.2.1)
25
25
  claide (~> 1.0)
26
26
  claide-plugins (>= 0.9.2)
27
27
  colored2 (~> 3.1)
@@ -29,14 +29,15 @@ GEM
29
29
  faraday (>= 0.9.0, < 2.0)
30
30
  faraday-http-cache (~> 2.0)
31
31
  git (~> 1.7)
32
- kramdown (~> 2.0)
32
+ kramdown (~> 2.3)
33
33
  kramdown-parser-gfm (~> 1.0)
34
34
  no_proxy_fix
35
35
  octokit (~> 4.7)
36
36
  terminal-table (~> 1)
37
37
  diff-lcs (1.2.5)
38
- faraday (1.0.1)
38
+ faraday (1.1.0)
39
39
  multipart-post (>= 1.2, < 3)
40
+ ruby2_keywords
40
41
  faraday-http-cache (2.2.0)
41
42
  faraday (>= 0.8)
42
43
  ffi (1.9.10)
@@ -57,7 +58,7 @@ GEM
57
58
  guard (~> 2.1)
58
59
  guard-compat (~> 1.1)
59
60
  rspec (>= 2.99.0, < 4.0)
60
- kramdown (2.2.1)
61
+ kramdown (2.3.0)
61
62
  rexml
62
63
  kramdown-parser-gfm (1.1.0)
63
64
  kramdown (~> 2.0)
@@ -78,27 +79,27 @@ GEM
78
79
  notiffany (0.1.0)
79
80
  nenv (~> 0.1)
80
81
  shellany (~> 0.0)
81
- octokit (4.18.0)
82
+ octokit (4.19.0)
82
83
  faraday (>= 0.9)
83
84
  sawyer (~> 0.8.0, >= 0.5.3)
84
85
  open4 (1.3.4)
85
- parallel (1.19.1)
86
- parser (2.7.1.3)
87
- ast (~> 2.4.0)
86
+ parallel (1.20.1)
87
+ parser (2.7.2.0)
88
+ ast (~> 2.4.1)
88
89
  prettybacon (0.0.2)
89
90
  bacon (~> 1.2)
90
91
  pry (0.10.3)
91
92
  coderay (~> 1.1.0)
92
93
  method_source (~> 0.8.1)
93
94
  slop (~> 3.4)
94
- public_suffix (4.0.5)
95
+ public_suffix (4.0.6)
95
96
  rainbow (3.0.0)
96
97
  rake (13.0.1)
97
98
  rb-fsevent (0.9.7)
98
99
  rb-inotify (0.9.7)
99
100
  ffi (>= 0.5.0)
100
101
  rchardet (1.8.0)
101
- regexp_parser (1.7.1)
102
+ regexp_parser (2.0.0)
102
103
  rexml (3.2.4)
103
104
  rspec (3.4.0)
104
105
  rspec-core (~> 3.4.0)
@@ -113,18 +114,19 @@ GEM
113
114
  diff-lcs (>= 1.2.0, < 2.0)
114
115
  rspec-support (~> 3.4.0)
115
116
  rspec-support (3.4.1)
116
- rubocop (0.85.1)
117
+ rubocop (1.5.0)
117
118
  parallel (~> 1.10)
118
- parser (>= 2.7.0.1)
119
+ parser (>= 2.7.1.5)
119
120
  rainbow (>= 2.2.2, < 4.0)
120
- regexp_parser (>= 1.7)
121
+ regexp_parser (>= 2.0)
121
122
  rexml
122
- rubocop-ast (>= 0.0.3)
123
+ rubocop-ast (>= 1.2.0)
123
124
  ruby-progressbar (~> 1.7)
124
125
  unicode-display_width (>= 1.4.0, < 2.0)
125
- rubocop-ast (0.0.3)
126
- parser (>= 2.7.0.1)
126
+ rubocop-ast (1.3.0)
127
+ parser (>= 2.7.1.5)
127
128
  ruby-progressbar (1.10.1)
129
+ ruby2_keywords (0.0.2)
128
130
  sawyer (0.8.2)
129
131
  addressable (>= 2.3.5)
130
132
  faraday (> 0.8, < 2.0)
data/README.md CHANGED
@@ -46,10 +46,10 @@ Runs Ruby files through Rubocop. Generates a `markdown` list of warnings.
46
46
  This method accepts a configuration hash.
47
47
  The following keys are supported:
48
48
 
49
- * `files`: array of file names or glob patterns to determine files to lint
49
+ * `files`: array of file names or glob patterns to determine files to lint. If omitted, this will lint only the files changed in the pull request. To lint all files every time, pass an empty string; this is the equivalent of typing `rubocop` without specifying any files, and will follow the rules in your `.rubocop.yml`.
50
50
  * `force_exclusion`: pass `true` to pass `--force-exclusion` argument to Rubocop.
51
51
  (this option will instruct rubocop to ignore the files that your rubocop config ignores,
52
- despite the plugin providing the list of files explicitely)
52
+ despite the plugin providing the list of files explicitly)
53
53
  * `inline_comment`: pass `true` to comment inline of the diffs.
54
54
  * `fail_on_inline_comment`: pass `true` to use `fail` instead of `warn` on inline comment.
55
55
  * `report_danger`: pass true to report errors to Danger, and break CI.
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ['lib']
19
19
 
20
20
  spec.add_dependency 'danger'
21
- spec.add_dependency 'rubocop'
21
+ spec.add_dependency 'rubocop', '~> 1.0'
22
22
 
23
23
  # General ruby development
24
24
  spec.add_development_dependency 'bundler', '~> 1.3'
@@ -78,14 +78,17 @@ module Danger
78
78
  end
79
79
 
80
80
  def added_lines(path)
81
- git.diff_for_file(path)
81
+ diff_for_file = git.diff_for_file(path)
82
+ return [] if diff_for_file.nil?
83
+
84
+ diff_for_file
82
85
  .patch
83
86
  .split("\n@@")
84
87
  .tap(&:shift)
85
88
  .flat_map do |chunk|
86
89
  first_line, *diff = chunk.split("\n")
87
90
  # Get start from diff.
88
- lineno = first_line.match(/\+(\d+),(\d+)/).captures.first.to_i
91
+ lineno = first_line.match(/\+(\d+),?(\d?)/).captures.first.to_i
89
92
  diff.each_with_object([]) do |current_line, added_lines|
90
93
  added_lines << lineno if current_line.start_with?('+')
91
94
  lineno += 1 unless current_line.start_with?('-')
@@ -1,3 +1,3 @@
1
1
  module DangerRubocop
2
- VERSION = '0.8.0'.freeze
2
+ VERSION = '0.9.3'.freeze
3
3
  end
@@ -107,6 +107,36 @@ module Danger
107
107
  it 'handles git diff' do
108
108
  expect(@rubocop.send(:added_lines, 'SAMPLE')).to eq([1, 2])
109
109
  end
110
+
111
+ context "single line added to a new file" do
112
+ before do
113
+ allow(@rubocop.git).to receive(:diff_for_file).with('SAMPLE') do
114
+ instance_double('Git::Diff::DiffFile', patch: <<~DIFF)
115
+ diff --git a/SAMPLE b/SAMPLE
116
+ new file mode 100644
117
+ index 0000000..7bba8c8
118
+ --- /dev/null
119
+ +++ b/SAMPLE
120
+ @@ -0,0 +1 @@
121
+ +line 1
122
+ DIFF
123
+ end
124
+ end
125
+
126
+ it 'handles git diff' do
127
+ expect(@rubocop.send(:added_lines, 'SAMPLE')).to eq([1])
128
+ end
129
+ end
130
+
131
+ context 'no such file' do
132
+ before do
133
+ allow(@rubocop.git).to receive(:diff_for_file).with('SAMPLE').and_return(nil)
134
+ end
135
+
136
+ it 'return empty array' do
137
+ expect(@rubocop.send(:added_lines, 'SAMPLE')).to eq([])
138
+ end
139
+ end
110
140
  end
111
141
 
112
142
  describe :lint_files do
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.8.0
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ash Furrow
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-12 00:00:00.000000000 Z
11
+ date: 2020-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rubocop
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -177,7 +177,7 @@ homepage: https://github.com/ashfurrow/danger-rubocop
177
177
  licenses:
178
178
  - MIT
179
179
  metadata: {}
180
- post_install_message:
180
+ post_install_message:
181
181
  rdoc_options: []
182
182
  require_paths:
183
183
  - lib
@@ -192,8 +192,8 @@ 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.1
196
- signing_key:
195
+ rubygems_version: 3.0.8
196
+ signing_key:
197
197
  specification_version: 4
198
198
  summary: A Danger plugin for running Ruby files through Rubocop.
199
199
  test_files: