rubocop 0.6.0 → 0.7.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 +7 -0
- data/.rubocop.yml +4 -262
- data/CHANGELOG.md +65 -1
- data/Gemfile +4 -0
- data/README.md +89 -2
- data/Rakefile +2 -2
- data/bin/rubocop +15 -10
- data/lib/rubocop/cli.rb +156 -114
- data/lib/rubocop/config.rb +202 -0
- data/lib/rubocop/config_store.rb +37 -0
- data/lib/rubocop/cop/alias.rb +2 -5
- data/lib/rubocop/cop/align_parameters.rb +1 -1
- data/lib/rubocop/cop/array_literal.rb +43 -4
- data/lib/rubocop/cop/{ascii_identifiers_and_comments.rb → ascii_comments.rb} +3 -3
- data/lib/rubocop/cop/ascii_identifiers.rb +18 -0
- data/lib/rubocop/cop/avoid_for.rb +2 -4
- data/lib/rubocop/cop/avoid_global_vars.rb +49 -0
- data/lib/rubocop/cop/block_comments.rb +17 -0
- data/lib/rubocop/cop/brace_after_percent.rb +9 -5
- data/lib/rubocop/cop/{indentation.rb → case_indentation.rb} +1 -1
- data/lib/rubocop/cop/class_methods.rb +20 -0
- data/lib/rubocop/cop/colon_method_call.rb +44 -0
- data/lib/rubocop/cop/cop.rb +33 -0
- data/lib/rubocop/cop/def_parentheses.rb +1 -1
- data/lib/rubocop/cop/empty_line_between_defs.rb +26 -0
- data/lib/rubocop/cop/empty_lines.rb +10 -13
- data/lib/rubocop/cop/eval.rb +22 -0
- data/lib/rubocop/cop/favor_join.rb +37 -0
- data/lib/rubocop/cop/grammar.rb +2 -2
- data/lib/rubocop/cop/hash_literal.rb +43 -4
- data/lib/rubocop/cop/hash_syntax.rb +2 -2
- data/lib/rubocop/cop/if_then_else.rb +1 -1
- data/lib/rubocop/cop/leading_comment_space.rb +20 -0
- data/lib/rubocop/cop/line_continuation.rb +18 -0
- data/lib/rubocop/cop/line_length.rb +1 -1
- data/lib/rubocop/cop/method_and_variable_snake_case.rb +7 -6
- data/lib/rubocop/cop/method_length.rb +4 -15
- data/lib/rubocop/cop/not.rb +15 -0
- data/lib/rubocop/cop/offence.rb +9 -0
- data/lib/rubocop/cop/op_method.rb +6 -1
- data/lib/rubocop/cop/semicolon.rb +74 -3
- data/lib/rubocop/cop/single_line_methods.rb +60 -0
- data/lib/rubocop/cop/space_after_comma_etc.rb +4 -5
- data/lib/rubocop/cop/space_after_control_keyword.rb +28 -0
- data/lib/rubocop/cop/surrounding_space.rb +48 -9
- data/lib/rubocop/cop/symbol_array.rb +29 -0
- data/lib/rubocop/cop/symbol_snake_case.rb +20 -0
- data/lib/rubocop/cop/trivial_accessors.rb +103 -0
- data/lib/rubocop/cop/unless_else.rb +1 -1
- data/lib/rubocop/cop/variable_interpolation.rb +3 -2
- data/lib/rubocop/cop/word_array.rb +38 -0
- data/lib/rubocop/report/plain_text.rb +1 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +22 -7
- data/rubocop.gemspec +11 -7
- data/spec/project_spec.rb +27 -0
- data/spec/rubocop/cli_spec.rb +556 -388
- data/spec/rubocop/config_spec.rb +399 -0
- data/spec/rubocop/config_store_spec.rb +66 -0
- data/spec/rubocop/cops/alias_spec.rb +7 -0
- data/spec/rubocop/cops/array_literal_spec.rb +18 -1
- data/spec/rubocop/cops/ascii_comments_spec.rb +27 -0
- data/spec/rubocop/cops/ascii_identifiers_spec.rb +27 -0
- data/spec/rubocop/cops/avoid_for_spec.rb +15 -1
- data/spec/rubocop/cops/avoid_global_vars.rb +32 -0
- data/spec/rubocop/cops/block_comments_spec.rb +29 -0
- data/spec/rubocop/cops/brace_after_percent_spec.rb +19 -13
- data/spec/rubocop/cops/{indentation_spec.rb → case_indentation_spec.rb} +2 -2
- data/spec/rubocop/cops/class_methods_spec.rb +49 -0
- data/spec/rubocop/cops/colon_method_call_spec.rb +47 -0
- data/spec/rubocop/cops/empty_line_between_defs_spec.rb +83 -0
- data/spec/rubocop/cops/empty_lines_spec.rb +6 -63
- data/spec/rubocop/cops/eval_spec.rb +36 -0
- data/spec/rubocop/cops/favor_join_spec.rb +39 -0
- data/spec/rubocop/cops/hash_literal_spec.rb +18 -1
- data/spec/rubocop/cops/leading_comment_space_spec.rb +60 -0
- data/spec/rubocop/cops/line_continuation_spec.rb +24 -0
- data/spec/rubocop/cops/line_length_spec.rb +1 -0
- data/spec/rubocop/cops/method_and_variable_snake_case_spec.rb +20 -0
- data/spec/rubocop/cops/method_length_spec.rb +2 -5
- data/spec/rubocop/cops/new_lambda_literal_spec.rb +2 -3
- data/spec/rubocop/cops/not_spec.rb +34 -0
- data/spec/rubocop/cops/offence_spec.rb +7 -0
- data/spec/rubocop/cops/op_method_spec.rb +11 -0
- data/spec/rubocop/cops/semicolon_spec.rb +79 -4
- data/spec/rubocop/cops/single_line_methods_spec.rb +50 -0
- data/spec/rubocop/cops/space_after_control_keyword_spec.rb +28 -0
- data/spec/rubocop/cops/space_after_semicolon_spec.rb +5 -0
- data/spec/rubocop/cops/space_around_equals_in_default_parameter_spec.rb +11 -1
- data/spec/rubocop/cops/space_inside_hash_literal_braces_spec.rb +74 -0
- data/spec/rubocop/cops/symbol_array_spec.rb +25 -0
- data/spec/rubocop/cops/symbol_snake_case_spec.rb +13 -0
- data/spec/rubocop/cops/trivial_accessors_spec.rb +332 -0
- data/spec/rubocop/cops/variable_interpolation_spec.rb +10 -1
- data/spec/rubocop/cops/word_array_spec.rb +39 -0
- data/spec/spec_helper.rb +18 -5
- data/spec/support/file_helper.rb +21 -0
- data/spec/support/isolated_environment.rb +27 -0
- metadata +82 -36
- data/spec/rubocop/cops/ascii_identifiers_and_comments_spec.rb +0 -38
|
@@ -16,6 +16,15 @@ module Rubocop
|
|
|
16
16
|
.to eq(['Replace interpolated var $test with expression #{$test}.'])
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
it 'registers an offence for interpolated regexp back references' do
|
|
20
|
+
inspect_source(vi,
|
|
21
|
+
'file.rb',
|
|
22
|
+
['puts "this is a #$1"'])
|
|
23
|
+
expect(vi.offences.size).to eq(1)
|
|
24
|
+
expect(vi.offences.map(&:message))
|
|
25
|
+
.to eq(['Replace interpolated var $1 with expression #{$1}.'])
|
|
26
|
+
end
|
|
27
|
+
|
|
19
28
|
it 'registers an offence for interpolated instance variables' do
|
|
20
29
|
inspect_source(vi,
|
|
21
30
|
'file.rb',
|
|
@@ -37,7 +46,7 @@ module Rubocop
|
|
|
37
46
|
it 'does not register an offence for variables in expressions' do
|
|
38
47
|
inspect_source(vi,
|
|
39
48
|
'file.rb',
|
|
40
|
-
['puts "this is a #{@test}"'])
|
|
49
|
+
['puts "this is a #{@test} #{@@t} #{$t} #{$1}"'])
|
|
41
50
|
expect(vi.offences).to be_empty
|
|
42
51
|
end
|
|
43
52
|
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
module Rubocop
|
|
6
|
+
module Cop
|
|
7
|
+
describe WordArray do
|
|
8
|
+
let(:wa) { WordArray.new }
|
|
9
|
+
|
|
10
|
+
it 'registers an offence for arrays of single quoted strings' do
|
|
11
|
+
inspect_source(wa,
|
|
12
|
+
'file.rb',
|
|
13
|
+
["['one', 'two', 'three']"])
|
|
14
|
+
expect(wa.offences.size).to eq(1)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'registers an offence for arrays of double quoted strings' do
|
|
18
|
+
inspect_source(wa,
|
|
19
|
+
'file.rb',
|
|
20
|
+
['["one", "two", "three"]'])
|
|
21
|
+
expect(wa.offences.size).to eq(1)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'does not register an offence for array of non-words' do
|
|
25
|
+
inspect_source(wa,
|
|
26
|
+
'file.rb',
|
|
27
|
+
['["one space", "two", "three"]'])
|
|
28
|
+
expect(wa.offences).to be_empty
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'does not register an offence for array with empty strings' do
|
|
32
|
+
inspect_source(wa,
|
|
33
|
+
'file.rb',
|
|
34
|
+
['["", "two", "three"]'])
|
|
35
|
+
expect(wa.offences).to be_empty
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
if ENV['COVERAGE']
|
|
3
|
+
if ENV['TRAVIS'] || ENV['COVERAGE']
|
|
4
4
|
require 'simplecov'
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
if ENV['TRAVIS']
|
|
7
|
+
require 'coveralls'
|
|
8
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
SimpleCov.start do
|
|
12
|
+
add_filter '/spec/'
|
|
13
|
+
add_filter '/vendor/bundle/'
|
|
14
|
+
end
|
|
6
15
|
end
|
|
7
16
|
|
|
8
17
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
@@ -11,9 +20,8 @@ require 'rspec'
|
|
|
11
20
|
require 'rubocop'
|
|
12
21
|
require 'rubocop/cli'
|
|
13
22
|
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
23
|
+
# disable colors in specs
|
|
24
|
+
Sickill::Rainbow.enabled = false
|
|
17
25
|
|
|
18
26
|
module ExitCodeMatchers
|
|
19
27
|
RSpec::Matchers.define :exit_with_code do |code|
|
|
@@ -41,6 +49,7 @@ end
|
|
|
41
49
|
|
|
42
50
|
RSpec.configure do |config|
|
|
43
51
|
config.filter_run_excluding ruby: ->(v) { !RUBY_VERSION.start_with?(v.to_s) }
|
|
52
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
|
44
53
|
|
|
45
54
|
config.expect_with :rspec do |c|
|
|
46
55
|
c.syntax = :expect # disables `should`
|
|
@@ -49,6 +58,10 @@ RSpec.configure do |config|
|
|
|
49
58
|
config.include(ExitCodeMatchers)
|
|
50
59
|
end
|
|
51
60
|
|
|
61
|
+
# Requires supporting files with custom matchers and macros, etc,
|
|
62
|
+
# in ./support/ and its subdirectories.
|
|
63
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
64
|
+
|
|
52
65
|
def inspect_source(cop, file, source)
|
|
53
66
|
tokens, sexp, correlations = Rubocop::CLI.rip_source(source)
|
|
54
67
|
cop.correlations = correlations
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
|
|
5
|
+
module FileHelper
|
|
6
|
+
def create_file(file_path, content)
|
|
7
|
+
file_path = File.expand_path(file_path)
|
|
8
|
+
|
|
9
|
+
dir_path = File.dirname(file_path)
|
|
10
|
+
FileUtils.makedirs dir_path unless File.exists?(dir_path)
|
|
11
|
+
|
|
12
|
+
File.open(file_path, 'w') do |file|
|
|
13
|
+
case content
|
|
14
|
+
when String
|
|
15
|
+
file.puts content
|
|
16
|
+
when Array
|
|
17
|
+
file.puts content.join("\n")
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'tmpdir'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
|
|
6
|
+
shared_context 'isolated environment', :isolated_environment do
|
|
7
|
+
around do |example|
|
|
8
|
+
Dir.mktmpdir do |tmpdir|
|
|
9
|
+
original_home = ENV['HOME']
|
|
10
|
+
|
|
11
|
+
begin
|
|
12
|
+
virtual_home = File.expand_path(File.join(tmpdir, 'home'))
|
|
13
|
+
Dir.mkdir(virtual_home)
|
|
14
|
+
ENV['HOME'] = virtual_home
|
|
15
|
+
|
|
16
|
+
working_dir = File.join(tmpdir, 'work')
|
|
17
|
+
Dir.mkdir(working_dir)
|
|
18
|
+
|
|
19
|
+
Dir.chdir(working_dir) do
|
|
20
|
+
example.run
|
|
21
|
+
end
|
|
22
|
+
ensure
|
|
23
|
+
ENV['HOME'] = original_home
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
metadata
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.7.0
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Bozhidar Batsov
|
|
@@ -12,25 +11,22 @@ cert_chain: []
|
|
|
12
11
|
date: 2013-04-17 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
name:
|
|
14
|
+
name: rainbow
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
16
|
requirements:
|
|
19
|
-
- -
|
|
17
|
+
- - '>='
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
21
|
-
version:
|
|
19
|
+
version: 1.1.4
|
|
22
20
|
type: :runtime
|
|
23
21
|
prerelease: false
|
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
-
none: false
|
|
26
23
|
requirements:
|
|
27
|
-
- -
|
|
24
|
+
- - '>='
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
|
-
version:
|
|
26
|
+
version: 1.1.4
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
|
31
28
|
name: rake
|
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
|
33
|
-
none: false
|
|
34
30
|
requirements:
|
|
35
31
|
- - ~>
|
|
36
32
|
- !ruby/object:Gem::Version
|
|
@@ -38,7 +34,6 @@ dependencies:
|
|
|
38
34
|
type: :development
|
|
39
35
|
prerelease: false
|
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
-
none: false
|
|
42
37
|
requirements:
|
|
43
38
|
- - ~>
|
|
44
39
|
- !ruby/object:Gem::Version
|
|
@@ -46,7 +41,6 @@ dependencies:
|
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
|
47
42
|
name: rspec
|
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
|
49
|
-
none: false
|
|
50
44
|
requirements:
|
|
51
45
|
- - ~>
|
|
52
46
|
- !ruby/object:Gem::Version
|
|
@@ -54,7 +48,6 @@ dependencies:
|
|
|
54
48
|
type: :development
|
|
55
49
|
prerelease: false
|
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
none: false
|
|
58
51
|
requirements:
|
|
59
52
|
- - ~>
|
|
60
53
|
- !ruby/object:Gem::Version
|
|
@@ -62,7 +55,6 @@ dependencies:
|
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
|
63
56
|
name: yard
|
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
|
65
|
-
none: false
|
|
66
58
|
requirements:
|
|
67
59
|
- - ~>
|
|
68
60
|
- !ruby/object:Gem::Version
|
|
@@ -70,7 +62,6 @@ dependencies:
|
|
|
70
62
|
type: :development
|
|
71
63
|
prerelease: false
|
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
-
none: false
|
|
74
65
|
requirements:
|
|
75
66
|
- - ~>
|
|
76
67
|
- !ruby/object:Gem::Version
|
|
@@ -78,7 +69,6 @@ dependencies:
|
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
|
79
70
|
name: bundler
|
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
|
81
|
-
none: false
|
|
82
72
|
requirements:
|
|
83
73
|
- - ~>
|
|
84
74
|
- !ruby/object:Gem::Version
|
|
@@ -86,7 +76,6 @@ dependencies:
|
|
|
86
76
|
type: :development
|
|
87
77
|
prerelease: false
|
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
89
|
-
none: false
|
|
90
79
|
requirements:
|
|
91
80
|
- - ~>
|
|
92
81
|
- !ruby/object:Gem::Version
|
|
@@ -94,7 +83,6 @@ dependencies:
|
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
|
95
84
|
name: simplecov
|
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
|
97
|
-
none: false
|
|
98
86
|
requirements:
|
|
99
87
|
- - ~>
|
|
100
88
|
- !ruby/object:Gem::Version
|
|
@@ -102,13 +90,13 @@ dependencies:
|
|
|
102
90
|
type: :development
|
|
103
91
|
prerelease: false
|
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
-
none: false
|
|
106
93
|
requirements:
|
|
107
94
|
- - ~>
|
|
108
95
|
- !ruby/object:Gem::Version
|
|
109
96
|
version: '0.7'
|
|
110
|
-
description:
|
|
111
|
-
|
|
97
|
+
description: |2
|
|
98
|
+
Automatic Ruby code style checking tool.
|
|
99
|
+
Aims to enforce the community-driven Ruby Style Guide.
|
|
112
100
|
email: bozhidar@batsov.com
|
|
113
101
|
executables:
|
|
114
102
|
- rubocop
|
|
@@ -130,25 +118,36 @@ files:
|
|
|
130
118
|
- bin/rubocop
|
|
131
119
|
- rubocop.gemspec
|
|
132
120
|
- lib/rubocop/cli.rb
|
|
121
|
+
- lib/rubocop/config.rb
|
|
122
|
+
- lib/rubocop/config_store.rb
|
|
133
123
|
- lib/rubocop/cop/alias.rb
|
|
134
124
|
- lib/rubocop/cop/align_parameters.rb
|
|
135
125
|
- lib/rubocop/cop/ampersands_pipes_vs_and_or.rb
|
|
136
126
|
- lib/rubocop/cop/array_literal.rb
|
|
137
|
-
- lib/rubocop/cop/
|
|
127
|
+
- lib/rubocop/cop/ascii_comments.rb
|
|
128
|
+
- lib/rubocop/cop/ascii_identifiers.rb
|
|
138
129
|
- lib/rubocop/cop/avoid_class_vars.rb
|
|
139
130
|
- lib/rubocop/cop/avoid_for.rb
|
|
131
|
+
- lib/rubocop/cop/avoid_global_vars.rb
|
|
140
132
|
- lib/rubocop/cop/avoid_perl_backrefs.rb
|
|
141
133
|
- lib/rubocop/cop/avoid_perlisms.rb
|
|
134
|
+
- lib/rubocop/cop/block_comments.rb
|
|
142
135
|
- lib/rubocop/cop/blocks.rb
|
|
143
136
|
- lib/rubocop/cop/brace_after_percent.rb
|
|
137
|
+
- lib/rubocop/cop/case_indentation.rb
|
|
144
138
|
- lib/rubocop/cop/class_and_module_camel_case.rb
|
|
139
|
+
- lib/rubocop/cop/class_methods.rb
|
|
145
140
|
- lib/rubocop/cop/collection_methods.rb
|
|
141
|
+
- lib/rubocop/cop/colon_method_call.rb
|
|
146
142
|
- lib/rubocop/cop/cop.rb
|
|
147
143
|
- lib/rubocop/cop/def_parentheses.rb
|
|
144
|
+
- lib/rubocop/cop/empty_line_between_defs.rb
|
|
148
145
|
- lib/rubocop/cop/empty_lines.rb
|
|
149
146
|
- lib/rubocop/cop/encoding.rb
|
|
150
147
|
- lib/rubocop/cop/end_of_line.rb
|
|
151
148
|
- lib/rubocop/cop/ensure_return.rb
|
|
149
|
+
- lib/rubocop/cop/eval.rb
|
|
150
|
+
- lib/rubocop/cop/favor_join.rb
|
|
152
151
|
- lib/rubocop/cop/favor_modifier.rb
|
|
153
152
|
- lib/rubocop/cop/favor_percent_r.rb
|
|
154
153
|
- lib/rubocop/cop/favor_sprintf.rb
|
|
@@ -158,11 +157,13 @@ files:
|
|
|
158
157
|
- lib/rubocop/cop/hash_literal.rb
|
|
159
158
|
- lib/rubocop/cop/hash_syntax.rb
|
|
160
159
|
- lib/rubocop/cop/if_then_else.rb
|
|
161
|
-
- lib/rubocop/cop/
|
|
160
|
+
- lib/rubocop/cop/leading_comment_space.rb
|
|
161
|
+
- lib/rubocop/cop/line_continuation.rb
|
|
162
162
|
- lib/rubocop/cop/line_length.rb
|
|
163
163
|
- lib/rubocop/cop/method_and_variable_snake_case.rb
|
|
164
164
|
- lib/rubocop/cop/method_length.rb
|
|
165
165
|
- lib/rubocop/cop/new_lambda_literal.rb
|
|
166
|
+
- lib/rubocop/cop/not.rb
|
|
166
167
|
- lib/rubocop/cop/numeric_literals.rb
|
|
167
168
|
- lib/rubocop/cop/offence.rb
|
|
168
169
|
- lib/rubocop/cop/op_method.rb
|
|
@@ -174,42 +175,59 @@ files:
|
|
|
174
175
|
- lib/rubocop/cop/rescue_exception.rb
|
|
175
176
|
- lib/rubocop/cop/rescue_modifier.rb
|
|
176
177
|
- lib/rubocop/cop/semicolon.rb
|
|
178
|
+
- lib/rubocop/cop/single_line_methods.rb
|
|
177
179
|
- lib/rubocop/cop/space_after_comma_etc.rb
|
|
180
|
+
- lib/rubocop/cop/space_after_control_keyword.rb
|
|
178
181
|
- lib/rubocop/cop/string_literals.rb
|
|
179
182
|
- lib/rubocop/cop/surrounding_space.rb
|
|
183
|
+
- lib/rubocop/cop/symbol_array.rb
|
|
180
184
|
- lib/rubocop/cop/symbol_snake_case.rb
|
|
181
185
|
- lib/rubocop/cop/syntax.rb
|
|
182
186
|
- lib/rubocop/cop/tab.rb
|
|
183
187
|
- lib/rubocop/cop/ternary_operator.rb
|
|
184
188
|
- lib/rubocop/cop/trailing_whitespace.rb
|
|
189
|
+
- lib/rubocop/cop/trivial_accessors.rb
|
|
185
190
|
- lib/rubocop/cop/unless_else.rb
|
|
186
191
|
- lib/rubocop/cop/variable_interpolation.rb
|
|
187
192
|
- lib/rubocop/cop/when_then.rb
|
|
193
|
+
- lib/rubocop/cop/word_array.rb
|
|
188
194
|
- lib/rubocop/report/emacs_style.rb
|
|
189
195
|
- lib/rubocop/report/plain_text.rb
|
|
190
196
|
- lib/rubocop/report/report.rb
|
|
191
197
|
- lib/rubocop/version.rb
|
|
192
198
|
- lib/rubocop.rb
|
|
199
|
+
- spec/project_spec.rb
|
|
193
200
|
- spec/rubocop/cli_spec.rb
|
|
201
|
+
- spec/rubocop/config_spec.rb
|
|
202
|
+
- spec/rubocop/config_store_spec.rb
|
|
194
203
|
- spec/rubocop/cops/alias_spec.rb
|
|
195
204
|
- spec/rubocop/cops/align_parameters_spec.rb
|
|
196
205
|
- spec/rubocop/cops/ampersands_pipes_vs_and_or_spec.rb
|
|
197
206
|
- spec/rubocop/cops/array_literal_spec.rb
|
|
198
|
-
- spec/rubocop/cops/
|
|
207
|
+
- spec/rubocop/cops/ascii_comments_spec.rb
|
|
208
|
+
- spec/rubocop/cops/ascii_identifiers_spec.rb
|
|
199
209
|
- spec/rubocop/cops/avoid_class_vars_spec.rb
|
|
200
210
|
- spec/rubocop/cops/avoid_for_spec.rb
|
|
211
|
+
- spec/rubocop/cops/avoid_global_vars.rb
|
|
201
212
|
- spec/rubocop/cops/avoid_perl_backrefs_spec.rb
|
|
202
213
|
- spec/rubocop/cops/avoid_perlisms_spec.rb
|
|
214
|
+
- spec/rubocop/cops/block_comments_spec.rb
|
|
203
215
|
- spec/rubocop/cops/brace_after_percent_spec.rb
|
|
216
|
+
- spec/rubocop/cops/case_indentation_spec.rb
|
|
204
217
|
- spec/rubocop/cops/class_and_module_camel_case_spec.rb
|
|
218
|
+
- spec/rubocop/cops/class_methods_spec.rb
|
|
205
219
|
- spec/rubocop/cops/collection_methods_spec.rb
|
|
220
|
+
- spec/rubocop/cops/colon_method_call_spec.rb
|
|
206
221
|
- spec/rubocop/cops/cop_spec.rb
|
|
207
222
|
- spec/rubocop/cops/def_with_parentheses_spec.rb
|
|
208
223
|
- spec/rubocop/cops/def_without_parentheses_spec.rb
|
|
224
|
+
- spec/rubocop/cops/empty_line_between_defs_spec.rb
|
|
209
225
|
- spec/rubocop/cops/empty_lines_spec.rb
|
|
210
226
|
- spec/rubocop/cops/encoding_spec.rb
|
|
211
227
|
- spec/rubocop/cops/end_of_line_spec.rb
|
|
212
228
|
- spec/rubocop/cops/ensure_return_spec.rb
|
|
229
|
+
- spec/rubocop/cops/eval_spec.rb
|
|
230
|
+
- spec/rubocop/cops/favor_join_spec.rb
|
|
213
231
|
- spec/rubocop/cops/favor_modifier_spec.rb
|
|
214
232
|
- spec/rubocop/cops/favor_percent_r.rb
|
|
215
233
|
- spec/rubocop/cops/favor_sprintf_spec.rb
|
|
@@ -220,13 +238,15 @@ files:
|
|
|
220
238
|
- spec/rubocop/cops/hash_literal_spec.rb
|
|
221
239
|
- spec/rubocop/cops/hash_syntax_spec.rb
|
|
222
240
|
- spec/rubocop/cops/if_with_semicolon_spec.rb
|
|
223
|
-
- spec/rubocop/cops/
|
|
241
|
+
- spec/rubocop/cops/leading_comment_space_spec.rb
|
|
242
|
+
- spec/rubocop/cops/line_continuation_spec.rb
|
|
224
243
|
- spec/rubocop/cops/line_length_spec.rb
|
|
225
244
|
- spec/rubocop/cops/method_and_variable_snake_case_spec.rb
|
|
226
245
|
- spec/rubocop/cops/method_length_spec.rb
|
|
227
246
|
- spec/rubocop/cops/multiline_blocks_spec.rb
|
|
228
247
|
- spec/rubocop/cops/multiline_if_then_spec.rb
|
|
229
248
|
- spec/rubocop/cops/new_lambda_literal_spec.rb
|
|
249
|
+
- spec/rubocop/cops/not_spec.rb
|
|
230
250
|
- spec/rubocop/cops/numeric_literals_spec.rb
|
|
231
251
|
- spec/rubocop/cops/offence_spec.rb
|
|
232
252
|
- spec/rubocop/cops/one_line_conditional_spec.rb
|
|
@@ -240,75 +260,91 @@ files:
|
|
|
240
260
|
- spec/rubocop/cops/rescue_modifier.rb
|
|
241
261
|
- spec/rubocop/cops/semicolon_spec.rb
|
|
242
262
|
- spec/rubocop/cops/single_line_blocks_spec.rb
|
|
263
|
+
- spec/rubocop/cops/single_line_methods_spec.rb
|
|
243
264
|
- spec/rubocop/cops/space_after_colon_spec.rb
|
|
244
265
|
- spec/rubocop/cops/space_after_comma_spec.rb
|
|
266
|
+
- spec/rubocop/cops/space_after_control_keyword_spec.rb
|
|
245
267
|
- spec/rubocop/cops/space_after_semicolon_spec.rb
|
|
246
268
|
- spec/rubocop/cops/space_around_braces_spec.rb
|
|
247
269
|
- spec/rubocop/cops/space_around_equals_in_default_parameter_spec.rb
|
|
248
270
|
- spec/rubocop/cops/space_around_operators_spec.rb
|
|
249
271
|
- spec/rubocop/cops/space_inside_brackets_spec.rb
|
|
272
|
+
- spec/rubocop/cops/space_inside_hash_literal_braces_spec.rb
|
|
250
273
|
- spec/rubocop/cops/space_inside_parens_spec.rb
|
|
251
274
|
- spec/rubocop/cops/string_literals_spec.rb
|
|
275
|
+
- spec/rubocop/cops/symbol_array_spec.rb
|
|
252
276
|
- spec/rubocop/cops/symbol_snake_case_spec.rb
|
|
253
277
|
- spec/rubocop/cops/syntax_spec.rb
|
|
254
278
|
- spec/rubocop/cops/tab_spec.rb
|
|
255
279
|
- spec/rubocop/cops/ternary_operator_spec.rb
|
|
256
280
|
- spec/rubocop/cops/trailing_whitespace_spec.rb
|
|
281
|
+
- spec/rubocop/cops/trivial_accessors_spec.rb
|
|
257
282
|
- spec/rubocop/cops/unless_else_spec.rb
|
|
258
283
|
- spec/rubocop/cops/variable_interpolation_spec.rb
|
|
259
284
|
- spec/rubocop/cops/when_then_spec.rb
|
|
285
|
+
- spec/rubocop/cops/word_array_spec.rb
|
|
260
286
|
- spec/rubocop/reports/emacs_style_spec.rb
|
|
261
287
|
- spec/rubocop/reports/report_spec.rb
|
|
262
288
|
- spec/spec_helper.rb
|
|
289
|
+
- spec/support/file_helper.rb
|
|
290
|
+
- spec/support/isolated_environment.rb
|
|
263
291
|
homepage: http://github.com/bbatsov/rubocop
|
|
264
292
|
licenses:
|
|
265
293
|
- MIT
|
|
294
|
+
metadata: {}
|
|
266
295
|
post_install_message:
|
|
267
296
|
rdoc_options: []
|
|
268
297
|
require_paths:
|
|
269
298
|
- lib
|
|
270
299
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
271
|
-
none: false
|
|
272
300
|
requirements:
|
|
273
|
-
- -
|
|
301
|
+
- - '>='
|
|
274
302
|
- !ruby/object:Gem::Version
|
|
275
303
|
version: 1.9.2
|
|
276
304
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
277
|
-
none: false
|
|
278
305
|
requirements:
|
|
279
|
-
- -
|
|
306
|
+
- - '>='
|
|
280
307
|
- !ruby/object:Gem::Version
|
|
281
308
|
version: '0'
|
|
282
|
-
segments:
|
|
283
|
-
- 0
|
|
284
|
-
hash: 4221530219562804900
|
|
285
309
|
requirements: []
|
|
286
310
|
rubyforge_project:
|
|
287
|
-
rubygems_version:
|
|
311
|
+
rubygems_version: 2.0.3
|
|
288
312
|
signing_key:
|
|
289
|
-
specification_version:
|
|
313
|
+
specification_version: 4
|
|
290
314
|
summary: Automatic Ruby code style checking tool.
|
|
291
315
|
test_files:
|
|
316
|
+
- spec/project_spec.rb
|
|
292
317
|
- spec/rubocop/cli_spec.rb
|
|
318
|
+
- spec/rubocop/config_spec.rb
|
|
319
|
+
- spec/rubocop/config_store_spec.rb
|
|
293
320
|
- spec/rubocop/cops/alias_spec.rb
|
|
294
321
|
- spec/rubocop/cops/align_parameters_spec.rb
|
|
295
322
|
- spec/rubocop/cops/ampersands_pipes_vs_and_or_spec.rb
|
|
296
323
|
- spec/rubocop/cops/array_literal_spec.rb
|
|
297
|
-
- spec/rubocop/cops/
|
|
324
|
+
- spec/rubocop/cops/ascii_comments_spec.rb
|
|
325
|
+
- spec/rubocop/cops/ascii_identifiers_spec.rb
|
|
298
326
|
- spec/rubocop/cops/avoid_class_vars_spec.rb
|
|
299
327
|
- spec/rubocop/cops/avoid_for_spec.rb
|
|
328
|
+
- spec/rubocop/cops/avoid_global_vars.rb
|
|
300
329
|
- spec/rubocop/cops/avoid_perl_backrefs_spec.rb
|
|
301
330
|
- spec/rubocop/cops/avoid_perlisms_spec.rb
|
|
331
|
+
- spec/rubocop/cops/block_comments_spec.rb
|
|
302
332
|
- spec/rubocop/cops/brace_after_percent_spec.rb
|
|
333
|
+
- spec/rubocop/cops/case_indentation_spec.rb
|
|
303
334
|
- spec/rubocop/cops/class_and_module_camel_case_spec.rb
|
|
335
|
+
- spec/rubocop/cops/class_methods_spec.rb
|
|
304
336
|
- spec/rubocop/cops/collection_methods_spec.rb
|
|
337
|
+
- spec/rubocop/cops/colon_method_call_spec.rb
|
|
305
338
|
- spec/rubocop/cops/cop_spec.rb
|
|
306
339
|
- spec/rubocop/cops/def_with_parentheses_spec.rb
|
|
307
340
|
- spec/rubocop/cops/def_without_parentheses_spec.rb
|
|
341
|
+
- spec/rubocop/cops/empty_line_between_defs_spec.rb
|
|
308
342
|
- spec/rubocop/cops/empty_lines_spec.rb
|
|
309
343
|
- spec/rubocop/cops/encoding_spec.rb
|
|
310
344
|
- spec/rubocop/cops/end_of_line_spec.rb
|
|
311
345
|
- spec/rubocop/cops/ensure_return_spec.rb
|
|
346
|
+
- spec/rubocop/cops/eval_spec.rb
|
|
347
|
+
- spec/rubocop/cops/favor_join_spec.rb
|
|
312
348
|
- spec/rubocop/cops/favor_modifier_spec.rb
|
|
313
349
|
- spec/rubocop/cops/favor_percent_r.rb
|
|
314
350
|
- spec/rubocop/cops/favor_sprintf_spec.rb
|
|
@@ -319,13 +355,15 @@ test_files:
|
|
|
319
355
|
- spec/rubocop/cops/hash_literal_spec.rb
|
|
320
356
|
- spec/rubocop/cops/hash_syntax_spec.rb
|
|
321
357
|
- spec/rubocop/cops/if_with_semicolon_spec.rb
|
|
322
|
-
- spec/rubocop/cops/
|
|
358
|
+
- spec/rubocop/cops/leading_comment_space_spec.rb
|
|
359
|
+
- spec/rubocop/cops/line_continuation_spec.rb
|
|
323
360
|
- spec/rubocop/cops/line_length_spec.rb
|
|
324
361
|
- spec/rubocop/cops/method_and_variable_snake_case_spec.rb
|
|
325
362
|
- spec/rubocop/cops/method_length_spec.rb
|
|
326
363
|
- spec/rubocop/cops/multiline_blocks_spec.rb
|
|
327
364
|
- spec/rubocop/cops/multiline_if_then_spec.rb
|
|
328
365
|
- spec/rubocop/cops/new_lambda_literal_spec.rb
|
|
366
|
+
- spec/rubocop/cops/not_spec.rb
|
|
329
367
|
- spec/rubocop/cops/numeric_literals_spec.rb
|
|
330
368
|
- spec/rubocop/cops/offence_spec.rb
|
|
331
369
|
- spec/rubocop/cops/one_line_conditional_spec.rb
|
|
@@ -339,24 +377,32 @@ test_files:
|
|
|
339
377
|
- spec/rubocop/cops/rescue_modifier.rb
|
|
340
378
|
- spec/rubocop/cops/semicolon_spec.rb
|
|
341
379
|
- spec/rubocop/cops/single_line_blocks_spec.rb
|
|
380
|
+
- spec/rubocop/cops/single_line_methods_spec.rb
|
|
342
381
|
- spec/rubocop/cops/space_after_colon_spec.rb
|
|
343
382
|
- spec/rubocop/cops/space_after_comma_spec.rb
|
|
383
|
+
- spec/rubocop/cops/space_after_control_keyword_spec.rb
|
|
344
384
|
- spec/rubocop/cops/space_after_semicolon_spec.rb
|
|
345
385
|
- spec/rubocop/cops/space_around_braces_spec.rb
|
|
346
386
|
- spec/rubocop/cops/space_around_equals_in_default_parameter_spec.rb
|
|
347
387
|
- spec/rubocop/cops/space_around_operators_spec.rb
|
|
348
388
|
- spec/rubocop/cops/space_inside_brackets_spec.rb
|
|
389
|
+
- spec/rubocop/cops/space_inside_hash_literal_braces_spec.rb
|
|
349
390
|
- spec/rubocop/cops/space_inside_parens_spec.rb
|
|
350
391
|
- spec/rubocop/cops/string_literals_spec.rb
|
|
392
|
+
- spec/rubocop/cops/symbol_array_spec.rb
|
|
351
393
|
- spec/rubocop/cops/symbol_snake_case_spec.rb
|
|
352
394
|
- spec/rubocop/cops/syntax_spec.rb
|
|
353
395
|
- spec/rubocop/cops/tab_spec.rb
|
|
354
396
|
- spec/rubocop/cops/ternary_operator_spec.rb
|
|
355
397
|
- spec/rubocop/cops/trailing_whitespace_spec.rb
|
|
398
|
+
- spec/rubocop/cops/trivial_accessors_spec.rb
|
|
356
399
|
- spec/rubocop/cops/unless_else_spec.rb
|
|
357
400
|
- spec/rubocop/cops/variable_interpolation_spec.rb
|
|
358
401
|
- spec/rubocop/cops/when_then_spec.rb
|
|
402
|
+
- spec/rubocop/cops/word_array_spec.rb
|
|
359
403
|
- spec/rubocop/reports/emacs_style_spec.rb
|
|
360
404
|
- spec/rubocop/reports/report_spec.rb
|
|
361
405
|
- spec/spec_helper.rb
|
|
406
|
+
- spec/support/file_helper.rb
|
|
407
|
+
- spec/support/isolated_environment.rb
|
|
362
408
|
has_rdoc:
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
module Rubocop
|
|
6
|
-
module Cop
|
|
7
|
-
describe AsciiIdentifiersAndComments do
|
|
8
|
-
let(:ascii) { AsciiIdentifiersAndComments.new }
|
|
9
|
-
|
|
10
|
-
it 'registers an offence for a variable name with non-ascii chars' do
|
|
11
|
-
inspect_source(ascii,
|
|
12
|
-
'file.rb',
|
|
13
|
-
['älg = 1'])
|
|
14
|
-
expect(ascii.offences.size).to eq(1)
|
|
15
|
-
expect(ascii.offences.map(&:message))
|
|
16
|
-
.to eq([AsciiIdentifiersAndComments::ERROR_MESSAGE])
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'registers an offence for a comment with non-ascii chars' do
|
|
20
|
-
inspect_source(ascii,
|
|
21
|
-
'file.rb',
|
|
22
|
-
['# 这是什么?'])
|
|
23
|
-
expect(ascii.offences.size).to eq(1)
|
|
24
|
-
expect(ascii.offences.map(&:message))
|
|
25
|
-
.to eq([AsciiIdentifiersAndComments::ERROR_MESSAGE])
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'accepts comments and identifiers with only ascii chars' do
|
|
29
|
-
inspect_source(ascii,
|
|
30
|
-
'file.rb',
|
|
31
|
-
['# AZaz1@$%~,;*_`|',
|
|
32
|
-
'x.empty?'])
|
|
33
|
-
expect(ascii.offences.size).to eq(0)
|
|
34
|
-
expect(ascii.offences.map(&:message)).to be_empty
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|