danger-rubocop 0.3.0 → 0.4.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
  SHA1:
3
- metadata.gz: 1978aa697df5bc21637aa6709902420c4609a3df
4
- data.tar.gz: 421a0668ca419f70fc5d6be6f1e0b3f03ca84a33
3
+ metadata.gz: 0344fb238b0dd6aeb32bf763745f599e46dd5176
4
+ data.tar.gz: 2653083d32aa0f8a7d1452fa5a81b674981ea479
5
5
  SHA512:
6
- metadata.gz: 49f783ea67d5843ed21746553d640477fab94fb03819118ae87adf3611ae22297a5eff61581b128e904f72535cd4b7d22296b37df6f130d4557f2763c0d8712d
7
- data.tar.gz: c079dc452e654c4bcad9e630528e0b4013d641189e9823dd5521ae8cc15226e8a2e6d65c84973c55d1921aed6ae14276ef0931060be5305735a2f7eec8708cc4
6
+ metadata.gz: 4fdb6286385ef2fc18a1cc37c3330d2719022d598e823be29ce35506a1d8307fb9fb02d2c3a55c6ee381e642880ba4d78193e5660b279d4a203d139d3aeafd78
7
+ data.tar.gz: 73e00649f3542c68ca1116f569b3fd996954428df566ced153394a3b70cd96d5349abfe14658c5844ae4f543faead71cf4ee51f0c79dbd88db2082f915279576
data/Gemfile.lock CHANGED
@@ -1,40 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-rubocop (0.2.0)
4
+ danger-rubocop (0.3.0)
5
5
  danger
6
6
  rubocop
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.4.0)
11
+ addressable (2.5.0)
12
+ public_suffix (~> 2.0, >= 2.0.2)
12
13
  ast (2.3.0)
13
14
  bacon (1.2.0)
14
- claide (1.0.0)
15
- claide-plugins (0.9.1)
15
+ claide (1.0.1)
16
+ claide-plugins (0.9.2)
16
17
  cork
17
18
  nap
18
19
  open4 (~> 1.3)
19
20
  coderay (1.1.1)
20
21
  colored (1.2)
21
- cork (0.1.0)
22
+ cork (0.2.0)
22
23
  colored (~> 1.2)
23
- danger (2.1.0)
24
+ danger (4.0.2)
24
25
  claide (~> 1.0)
25
- claide-plugins (> 0.9.0)
26
+ claide-plugins (>= 0.9.2)
26
27
  colored (~> 1.2)
27
28
  cork (~> 0.1)
28
- faraday (~> 0)
29
+ faraday (~> 0.9)
29
30
  faraday-http-cache (~> 1.0)
30
31
  git (~> 1)
32
+ kramdown (~> 1.5)
31
33
  octokit (~> 4.2)
32
- redcarpet (~> 3.3)
33
34
  terminal-table (~> 1)
34
35
  diff-lcs (1.2.5)
35
- faraday (0.9.2)
36
+ faraday (0.10.0)
36
37
  multipart-post (>= 1.2, < 3)
37
- faraday-http-cache (1.3.0)
38
+ faraday-http-cache (1.3.1)
38
39
  faraday (~> 0.8)
39
40
  ffi (1.9.10)
40
41
  formatador (0.2.5)
@@ -53,6 +54,7 @@ GEM
53
54
  guard (~> 2.1)
54
55
  guard-compat (~> 1.1)
55
56
  rspec (>= 2.99.0, < 4.0)
57
+ kramdown (1.13.1)
56
58
  listen (3.0.7)
57
59
  rb-fsevent (>= 0.9.3)
58
60
  rb-inotify (>= 0.9.7)
@@ -69,10 +71,10 @@ GEM
69
71
  notiffany (0.1.0)
70
72
  nenv (~> 0.1)
71
73
  shellany (~> 0.0)
72
- octokit (4.3.0)
73
- sawyer (~> 0.7.0, >= 0.5.3)
74
+ octokit (4.6.2)
75
+ sawyer (~> 0.8.0, >= 0.5.3)
74
76
  open4 (1.3.4)
75
- parser (2.3.1.2)
77
+ parser (2.3.3.1)
76
78
  ast (~> 2.2)
77
79
  powerpack (0.1.1)
78
80
  prettybacon (0.0.2)
@@ -81,12 +83,12 @@ GEM
81
83
  coderay (~> 1.1.0)
82
84
  method_source (~> 0.8.1)
83
85
  slop (~> 3.4)
86
+ public_suffix (2.0.4)
84
87
  rainbow (2.1.0)
85
88
  rake (10.5.0)
86
89
  rb-fsevent (0.9.7)
87
90
  rb-inotify (0.9.7)
88
91
  ffi (>= 0.5.0)
89
- redcarpet (3.3.4)
90
92
  rspec (3.4.0)
91
93
  rspec-core (~> 3.4.0)
92
94
  rspec-expectations (~> 3.4.0)
@@ -100,21 +102,22 @@ GEM
100
102
  diff-lcs (>= 1.2.0, < 2.0)
101
103
  rspec-support (~> 3.4.0)
102
104
  rspec-support (3.4.1)
103
- rubocop (0.42.0)
105
+ rubocop (0.46.0)
104
106
  parser (>= 2.3.1.1, < 3.0)
105
107
  powerpack (~> 0.1)
106
108
  rainbow (>= 1.99.1, < 3.0)
107
109
  ruby-progressbar (~> 1.7)
108
110
  unicode-display_width (~> 1.0, >= 1.0.1)
109
111
  ruby-progressbar (1.8.1)
110
- sawyer (0.7.0)
111
- addressable (>= 2.3.5, < 2.5)
112
- faraday (~> 0.8, < 0.10)
112
+ sawyer (0.8.1)
113
+ addressable (>= 2.3.5, < 2.6)
114
+ faraday (~> 0.8, < 1.0)
113
115
  shellany (0.0.1)
114
116
  slop (3.6.0)
115
- terminal-table (1.6.0)
117
+ terminal-table (1.7.3)
118
+ unicode-display_width (~> 1.1.1)
116
119
  thor (0.19.1)
117
- unicode-display_width (1.1.0)
120
+ unicode-display_width (1.1.1)
118
121
  yard (0.9.5)
119
122
 
120
123
  PLATFORMS
@@ -139,4 +142,4 @@ RUBY VERSION
139
142
  ruby 2.3.1p112
140
143
 
141
144
  BUNDLED WITH
142
- 1.12.5
145
+ 1.13.6
data/lib/danger_plugin.rb CHANGED
@@ -25,21 +25,25 @@ module Danger
25
25
  # @return [void]
26
26
  #
27
27
  def lint(files = nil)
28
- files_to_lint = files ? Dir.glob(files) : (git.modified_files + git.added_files)
28
+ files_to_lint = fetch_files_to_lint(files)
29
29
 
30
- offending_files = rubocop(files_to_lint)
31
30
  return if offending_files.empty?
32
31
 
33
32
  markdown offenses_message(offending_files)
34
33
  end
34
+
35
+ def offending_files(files = nil)
36
+ files_to_lint = fetch_files_to_lint(files)
37
+ rubocop(files_to_lint)
38
+ end
35
39
 
36
40
  private
37
41
 
38
42
  def rubocop(files_to_lint)
39
- rubocop_output = `#{'bundle exec ' if File.exist?('Gemfile')}rubocop -f json`
43
+ rubocop_output = `#{'bundle exec ' if File.exist?('Gemfile')}rubocop -f json #{files_to_lint.join(' ')}`
40
44
 
41
45
  JSON.parse(rubocop_output)['files']
42
- .select { |f| files_to_lint.include?(f['path']) && f['offenses'].any? }
46
+ .select { |f| f['offenses'].any? }
43
47
  end
44
48
 
45
49
  def offenses_message(offending_files)
@@ -57,5 +61,9 @@ module Danger
57
61
  ).to_s
58
62
  message + table.split("\n")[1..-2].join("\n")
59
63
  end
64
+
65
+ def fetch_files_to_lint(files = nil)
66
+ @files_to_lint ||= (files ? Dir.glob(files) : (git.modified_files + git.added_files))
67
+ end
60
68
  end
61
69
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DangerRubocop
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -13,9 +13,8 @@ module Danger
13
13
  end
14
14
 
15
15
  describe :lint_files do
16
- before do
17
- # Set up our stubbed JSON response
18
- response = {
16
+ let(:response_ruby_file) do
17
+ {
19
18
  'files' => [
20
19
  {
21
20
  'path' => 'spec/fixtures/ruby_file.rb',
@@ -25,7 +24,14 @@ module Danger
25
24
  'location' => { 'line' => 13 }
26
25
  }
27
26
  ]
28
- },
27
+ }
28
+ ]
29
+ }.to_json
30
+ end
31
+
32
+ let(:response_another_ruby_file) do
33
+ {
34
+ 'files' => [
29
35
  {
30
36
  'path' => 'spec/fixtures/another_ruby_file.rb',
31
37
  'offenses' => [
@@ -36,21 +42,18 @@ module Danger
36
42
  ]
37
43
  }
38
44
  ]
39
- }
40
- @rubocop_response = response.to_json
45
+ }.to_json
41
46
  end
42
47
 
43
48
  it 'handles a rubocop report for specified files' do
44
49
  allow(@rubocop).to receive(:`)
45
- .with('bundle exec rubocop -f json')
46
- .and_return(@rubocop_response)
50
+ .with('bundle exec rubocop -f json spec/fixtures/ruby_file.rb')
51
+ .and_return(response_ruby_file)
47
52
 
48
53
  # Do it
49
54
  @rubocop.lint('spec/fixtures/ruby*.rb')
50
55
 
51
- output = @rubocop.status_report[:markdowns].first
52
-
53
- expect(output).to_not be_empty
56
+ output = @rubocop.status_report[:markdowns].first.message
54
57
 
55
58
  # A title
56
59
  expect(output).to include('Rubocop violations')
@@ -64,14 +67,13 @@ module Danger
64
67
  .and_return(["spec/fixtures/another_ruby_file.rb"])
65
68
 
66
69
  allow(@rubocop).to receive(:`)
67
- .with('bundle exec rubocop -f json')
68
- .and_return(@rubocop_response)
70
+ .with('bundle exec rubocop -f json spec/fixtures/another_ruby_file.rb')
71
+ .and_return(response_another_ruby_file)
69
72
 
70
73
  @rubocop.lint
71
74
 
72
- output = @rubocop.status_report[:markdowns].first
75
+ output = @rubocop.status_report[:markdowns].first.message
73
76
 
74
- expect(output).to_not be_empty
75
77
  expect(output).to include('Rubocop violations')
76
78
  expect(output).to include("spec/fixtures/another_ruby_file.rb | 23 | Don't do that!")
77
79
  end
@@ -81,8 +83,8 @@ module Danger
81
83
  .and_return(['spec/fixtures/ruby_file.rb'])
82
84
  allow(@rubocop.git).to receive(:added_files).and_return([])
83
85
  allow(@rubocop).to receive(:`)
84
- .with('bundle exec rubocop -f json')
85
- .and_return(@rubocop_response)
86
+ .with('bundle exec rubocop -f json spec/fixtures/ruby_file.rb')
87
+ .and_return(response_ruby_file)
86
88
 
87
89
  @rubocop.lint
88
90
 
@@ -92,7 +94,7 @@ module Danger
92
94
  |----------------------------|------|----------------|
93
95
  | spec/fixtures/ruby_file.rb | 13 | Don't do that! |
94
96
  EOS
95
- expect(@rubocop.status_report[:markdowns].first).to eq(formatted_table.chomp)
97
+ expect(@rubocop.status_report[:markdowns].first.message).to eq(formatted_table.chomp)
96
98
  end
97
99
  end
98
100
  end
metadata CHANGED
@@ -1,125 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.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: 2016-08-02 00:00:00.000000000 Z
11
+ date: 2017-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubocop
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '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
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '10.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
68
  version: '10.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '3.4'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.4'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: guard
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '2.14'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '2.14'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: guard-rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '4.7'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '4.7'
125
125
  - !ruby/object:Gem::Dependency
@@ -140,14 +140,14 @@ dependencies:
140
140
  name: pry
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  description: A Danger plugin for running Ruby files through Rubocop.
@@ -156,7 +156,7 @@ executables: []
156
156
  extensions: []
157
157
  extra_rdoc_files: []
158
158
  files:
159
- - .gitignore
159
+ - ".gitignore"
160
160
  - Gemfile
161
161
  - Gemfile.lock
162
162
  - Guardfile
@@ -180,17 +180,17 @@ require_paths:
180
180
  - lib
181
181
  required_ruby_version: !ruby/object:Gem::Requirement
182
182
  requirements:
183
- - - '>='
183
+ - - ">="
184
184
  - !ruby/object:Gem::Version
185
185
  version: '0'
186
186
  required_rubygems_version: !ruby/object:Gem::Requirement
187
187
  requirements:
188
- - - '>='
188
+ - - ">="
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
191
  requirements: []
192
192
  rubyforge_project:
193
- rubygems_version: 2.0.14.1
193
+ rubygems_version: 2.5.1
194
194
  signing_key:
195
195
  specification_version: 4
196
196
  summary: A Danger plugin for running Ruby files through Rubocop.
@@ -198,4 +198,3 @@ test_files:
198
198
  - spec/danger_plugin_spec.rb
199
199
  - spec/fixtures/ruby_file.rb
200
200
  - spec/spec_helper.rb
201
- has_rdoc: