rubocop 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubocop might be problematic. Click here for more details.
- data/CONTRIBUTING.md +12 -6
- data/Gemfile.lock +3 -3
- data/README.md +8 -0
- data/VERSION +1 -1
- data/lib/rubocop/cli.rb +11 -12
- data/lib/rubocop/cop/syntax.rb +5 -2
- data/rubocop.gemspec +2 -2
- data/spec/rubocop/cli_spec.rb +26 -0
- metadata +3 -3
data/CONTRIBUTING.md
CHANGED
@@ -1,9 +1,15 @@
|
|
1
|
-
# Contributing to
|
2
|
-
|
3
|
-
* Check out the latest master to make sure the feature hasn't been
|
4
|
-
|
1
|
+
# Contributing to RuboCop
|
2
|
+
|
3
|
+
* Check out the latest master to make sure the feature hasn't been
|
4
|
+
implemented or the bug hasn't been fixed yet.
|
5
|
+
* Check out the issue tracker to make sure someone already hasn't
|
6
|
+
requested it and/or contributed it.
|
5
7
|
* Fork the project.
|
6
8
|
* Start a feature/bugfix branch.
|
7
9
|
* Commit and push until you are happy with your contribution.
|
8
|
-
* Make sure to add tests for it. This is important so I don't break it
|
9
|
-
|
10
|
+
* Make sure to add tests for it. This is important so I don't break it
|
11
|
+
in a future version unintentionally.
|
12
|
+
* Please try not to mess with the Rakefile, version, or history. If
|
13
|
+
you want to have your own version, or is otherwise necessary, that
|
14
|
+
is fine, but please isolate to its own commit so I can cherry-pick
|
15
|
+
around it.
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
diff-lcs (1.2.
|
4
|
+
diff-lcs (1.2.3)
|
5
5
|
git (1.2.5)
|
6
6
|
jeweler (1.8.4)
|
7
7
|
bundler (~> 1.0)
|
@@ -20,13 +20,13 @@ GEM
|
|
20
20
|
rspec-core (2.13.1)
|
21
21
|
rspec-expectations (2.13.0)
|
22
22
|
diff-lcs (>= 1.1.3, < 2.0)
|
23
|
-
rspec-mocks (2.13.
|
23
|
+
rspec-mocks (2.13.1)
|
24
24
|
simplecov (0.7.1)
|
25
25
|
multi_json (~> 1.0)
|
26
26
|
simplecov-html (~> 0.7.1)
|
27
27
|
simplecov-html (0.7.1)
|
28
28
|
term-ansicolor (1.1.4)
|
29
|
-
yard (0.8.
|
29
|
+
yard (0.8.6)
|
30
30
|
|
31
31
|
PLATFORMS
|
32
32
|
ruby
|
data/README.md
CHANGED
@@ -76,6 +76,14 @@ analyzer a daunting task.
|
|
76
76
|
RuboCop currently supports MRI 1.9 and MRI 2.0. Support for JRuby and
|
77
77
|
Rubinius is not planned at this point.
|
78
78
|
|
79
|
+
## Editor integration
|
80
|
+
|
81
|
+
### Emacs
|
82
|
+
|
83
|
+
[rubocop.el](https://github.com/bbatsov/rubocop-emacs) is a simple
|
84
|
+
Emacs interface for RuboCop. It allows you to run RuboCop inside Emacs
|
85
|
+
and quickly jump between problems in your code.
|
86
|
+
|
79
87
|
## Copyright
|
80
88
|
|
81
89
|
Copyright (c) 2012-2013 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.5
|
data/lib/rubocop/cli.rb
CHANGED
@@ -36,15 +36,11 @@ module Rubocop
|
|
36
36
|
end
|
37
37
|
end.parse!(args)
|
38
38
|
|
39
|
+
cops = Cop::Cop.all
|
40
|
+
show_cops_on_duty(cops) if $options[:debug]
|
39
41
|
total_offences = 0
|
40
42
|
@configs = {}
|
41
43
|
|
42
|
-
target_files = target_files(args)
|
43
|
-
config = $options[:config] || config_from_dotfile(target_files[0])
|
44
|
-
|
45
|
-
cops = cops_on_duty(config)
|
46
|
-
show_cops_on_duty(cops) if $options[:debug]
|
47
|
-
|
48
44
|
target_files(args).each do |file|
|
49
45
|
report = Report.create(file, $options[:mode])
|
50
46
|
source = File.readlines(file).map do |line|
|
@@ -62,15 +58,18 @@ module Rubocop
|
|
62
58
|
total_offences += syntax_cop.offences.count
|
63
59
|
else
|
64
60
|
tokens, sexp, correlations = CLI.rip_source(source)
|
61
|
+
config = $options[:config] || config_from_dotfile(File.dirname(file))
|
65
62
|
|
66
63
|
cops.each do |cop_klass|
|
67
64
|
cop_config = config[cop_klass.name.split('::').last] if config
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
65
|
+
if cop_config.nil? || cop_config['Enabled']
|
66
|
+
cop_klass.config = cop_config
|
67
|
+
cop = cop_klass.new
|
68
|
+
cop.correlations = correlations
|
69
|
+
cop.inspect(file, source, tokens, sexp)
|
70
|
+
total_offences += cop.offences.count
|
71
|
+
report << cop if cop.has_report?
|
72
|
+
end
|
74
73
|
end
|
75
74
|
end
|
76
75
|
|
data/lib/rubocop/cop/syntax.rb
CHANGED
@@ -10,8 +10,11 @@ module Rubocop
|
|
10
10
|
Open3.capture3('ruby -wc', stdin_data: source.join("\n"))
|
11
11
|
|
12
12
|
stderr.each_line do |line|
|
13
|
-
|
14
|
-
|
13
|
+
# discard lines that are not containing relevant info
|
14
|
+
if line =~ /.+:(\d+): (.+)/
|
15
|
+
line_no, severity, message = process_line(line)
|
16
|
+
add_offence(severity, line_no, message)
|
17
|
+
end
|
15
18
|
end
|
16
19
|
end
|
17
20
|
|
data/rubocop.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "rubocop"
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bozhidar Batsov"]
|
12
|
-
s.date = "2013-04-
|
12
|
+
s.date = "2013-04-15"
|
13
13
|
s.description = "Automatic Ruby code style checking tool. Aims to enforce the community-driven Ruby Style Guide."
|
14
14
|
s.email = "bozhidar@batsov.com"
|
15
15
|
s.executables = ["rubocop"]
|
data/spec/rubocop/cli_spec.rb
CHANGED
@@ -208,6 +208,32 @@ module Rubocop
|
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
211
|
+
it 'can have different config files in different directories' do
|
212
|
+
%w(src lib).each do |dir|
|
213
|
+
FileUtils.mkdir_p "example/#{dir}"
|
214
|
+
File.open("example/#{dir}/example1.rb", 'w') do |f|
|
215
|
+
f.puts '# encoding: utf-8'
|
216
|
+
f.puts '#' * 90
|
217
|
+
end
|
218
|
+
end
|
219
|
+
File.open('example/src/.rubocop.yml', 'w') do |f|
|
220
|
+
f.puts('LineLength:',
|
221
|
+
' Enabled: true',
|
222
|
+
' Max: 100')
|
223
|
+
end
|
224
|
+
begin
|
225
|
+
expect(cli.run(['example'])).to eq(1)
|
226
|
+
expect($stdout.string.uncolored).to eq(
|
227
|
+
['== example/lib/example1.rb ==',
|
228
|
+
'C: 2: Line is too long. [90/79]',
|
229
|
+
'',
|
230
|
+
'2 files inspected, 1 offences detected',
|
231
|
+
''].join("\n"))
|
232
|
+
ensure
|
233
|
+
FileUtils.rm_rf 'example'
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
211
237
|
it 'finds no violations when checking the rubocop source code' do
|
212
238
|
cli.run
|
213
239
|
expect($stdout.string.uncolored).to match(
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: term-ansicolor
|
@@ -256,7 +256,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
256
256
|
version: '0'
|
257
257
|
segments:
|
258
258
|
- 0
|
259
|
-
hash:
|
259
|
+
hash: -80957332524471411
|
260
260
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
261
261
|
none: false
|
262
262
|
requirements:
|