rubocop 0.34.1 → 0.34.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/config/disabled.yml +4 -0
- data/config/enabled.yml +3 -4
- data/lib/rubocop/config.rb +7 -5
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +45 -26
- data/lib/rubocop/cop/metrics/abc_size.rb +17 -6
- data/lib/rubocop/cop/performance/case_when_splat.rb +31 -3
- data/lib/rubocop/cop/style/auto_resource_cleanup.rb +2 -1
- data/lib/rubocop/cop/style/comment_annotation.rb +7 -1
- data/lib/rubocop/cop/style/extra_spacing.rb +19 -1
- data/lib/rubocop/cop/style/rescue_ensure_alignment.rb +6 -3
- data/lib/rubocop/cop/style/symbol_proc.rb +7 -1
- data/lib/rubocop/options.rb +4 -2
- data/lib/rubocop/result_cache.rb +1 -1
- data/lib/rubocop/runner.rb +1 -6
- data/lib/rubocop/version.rb +1 -1
- data/relnotes/v0.34.2.md +139 -0
- data/rubocop.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 706a61d96efb82b99fada36b2472fb0adc32ce09
|
4
|
+
data.tar.gz: 107b525881e8a174454969957a9e2e1b823f66f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e2e7a1a59ce5f66a66b013e53a1c864db55583de28c4dae467e8e095f985f0a7f8a81f52132f346308ff358fe9cc04d6db12d9a20275b6afa8fb2ca83944056
|
7
|
+
data.tar.gz: 52fa283a415fabac9ac2fcf6e06c2450381ecca66cffef48bcccc09729992bfafa8b5ffd2a044c5f936a31ed51932618d18bc593727d5bce823fb22c15370825
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,28 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 0.34.2 (21/09/2015)
|
6
|
+
|
7
|
+
### Bug Fixes
|
8
|
+
|
9
|
+
* [#2232](https://github.com/bbatsov/rubocop/issues/2232): Fix false positive in `Lint/FormatParameterMismatch` for argument with splat operator. ([@dreyks][])
|
10
|
+
* [#2237](https://github.com/bbatsov/rubocop/pull/2237): Allow `Lint/FormatParameterMismatch` to be called using `Kernel.format` and `Kernel.sprintf`. ([@rrosenblum][])
|
11
|
+
* [#2234](https://github.com/bbatsov/rubocop/issues/2234): Do not register an offense for `Lint/FormatParameterMismatch` when the format string is a variable. ([@rrosenblum][])
|
12
|
+
* [#2240](https://github.com/bbatsov/rubocop/pull/2240): `Lint/UnneededDisable` should not report non-`Lint` `rubocop:disable` comments when running `rubocop --lint`. ([@jonas054][])
|
13
|
+
* [#2121](https://github.com/bbatsov/rubocop/issues/2121): Allow space before values in hash literals in `Style/ExtraSpacing` to avoid correction conflict. ([@jonas054][])
|
14
|
+
* [#2241](https://github.com/bbatsov/rubocop/issues/2241): Read cache in binary format. ([@jonas054][])
|
15
|
+
* [#2247](https://github.com/bbatsov/rubocop/issues/2247): Fix auto-correct of `Performance/CaseWhenSplat` for percent arrays (`%w`, `%W`, `%i`, and `%I`). ([@rrosenblum][])
|
16
|
+
* [#2244](https://github.com/bbatsov/rubocop/issues/2244): Disregard annotation keywords in `Style/CommentAnnotation` if they don't start a comment. ([@jonas054][])
|
17
|
+
* [#2257](https://github.com/bbatsov/rubocop/pull/2257): Fix bug where `Style/RescueEnsureAlignment` will register an offense for `rescue` and `ensure` on the same line. ([@rrosenblum][])
|
18
|
+
* [#2255](https://github.com/bbatsov/rubocop/issues/2255): Refine the offense highlighting for `Style/SymbolProc`. ([@bbatsov][])
|
19
|
+
* [#2260](https://github.com/bbatsov/rubocop/pull/2260): Make `Exclude` in `.rubocop_todo.yml` work when running from a subdirectory. ([@jonas054][])
|
20
|
+
|
21
|
+
### Changes
|
22
|
+
|
23
|
+
* [#2248](https://github.com/bbatsov/rubocop/issues/2248): Allow block-pass in `Style/AutoResourceCleanup`. ([@lumeet][])
|
24
|
+
* [#2258](https://github.com/bbatsov/rubocop/pull/2258): `Style/Documentation` will exclude test directories by default. ([@rrosenblum][])
|
25
|
+
* [#2260](https://github.com/bbatsov/rubocop/issues/2260): Disable `Style/StringMethods` by default. ([@bbatsov][])
|
26
|
+
|
5
27
|
## 0.34.1 (09/09/2015)
|
6
28
|
|
7
29
|
### Bug Fixes
|
@@ -1599,3 +1621,4 @@
|
|
1599
1621
|
[@imtayadeway]: https://github.com/imtayadeway
|
1600
1622
|
[@mrfoto]: https://github.com/mrfoto
|
1601
1623
|
[@karreiro]: https://github.com/karreiro
|
1624
|
+
[@dreyks]: https://github.com/dreyks
|
data/config/disabled.yml
CHANGED
@@ -57,6 +57,10 @@ Style/Send:
|
|
57
57
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#prefer-public-send'
|
58
58
|
Enabled: false
|
59
59
|
|
60
|
+
Style/StringMethods:
|
61
|
+
Description: 'Checks if configured preferred methods are used over non-preferred.'
|
62
|
+
Enabled: false
|
63
|
+
|
60
64
|
Style/SymbolArray:
|
61
65
|
Description: 'Use %i or %I for arrays of symbols.'
|
62
66
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-i'
|
data/config/enabled.yml
CHANGED
@@ -171,6 +171,9 @@ Style/DeprecatedHashMethods:
|
|
171
171
|
Style/Documentation:
|
172
172
|
Description: 'Document classes and non-namespace modules.'
|
173
173
|
Enabled: true
|
174
|
+
Exclude:
|
175
|
+
- 'spec/**/*'
|
176
|
+
- 'test/**/*'
|
174
177
|
|
175
178
|
Style/DotPosition:
|
176
179
|
Description: 'Checks the position of the dot in multi-line method calls.'
|
@@ -698,10 +701,6 @@ Style/StringLiteralsInInterpolation:
|
|
698
701
|
strings match the configured preference.
|
699
702
|
Enabled: true
|
700
703
|
|
701
|
-
Style/StringMethods:
|
702
|
-
Description: 'Checks if configured preferred methods are used over non-preferred.'
|
703
|
-
Enabled: true
|
704
|
-
|
705
704
|
Style/StructInheritance:
|
706
705
|
Description: 'Checks for inheritance from Struct.new.'
|
707
706
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-extend-struct-new'
|
data/lib/rubocop/config.rb
CHANGED
@@ -162,13 +162,15 @@ module RuboCop
|
|
162
162
|
relative_path(path, base_dir_for_path_parameters)
|
163
163
|
end
|
164
164
|
|
165
|
-
# Paths specified in .rubocop.yml files are relative
|
166
|
-
# that file is. Paths in other config files are
|
167
|
-
# directory. This is so that paths in
|
168
|
-
# not relative to RuboCop's config
|
165
|
+
# Paths specified in .rubocop.yml and .rubocop_todo.yml files are relative
|
166
|
+
# to the directory where that file is. Paths in other config files are
|
167
|
+
# relative to the current directory. This is so that paths in
|
168
|
+
# config/default.yml, for example, are not relative to RuboCop's config
|
169
|
+
# directory since that wouldn't work.
|
169
170
|
def base_dir_for_path_parameters
|
171
|
+
config_files = [ConfigLoader::DOTFILE, ConfigLoader::AUTO_GENERATED_FILE]
|
170
172
|
@base_dir_for_path_parameters ||=
|
171
|
-
if File.basename(loaded_path)
|
173
|
+
if config_files.include?(File.basename(loaded_path))
|
172
174
|
File.expand_path(File.dirname(loaded_path))
|
173
175
|
else
|
174
176
|
Dir.pwd
|
@@ -14,13 +14,14 @@ module RuboCop
|
|
14
14
|
class FormatParameterMismatch < Cop
|
15
15
|
# http://rubular.com/r/CvpbxkcTzy
|
16
16
|
MSG = 'Number arguments (%i) to `%s` mismatches expected fields (%i).'
|
17
|
-
# rubocop:disable Metrics/LineLength
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
FIELD_REGEX = /(%(([\s#+-0\*])?(\d*)?(.\d+)?(\.)?[bBdiouxXeEfgGaAcps]|%))/.freeze # rubocop:disable Metrics/LineLength
|
18
|
+
NAMED_FIELD_REGEX = /%\{[_a-zA-Z][_a-zA-Z]+\}/.freeze
|
19
|
+
KERNEL = 'Kernel'.freeze
|
20
|
+
SHOVEL = '<<'.freeze
|
21
|
+
PERCENT = '%'.freeze
|
22
|
+
PERCENT_PERCENT = '%%'.freeze
|
23
|
+
SPLAT = '*'.freeze
|
24
|
+
STRING_TYPES = [:str, :dstr].freeze
|
24
25
|
|
25
26
|
def on_send(node)
|
26
27
|
add_offense(node, :selector) if offending_node?(node)
|
@@ -29,18 +30,29 @@ module RuboCop
|
|
29
30
|
private
|
30
31
|
|
31
32
|
def offending_node?(node)
|
33
|
+
return false unless called_on_string?(node)
|
34
|
+
|
32
35
|
if sprintf?(node) || format?(node) || percent?(node)
|
33
|
-
if named_mode?(node)
|
36
|
+
if named_mode?(node) || node_with_splat_args?(node)
|
34
37
|
false
|
35
38
|
else
|
36
|
-
|
37
|
-
num_of_expected_fields !=
|
39
|
+
num_of_format_args, num_of_expected_fields = count_matches(node)
|
40
|
+
num_of_expected_fields != num_of_format_args
|
38
41
|
end
|
39
42
|
else
|
40
43
|
false
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
47
|
+
def called_on_string?(node)
|
48
|
+
receiver_node, _method, format_string, = *node
|
49
|
+
if receiver_node.nil? || receiver_node.const_type?
|
50
|
+
format_string && format_string.str_type?
|
51
|
+
else
|
52
|
+
receiver_node.str_type?
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
44
56
|
def named_mode?(node)
|
45
57
|
receiver_node, _method_name, *args = *node
|
46
58
|
|
@@ -50,17 +62,21 @@ module RuboCop
|
|
50
62
|
receiver_node
|
51
63
|
end
|
52
64
|
|
53
|
-
relevant_node
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
65
|
+
relevant_node.loc.expression.source.scan(NAMED_FIELD_REGEX).size > 0
|
66
|
+
end
|
67
|
+
|
68
|
+
def node_with_splat_args?(node)
|
69
|
+
return false if percent?(node)
|
70
|
+
|
71
|
+
_receiver_node, _method_name, *args = *node
|
72
|
+
|
73
|
+
args[1..-1].any? { |arg| arg.type == :splat }
|
58
74
|
end
|
59
75
|
|
60
76
|
def heredoc?(node)
|
61
77
|
_receiver, _name, args = *node
|
62
78
|
|
63
|
-
args.loc.expression.source[0, 2] ==
|
79
|
+
args.loc.expression.source[0, 2] == SHOVEL
|
64
80
|
end
|
65
81
|
|
66
82
|
def count_matches(node)
|
@@ -72,7 +88,7 @@ module RuboCop
|
|
72
88
|
elsif percent?(node)
|
73
89
|
first_child_argument = args.first
|
74
90
|
|
75
|
-
if first_child_argument.
|
91
|
+
if first_child_argument.array_type?
|
76
92
|
number_of_args_for_format = args.first.child_nodes.size
|
77
93
|
number_of_expected_fields = expected_fields_count(receiver_node)
|
78
94
|
else
|
@@ -87,10 +103,13 @@ module RuboCop
|
|
87
103
|
def format_method?(name, node)
|
88
104
|
receiver, method_name, *args = *node
|
89
105
|
|
90
|
-
|
91
|
-
|
106
|
+
if receiver && receiver.const_type?
|
107
|
+
return false unless receiver.loc.name.is?(KERNEL)
|
108
|
+
end
|
109
|
+
|
110
|
+
return false unless method_name == name
|
92
111
|
|
93
|
-
args.size > 1 &&
|
112
|
+
args.size > 1 && args.first.str_type?
|
94
113
|
end
|
95
114
|
|
96
115
|
def expected_fields_count(node)
|
@@ -99,8 +118,8 @@ module RuboCop
|
|
99
118
|
.expression
|
100
119
|
.source
|
101
120
|
.scan(FIELD_REGEX)
|
102
|
-
.select { |x| x.first !=
|
103
|
-
.reduce(0) { |a, e| a + (e[2] ==
|
121
|
+
.select { |x| x.first != PERCENT_PERCENT }
|
122
|
+
.reduce(0) { |a, e| a + (e[2] == SPLAT ? 2 : 1) }
|
104
123
|
end
|
105
124
|
|
106
125
|
def format?(node)
|
@@ -115,10 +134,10 @@ module RuboCop
|
|
115
134
|
receiver_node, method_name, *arg_nodes = *node
|
116
135
|
|
117
136
|
percent = method_name == :% &&
|
118
|
-
(
|
119
|
-
arg_nodes[0].
|
137
|
+
(STRING_TYPES.include?(receiver_node.type) ||
|
138
|
+
arg_nodes[0].array_type?)
|
120
139
|
|
121
|
-
if percent &&
|
140
|
+
if percent && STRING_TYPES.include?(receiver_node.type)
|
122
141
|
return false if heredoc?(node)
|
123
142
|
end
|
124
143
|
|
@@ -129,7 +148,7 @@ module RuboCop
|
|
129
148
|
_receiver, method_name, *_args = *node
|
130
149
|
num_args_for_format, num_expected_fields = count_matches(node)
|
131
150
|
|
132
|
-
method_name = 'String#%' if
|
151
|
+
method_name = 'String#%' if PERCENT == method_name.to_s
|
133
152
|
format(MSG, num_args_for_format, method_name, num_expected_fields)
|
134
153
|
end
|
135
154
|
end
|
@@ -10,16 +10,27 @@ module RuboCop
|
|
10
10
|
include MethodComplexity
|
11
11
|
|
12
12
|
MSG = 'Assignment Branch Condition size for %s is too high. [%.4g/%.4g]'
|
13
|
-
BRANCH_NODES = [:send]
|
14
|
-
CONDITION_NODES = CyclomaticComplexity::COUNTED_NODES
|
13
|
+
BRANCH_NODES = [:send].freeze
|
14
|
+
CONDITION_NODES = CyclomaticComplexity::COUNTED_NODES.freeze
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def complexity(node)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
assignment = 0
|
20
|
+
branch = 0
|
21
|
+
condition = 0
|
22
|
+
|
23
|
+
node.each_node do |child|
|
24
|
+
if ASGN_NODES.include?(child.type)
|
25
|
+
assignment += 1
|
26
|
+
elsif BRANCH_NODES.include?(child.type)
|
27
|
+
branch += 1
|
28
|
+
elsif CONDITION_NODES.include?(child.type)
|
29
|
+
condition += 1
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Math.sqrt(assignment**2 + branch**2 + condition**2).round(2)
|
23
34
|
end
|
24
35
|
end
|
25
36
|
end
|
@@ -56,6 +56,11 @@ module RuboCop
|
|
56
56
|
MSG = 'Place `when` conditions with a splat ' \
|
57
57
|
'at the end of the `when` branches.'.freeze
|
58
58
|
ARRAY_MSG = 'Do not expand array literals in `when` conditions.'.freeze
|
59
|
+
OPEN_BRACKET = '['.freeze
|
60
|
+
PERCENT_W = '%w'.freeze
|
61
|
+
PERCENT_CAPITAL_W = '%W'.freeze
|
62
|
+
PERCENT_I = '%i'.freeze
|
63
|
+
PERCENT_CAPITAL_I = '%I'.freeze
|
59
64
|
|
60
65
|
def on_case(node)
|
61
66
|
_case_branch, *when_branches, _else_branch = *node
|
@@ -104,9 +109,16 @@ module RuboCop
|
|
104
109
|
|
105
110
|
def correct_array_literal(condition, variable)
|
106
111
|
lambda do |corrector|
|
107
|
-
|
108
|
-
|
109
|
-
|
112
|
+
array_start = variable.loc.begin.source
|
113
|
+
|
114
|
+
if array_start.start_with?(OPEN_BRACKET)
|
115
|
+
corrector.remove(condition.loc.operator)
|
116
|
+
corrector.remove(variable.loc.begin)
|
117
|
+
corrector.remove(variable.loc.end)
|
118
|
+
else
|
119
|
+
corrector.replace(condition.loc.expression,
|
120
|
+
expand_percent_array(variable))
|
121
|
+
end
|
110
122
|
end
|
111
123
|
end
|
112
124
|
|
@@ -126,6 +138,22 @@ module RuboCop
|
|
126
138
|
correction)
|
127
139
|
end
|
128
140
|
end
|
141
|
+
|
142
|
+
def expand_percent_array(array)
|
143
|
+
array_start = array.loc.begin.source
|
144
|
+
elements = *array
|
145
|
+
elements = elements.map { |e| e.loc.expression.source }
|
146
|
+
|
147
|
+
if array_start.start_with?(PERCENT_W)
|
148
|
+
"'#{elements.join("', '")}'"
|
149
|
+
elsif array_start.start_with?(PERCENT_CAPITAL_W)
|
150
|
+
%("#{elements.join('", "')}")
|
151
|
+
elsif array_start.start_with?(PERCENT_I)
|
152
|
+
":#{elements.join(', :')}"
|
153
|
+
elsif array_start.start_with?(PERCENT_CAPITAL_I)
|
154
|
+
%(:"#{elements.join('", :"')}")
|
155
|
+
end
|
156
|
+
end
|
129
157
|
end
|
130
158
|
end
|
131
159
|
end
|
@@ -25,7 +25,7 @@ module RuboCop
|
|
25
25
|
]
|
26
26
|
|
27
27
|
def on_send(node)
|
28
|
-
receiver_node, method_name, *
|
28
|
+
receiver_node, method_name, *arg_nodes = *node
|
29
29
|
|
30
30
|
TARGET_METHODS.each do |(target_class, target_method)|
|
31
31
|
target_receiver = s(:const, nil, target_class)
|
@@ -33,6 +33,7 @@ module RuboCop
|
|
33
33
|
next if receiver_node != target_receiver
|
34
34
|
next if method_name != target_method
|
35
35
|
next if node.parent && node.parent.block_type?
|
36
|
+
next if !arg_nodes.empty? && arg_nodes.last.block_pass_type?
|
36
37
|
|
37
38
|
add_offense(node,
|
38
39
|
:expression,
|
@@ -15,7 +15,9 @@ module RuboCop
|
|
15
15
|
'is missing a note.'
|
16
16
|
|
17
17
|
def investigate(processed_source)
|
18
|
-
processed_source.comments.
|
18
|
+
processed_source.comments.each_with_index do |comment, ix|
|
19
|
+
next unless first_comment_line?(processed_source.comments, ix)
|
20
|
+
|
19
21
|
margin, first_word, colon, space, note = split_comment(comment)
|
20
22
|
next unless annotation?(comment) &&
|
21
23
|
!correct_annotation?(first_word, colon, space, note)
|
@@ -36,6 +38,10 @@ module RuboCop
|
|
36
38
|
|
37
39
|
private
|
38
40
|
|
41
|
+
def first_comment_line?(comments, ix)
|
42
|
+
ix == 0 || comments[ix - 1].loc.line < comments[ix].loc.line - 1
|
43
|
+
end
|
44
|
+
|
39
45
|
def autocorrect(comment)
|
40
46
|
margin, first_word, colon, space, note = split_comment(comment)
|
41
47
|
start = comment.loc.expression.begin_pos + margin.length
|
@@ -21,6 +21,9 @@ module RuboCop
|
|
21
21
|
MSG = 'Unnecessary spacing detected.'
|
22
22
|
|
23
23
|
def investigate(processed_source)
|
24
|
+
ast = processed_source.ast
|
25
|
+
ignored_ranges = ast ? ignored_ranges(ast) : []
|
26
|
+
|
24
27
|
processed_source.tokens.each_cons(2) do |t1, t2|
|
25
28
|
next if t2.type == :tNL
|
26
29
|
next if t1.pos.line != t2.pos.line
|
@@ -30,7 +33,7 @@ module RuboCop
|
|
30
33
|
end_pos = t2.pos.begin_pos - 1
|
31
34
|
range = Parser::Source::Range.new(processed_source.buffer,
|
32
35
|
start_pos, end_pos)
|
33
|
-
add_offense(range, range, MSG)
|
36
|
+
add_offense(range, range, MSG) unless ignored_ranges.include?(range)
|
34
37
|
end
|
35
38
|
end
|
36
39
|
|
@@ -40,6 +43,21 @@ module RuboCop
|
|
40
43
|
|
41
44
|
private
|
42
45
|
|
46
|
+
# Returns an array of ranges that should not be reported. It's the
|
47
|
+
# extra spaces between the separators (: or =>) and values in a hash,
|
48
|
+
# since those are handled by the Style/AlignHash cop.
|
49
|
+
def ignored_ranges(ast)
|
50
|
+
ranges = []
|
51
|
+
on_node(:pair, ast) do |pair|
|
52
|
+
_, value = *pair
|
53
|
+
ranges <<
|
54
|
+
Parser::Source::Range.new(processed_source.buffer,
|
55
|
+
pair.loc.operator.end_pos,
|
56
|
+
value.loc.expression.begin_pos - 1)
|
57
|
+
end
|
58
|
+
ranges
|
59
|
+
end
|
60
|
+
|
43
61
|
def allow_for_alignment?
|
44
62
|
cop_config['AllowForAlignment']
|
45
63
|
end
|
@@ -33,9 +33,11 @@ module RuboCop
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def investigate(processed_source)
|
36
|
-
@modifier_locations =
|
37
|
-
|
38
|
-
|
36
|
+
@modifier_locations =
|
37
|
+
processed_source.tokens.each_with_object([]) do |token, locations|
|
38
|
+
next unless token.type == :kRESCUE_MOD
|
39
|
+
locations << token.pos
|
40
|
+
end
|
39
41
|
end
|
40
42
|
|
41
43
|
def autocorrect(node)
|
@@ -56,6 +58,7 @@ module RuboCop
|
|
56
58
|
def check(node)
|
57
59
|
end_loc = ancestor_node(node).loc.end
|
58
60
|
return if end_loc.column == node.loc.keyword.column
|
61
|
+
return if end_loc.line == node.loc.keyword.line
|
59
62
|
|
60
63
|
kw_loc = node.loc.keyword
|
61
64
|
|
@@ -34,8 +34,14 @@ module RuboCop
|
|
34
34
|
return unless can_shorten?(block_args, block_body)
|
35
35
|
|
36
36
|
_receiver, method_name, _args = *block_body
|
37
|
+
|
38
|
+
sb = node.loc.expression.source_buffer
|
39
|
+
block_start = node.loc.begin.begin_pos
|
40
|
+
block_end = node.loc.end.end_pos
|
41
|
+
range = Parser::Source::Range.new(sb, block_start, block_end)
|
42
|
+
|
37
43
|
add_offense(node,
|
38
|
-
|
44
|
+
range,
|
39
45
|
format(MSG,
|
40
46
|
method_name,
|
41
47
|
bmethod_name))
|
data/lib/rubocop/options.rb
CHANGED
@@ -137,7 +137,10 @@ module RuboCop
|
|
137
137
|
option(opts, '-D', '--display-cop-names')
|
138
138
|
option(opts, '-S', '--display-style-guide')
|
139
139
|
option(opts, '-R', '--rails')
|
140
|
-
option(opts, '-l', '--lint')
|
140
|
+
option(opts, '-l', '--lint') do
|
141
|
+
@options[:only] ||= []
|
142
|
+
@options[:only] << 'Lint'
|
143
|
+
end
|
141
144
|
option(opts, '-a', '--auto-correct')
|
142
145
|
|
143
146
|
@options[:color] = true
|
@@ -197,7 +200,6 @@ module RuboCop
|
|
197
200
|
# This module contains help texts for command line options.
|
198
201
|
module OptionsHelp
|
199
202
|
MAX_EXCL = RuboCop::Options::DEFAULT_MAXIMUM_EXCLUSION_ITEMS.to_s
|
200
|
-
# rubocop:disable Style/ExtraSpacing
|
201
203
|
TEXT = {
|
202
204
|
only: 'Run only the given cop(s).',
|
203
205
|
only_guide_cops: ['Run only cops for rules that link to a',
|
data/lib/rubocop/result_cache.rb
CHANGED
data/lib/rubocop/runner.rb
CHANGED
@@ -180,9 +180,7 @@ module RuboCop
|
|
180
180
|
[:only, :except].each { |opt| Options.validate_cop_list(@options[opt]) }
|
181
181
|
|
182
182
|
if @options[:only]
|
183
|
-
cop_classes.select!
|
184
|
-
c.match?(@options[:only]) || @options[:lint] && c.lint?
|
185
|
-
end
|
183
|
+
cop_classes.select! { |c| c.match?(@options[:only]) }
|
186
184
|
else
|
187
185
|
filter_cop_classes(cop_classes, config)
|
188
186
|
end
|
@@ -201,9 +199,6 @@ module RuboCop
|
|
201
199
|
|
202
200
|
# filter out Rails cops unless requested
|
203
201
|
cop_classes.reject!(&:rails?) unless run_rails_cops?(config)
|
204
|
-
|
205
|
-
# select only lint cops when --lint is passed
|
206
|
-
cop_classes.select!(&:lint?) if @options[:lint]
|
207
202
|
end
|
208
203
|
|
209
204
|
def run_rails_cops?(config)
|
data/lib/rubocop/version.rb
CHANGED
data/relnotes/v0.34.2.md
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
### Bug Fixes
|
2
|
+
|
3
|
+
* [#2232](https://github.com/bbatsov/rubocop/issues/2232): Fix false positive in `Lint/FormatParameterMismatch` for argument with splat operator. ([@dreyks][])
|
4
|
+
* [#2237](https://github.com/bbatsov/rubocop/pull/2237): Allow `Lint/FormatParameterMismatch` to be called using `Kernel.format` and `Kernel.sprintf`. ([@rrosenblum][])
|
5
|
+
* [#2234](https://github.com/bbatsov/rubocop/issues/2234): Do not register an offense for `Lint/FormatParameterMismatch` when the format string is a variable. ([@rrosenblum][])
|
6
|
+
* [#2240](https://github.com/bbatsov/rubocop/pull/2240): `Lint/UnneededDisable` should not report non-`Lint` `rubocop:disable` comments when running `rubocop --lint`. ([@jonas054][])
|
7
|
+
* [#2121](https://github.com/bbatsov/rubocop/issues/2121): Allow space before values in hash literals in `Style/ExtraSpacing` to avoid correction conflict. ([@jonas054][])
|
8
|
+
* [#2241](https://github.com/bbatsov/rubocop/issues/2241): Read cache in binary format. ([@jonas054][])
|
9
|
+
* [#2247](https://github.com/bbatsov/rubocop/issues/2247): Fix auto-correct of `Performance/CaseWhenSplat` for percent arrays (`%w`, `%W`, `%i`, and `%I`). ([@rrosenblum][])
|
10
|
+
* [#2244](https://github.com/bbatsov/rubocop/issues/2244): Disregard annotation keywords in `Style/CommentAnnotation` if they don't start a comment. ([@jonas054][])
|
11
|
+
* [#2257](https://github.com/bbatsov/rubocop/pull/2257): Fix bug where `Style/RescueEnsureAlignment` will register an offense for `rescue` and `ensure` on the same line. ([@rrosenblum][])
|
12
|
+
* [#2255](https://github.com/bbatsov/rubocop/issues/2255): Refine the offense highlighting for `Style/SymbolProc`. ([@bbatsov][])
|
13
|
+
* [#2260](https://github.com/bbatsov/rubocop/pull/2260): Make `Exclude` in `.rubocop_todo.yml` work when running from a subdirectory. ([@jonas054][])
|
14
|
+
|
15
|
+
### Changes
|
16
|
+
|
17
|
+
* [#2248](https://github.com/bbatsov/rubocop/issues/2248): Allow block-pass in `Style/AutoResourceCleanup`. ([@lumeet][])
|
18
|
+
* [#2258](https://github.com/bbatsov/rubocop/pull/2258): `Style/Documentation` will exclude test directories by default. ([@rrosenblum][])
|
19
|
+
* [#2260](https://github.com/bbatsov/rubocop/issues/2260): Disable `Style/StringMethods` by default. ([@bbatsov][])
|
20
|
+
|
21
|
+
[@bbatsov]: https://github.com/bbatsov
|
22
|
+
[@jonas054]: https://github.com/jonas054
|
23
|
+
[@yujinakayama]: https://github.com/yujinakayama
|
24
|
+
[@dblock]: https://github.com/dblock
|
25
|
+
[@nevir]: https://github.com/nevir
|
26
|
+
[@daviddavis]: https://github.com/daviddavis
|
27
|
+
[@sds]: https://github.com/sds
|
28
|
+
[@fancyremarker]: https://github.com/fancyremarker
|
29
|
+
[@sinisterchipmunk]: https://github.com/sinisterchipmunk
|
30
|
+
[@vonTronje]: https://github.com/vonTronje
|
31
|
+
[@agrimm]: https://github.com/agrimm
|
32
|
+
[@pmenglund]: https://github.com/pmenglund
|
33
|
+
[@chulkilee]: https://github.com/chulkilee
|
34
|
+
[@codez]: https://github.com/codez
|
35
|
+
[@emou]: https://github.com/emou
|
36
|
+
[@skanev]: http://github.com/skanev
|
37
|
+
[@claco]: http://github.com/claco
|
38
|
+
[@rifraf]: http://github.com/rifraf
|
39
|
+
[@scottmatthewman]: https://github.com/scottmatthewman
|
40
|
+
[@ma2gedev]: http://github.com/ma2gedev
|
41
|
+
[@jeremyolliver]: https://github.com/jeremyolliver
|
42
|
+
[@hannestyden]: https://github.com/hannestyden
|
43
|
+
[@geniou]: https://github.com/geniou
|
44
|
+
[@jkogara]: https://github.com/jkogara
|
45
|
+
[@tmorris-fiksu]: https://github.com/tmorris-fiksu
|
46
|
+
[@mockdeep]: https://github.com/mockdeep
|
47
|
+
[@hiroponz]: https://github.com/hiroponz
|
48
|
+
[@tamird]: https://github.com/tamird
|
49
|
+
[@fshowalter]: https://github.com/fshowalter
|
50
|
+
[@cschramm]: https://github.com/cschramm
|
51
|
+
[@bquorning]: https://github.com/bquorning
|
52
|
+
[@bcobb]: https://github.com/bcobb
|
53
|
+
[@irrationalfab]: https://github.com/irrationalfab
|
54
|
+
[@tommeier]: https://github.com/tommeier
|
55
|
+
[@sfeldon]: https://github.com/sfeldon
|
56
|
+
[@biinari]: https://github.com/biinari
|
57
|
+
[@barunio]: https://github.com/barunio
|
58
|
+
[@molawson]: https://github.com/molawson
|
59
|
+
[@wndhydrnt]: https://github.com/wndhydrnt
|
60
|
+
[@ggilder]: https://github.com/ggilder
|
61
|
+
[@salbertson]: https://github.com/salbertson
|
62
|
+
[@camilleldn]: https://github.com/camilleldn
|
63
|
+
[@mcls]: https://github.com/mcls
|
64
|
+
[@yous]: https://github.com/yous
|
65
|
+
[@vrthra]: https://github.com/vrthra
|
66
|
+
[@SkuliOskarsson]: https://github.com/SkuliOskarsson
|
67
|
+
[@jspanjers]: https://github.com/jspanjers
|
68
|
+
[@sch1zo]: https://github.com/sch1zo
|
69
|
+
[@smangelsdorf]: https://github.com/smangelsdorf
|
70
|
+
[@mvz]: https://github.com/mvz
|
71
|
+
[@jfelchner]: https://github.com/jfelchner
|
72
|
+
[@janraasch]: https://github.com/janraasch
|
73
|
+
[@jcarbo]: https://github.com/jcarbo
|
74
|
+
[@oneamtu]: https://github.com/oneamtu
|
75
|
+
[@toy]: https://github.com/toy
|
76
|
+
[@Koronen]: https://github.com/Koronen
|
77
|
+
[@blainesch]: https://github.com/blainesch
|
78
|
+
[@marxarelli]: https://github.com/marxarelli
|
79
|
+
[@katieschilling]: https://github.com/katieschilling
|
80
|
+
[@kakutani]: https://github.com/kakutani
|
81
|
+
[@rrosenblum]: https://github.com/rrosenblum
|
82
|
+
[@mattjmcnaughton]: https://github.com/mattjmcnaughton
|
83
|
+
[@huerlisi]: https://github.com/huerlisi
|
84
|
+
[@volkert]: https://github.com/volkert
|
85
|
+
[@lumeet]: https://github.com/lumeet
|
86
|
+
[@mmozuras]: https://github.com/mmozuras
|
87
|
+
[@d4rk5eed]: https://github.com/d4rk5eed
|
88
|
+
[@cshaffer]: https://github.com/cshaffer
|
89
|
+
[@eitoball]: https://github.com/eitoball
|
90
|
+
[@iainbeeston]: https://github.com/iainbeeston
|
91
|
+
[@pimterry]: https://github.com/pimterry
|
92
|
+
[@palkan]: https://github.com/palkan
|
93
|
+
[@jdoconnor]: https://github.com/jdoconnor
|
94
|
+
[@meganemura]: https://github.com/meganemura
|
95
|
+
[@zvkemp]: https://github.com/zvkemp
|
96
|
+
[@vassilevsky]: https://github.com/vassilevsky
|
97
|
+
[@gerry3]: https://github.com/gerry3
|
98
|
+
[@ypresto]: https://github.com/ypresto
|
99
|
+
[@clowder]: https://github.com/clowder
|
100
|
+
[@mudge]: https://github.com/mudge
|
101
|
+
[@mzp]: https://github.com/mzp
|
102
|
+
[@bankair]: https://github.com/bankair
|
103
|
+
[@crimsonknave]: https://github.com/crimsonknave
|
104
|
+
[@renuo]: https://github.com/renuo
|
105
|
+
[@sdeframond]: https://github.com/sdeframond
|
106
|
+
[@til]: https://github.com/til
|
107
|
+
[@carhartl]: https://github.com/carhartl
|
108
|
+
[@dylandavidson]: https://github.com/dylandavidson
|
109
|
+
[@tmr08c]: https://github.com/tmr08c
|
110
|
+
[@hbd225]: https://github.com/hbd225
|
111
|
+
[@l8nite]: https://github.com/l8nite
|
112
|
+
[@sumeet]: https://github.com/sumeet
|
113
|
+
[@ojab]: https://github.com/ojab
|
114
|
+
[@chastell]: https://github.com/chastell
|
115
|
+
[@glasnt]: https://github.com/glasnt
|
116
|
+
[@crazydog115]: https://github.com/crazydog115
|
117
|
+
[@RGBD]: https://github.com/RGBD
|
118
|
+
[@panthomakos]: https://github.com/panthomakos
|
119
|
+
[@matugm]: https://github.com/matugm
|
120
|
+
[@m1foley]: https://github.com/m1foley
|
121
|
+
[@tejasbubane]: https://github.com/tejasbubane
|
122
|
+
[@bmorrall]: https://github.com/bmorrall
|
123
|
+
[@fphilipe]: https://github.com/fphilipe
|
124
|
+
[@gotrevor]: https://github.com/gotrevor
|
125
|
+
[@awwaiid]: https://github.com/awwaiid
|
126
|
+
[@segiddins]: https://github.com/segiddins
|
127
|
+
[@urbanautomaton]: https://github.com/urbanautomaton.com
|
128
|
+
[@unmanbearpig]: https://github.com/unmanbearpig
|
129
|
+
[@maxjacobson]: https://github.com/maxjacobson
|
130
|
+
[@sliuu]: https://github.com/sliuu
|
131
|
+
[@edmz]: https://github.com/edmz
|
132
|
+
[@syndbg]: https://github.com/syndbg
|
133
|
+
[@wli]: https://github.com/wli
|
134
|
+
[@caseywebdev]: https://github.com/caseywebdev
|
135
|
+
[@MGerrior]: https://github.com/MGerrior
|
136
|
+
[@imtayadeway]: https://github.com/imtayadeway
|
137
|
+
[@mrfoto]: https://github.com/mrfoto
|
138
|
+
[@karreiro]: https://github.com/karreiro
|
139
|
+
[@dreyks]: https://github.com/dreyks
|
data/rubocop.gemspec
CHANGED
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
|
|
44
44
|
s.add_runtime_dependency('astrolabe', '~> 1.3')
|
45
45
|
s.add_runtime_dependency('ruby-progressbar', '~> 1.4')
|
46
46
|
s.add_development_dependency('rake', '~> 10.1')
|
47
|
-
s.add_development_dependency('rspec', '~> 3.
|
47
|
+
s.add_development_dependency('rspec', '~> 3.3.0')
|
48
48
|
s.add_development_dependency('yard', '~> 0.8')
|
49
49
|
s.add_development_dependency('bundler', '~> 1.3')
|
50
50
|
s.add_development_dependency('simplecov', '~> 0.10')
|
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.34.
|
4
|
+
version: 0.34.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-09-
|
13
|
+
date: 2015-09-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rainbow
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 3.
|
117
|
+
version: 3.3.0
|
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
|
-
version: 3.
|
124
|
+
version: 3.3.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: yard
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -533,6 +533,7 @@ files:
|
|
533
533
|
- relnotes/v0.33.0.md
|
534
534
|
- relnotes/v0.34.0.md
|
535
535
|
- relnotes/v0.34.1.md
|
536
|
+
- relnotes/v0.34.2.md
|
536
537
|
- rubocop.gemspec
|
537
538
|
homepage: http://github.com/bbatsov/rubocop
|
538
539
|
licenses:
|