rubocop 0.84.0 → 0.85.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/default.yml +33 -15
- data/lib/rubocop.rb +6 -0
- data/lib/rubocop/cli.rb +2 -2
- data/lib/rubocop/cli/command/auto_genenerate_config.rb +2 -2
- data/lib/rubocop/comment_config.rb +1 -1
- data/lib/rubocop/config.rb +3 -1
- data/lib/rubocop/config_loader.rb +1 -1
- data/lib/rubocop/config_loader_resolver.rb +18 -2
- data/lib/rubocop/config_store.rb +12 -2
- data/lib/rubocop/cop/bundler/gem_comment.rb +70 -1
- data/lib/rubocop/cop/commissioner.rb +0 -21
- data/lib/rubocop/cop/cop.rb +14 -6
- data/lib/rubocop/cop/corrector.rb +3 -1
- data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/parentheses_corrector.rb +3 -1
- data/lib/rubocop/cop/layout/case_indentation.rb +3 -3
- data/lib/rubocop/cop/layout/class_structure.rb +19 -16
- data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +2 -2
- data/lib/rubocop/cop/layout/end_of_line.rb +2 -2
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/first_array_element_line_break.rb +1 -1
- data/lib/rubocop/cop/layout/first_parameter_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/hash_alignment.rb +6 -6
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +1 -1
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +19 -102
- data/lib/rubocop/cop/layout/line_length.rb +17 -17
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +3 -1
- data/lib/rubocop/cop/layout/space_around_keyword.rb +2 -2
- data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +3 -1
- data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +3 -1
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +2 -1
- data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +8 -4
- data/lib/rubocop/cop/lint/ensure_return.rb +1 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +3 -1
- data/lib/rubocop/cop/lint/loop.rb +1 -1
- data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +62 -0
- data/lib/rubocop/cop/lint/nested_percent_literal.rb +1 -1
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +7 -7
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +3 -1
- data/lib/rubocop/cop/lint/redundant_require_statement.rb +3 -3
- data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
- data/lib/rubocop/cop/lint/suppressed_exception.rb +4 -2
- data/lib/rubocop/cop/lint/unreachable_code.rb +1 -1
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +1 -1
- data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
- data/lib/rubocop/cop/migration/department_name.rb +9 -5
- data/lib/rubocop/cop/mixin/array_min_size.rb +3 -1
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +3 -1
- data/lib/rubocop/cop/mixin/configurable_formatting.rb +1 -1
- data/lib/rubocop/cop/mixin/ignored_pattern.rb +1 -1
- data/lib/rubocop/cop/mixin/line_length_help.rb +1 -1
- data/lib/rubocop/cop/mixin/multiline_element_indentation.rb +3 -1
- data/lib/rubocop/cop/mixin/regexp_literal_help.rb +16 -0
- data/lib/rubocop/cop/mixin/surrounding_space.rb +3 -1
- data/lib/rubocop/cop/mixin/uncommunicative_name.rb +1 -1
- data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +11 -1
- data/lib/rubocop/cop/naming/file_name.rb +26 -11
- data/lib/rubocop/cop/naming/predicate_name.rb +1 -1
- data/lib/rubocop/cop/registry.rb +3 -1
- data/lib/rubocop/cop/style/array_join.rb +1 -1
- data/lib/rubocop/cop/style/bare_percent_literals.rb +1 -1
- data/lib/rubocop/cop/style/copyright.rb +2 -2
- data/lib/rubocop/cop/style/empty_method.rb +1 -1
- data/lib/rubocop/cop/style/exponential_notation.rb +3 -3
- data/lib/rubocop/cop/style/format_string_token.rb +2 -3
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -2
- data/lib/rubocop/cop/style/hash_each_methods.rb +1 -1
- data/lib/rubocop/cop/style/hash_syntax.rb +5 -3
- data/lib/rubocop/cop/style/inline_comment.rb +1 -1
- data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
- data/lib/rubocop/cop/style/negated_if.rb +3 -3
- data/lib/rubocop/cop/style/negated_unless.rb +3 -3
- data/lib/rubocop/cop/style/non_nil_check.rb +1 -1
- data/lib/rubocop/cop/style/redundant_percent_q.rb +1 -1
- data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +89 -0
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +130 -0
- data/lib/rubocop/cop/style/symbol_array.rb +1 -1
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +3 -3
- data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +3 -3
- data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +13 -13
- data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +3 -3
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +3 -1
- data/lib/rubocop/cop/style/unless_else.rb +1 -1
- data/lib/rubocop/cop/style/when_then.rb +1 -1
- data/lib/rubocop/cop/team.rb +61 -25
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/cop/variable_force/branch.rb +3 -1
- data/lib/rubocop/formatter/junit_formatter.rb +14 -4
- data/lib/rubocop/magic_comment.rb +1 -1
- data/lib/rubocop/options.rb +17 -3
- data/lib/rubocop/result_cache.rb +4 -4
- data/lib/rubocop/rspec/cop_helper.rb +2 -23
- data/lib/rubocop/rspec/expect_offense.rb +42 -6
- data/lib/rubocop/rspec/shared_contexts.rb +2 -2
- data/lib/rubocop/runner.rb +14 -10
- data/lib/rubocop/target_finder.rb +3 -1
- data/lib/rubocop/target_ruby.rb +4 -1
- data/lib/rubocop/version.rb +1 -1
- metadata +21 -3
@@ -106,7 +106,7 @@ module RuboCop
|
|
106
106
|
# method name
|
107
107
|
string =~ /\A[a-zA-Z_]\w*[!?]?\z/ ||
|
108
108
|
# instance / class variable
|
109
|
-
string =~ /\A
|
109
|
+
string =~ /\A@@?[a-zA-Z_]\w*\z/ ||
|
110
110
|
# global variable
|
111
111
|
string =~ /\A\$[1-9]\d*\z/ ||
|
112
112
|
string =~ /\A\$[a-zA-Z_]\w*\z/ ||
|
@@ -6,11 +6,11 @@ module RuboCop
|
|
6
6
|
# This cop checks for trailing comma in argument lists.
|
7
7
|
# The supported styles are:
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# * `consistent_comma`: Requires a comma after the last argument,
|
10
10
|
# for all parenthesized method calls with arguments.
|
11
|
-
#
|
11
|
+
# * `comma`: Requires a comma after the last argument, but only for
|
12
12
|
# parenthesized method calls where each argument is on its own line.
|
13
|
-
#
|
13
|
+
# * `no_comma`: Requires that there is no comma after the last
|
14
14
|
# argument.
|
15
15
|
#
|
16
16
|
# @example EnforcedStyleForMultiline: consistent_comma
|
@@ -6,11 +6,11 @@ module RuboCop
|
|
6
6
|
# This cop checks for trailing comma in array literals.
|
7
7
|
# The configuration options are:
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# * `consistent_comma`: Requires a comma after the
|
10
10
|
# last item of all non-empty, multiline array literals.
|
11
|
-
#
|
11
|
+
# * `comma`: Requires a comma after last item in an array,
|
12
12
|
# but only when each item is on its own line.
|
13
|
-
#
|
13
|
+
# * `no_comma`: Does not requires a comma after the
|
14
14
|
# last item in an array
|
15
15
|
#
|
16
16
|
# @example EnforcedStyleForMultiline: consistent_comma
|
@@ -12,7 +12,7 @@ module RuboCop
|
|
12
12
|
# # bad
|
13
13
|
# add { |foo, bar,| foo + bar }
|
14
14
|
#
|
15
|
-
#
|
15
|
+
# # good
|
16
16
|
# add { |foo, bar| foo + bar }
|
17
17
|
#
|
18
18
|
# # good
|
@@ -22,24 +22,24 @@ module RuboCop
|
|
22
22
|
# add { foo }
|
23
23
|
#
|
24
24
|
# # bad
|
25
|
-
#
|
26
|
-
#
|
25
|
+
# add do |foo, bar,|
|
26
|
+
# foo + bar
|
27
27
|
# end
|
28
28
|
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
29
|
+
# # good
|
30
|
+
# add do |foo, bar|
|
31
|
+
# foo + bar
|
32
|
+
# end
|
33
33
|
#
|
34
|
-
#
|
34
|
+
# # good
|
35
35
|
# add do |foo,|
|
36
|
-
#
|
37
|
-
#
|
36
|
+
# foo
|
37
|
+
# end
|
38
38
|
#
|
39
|
-
#
|
40
|
-
#
|
39
|
+
# # good
|
40
|
+
# add do
|
41
41
|
# foo + bar
|
42
|
-
#
|
42
|
+
# end
|
43
43
|
class TrailingCommaInBlockArgs < Cop
|
44
44
|
MSG = 'Useless trailing comma present in block arguments.'
|
45
45
|
|
@@ -6,11 +6,11 @@ module RuboCop
|
|
6
6
|
# This cop checks for trailing comma in hash literals.
|
7
7
|
# The configuration options are:
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# * `consistent_comma`: Requires a comma after the
|
10
10
|
# last item of all non-empty, multiline hash literals.
|
11
|
-
#
|
11
|
+
# * `comma`: Requires a comma after the last item in a hash,
|
12
12
|
# but only when each item is on its own line.
|
13
|
-
#
|
13
|
+
# * `no_comma`: Does not requires a comma after the
|
14
14
|
# last item in a hash
|
15
15
|
#
|
16
16
|
# @example EnforcedStyleForMultiline: consistent_comma
|
@@ -122,7 +122,9 @@ module RuboCop
|
|
122
122
|
|
123
123
|
return unless first_offense
|
124
124
|
|
125
|
-
|
125
|
+
if unused_variables_only?(first_offense, variables)
|
126
|
+
return unused_range(node.type, mlhs_node, right)
|
127
|
+
end
|
126
128
|
|
127
129
|
return range_for_parentheses(first_offense, mlhs_node) if Util.parentheses?(mlhs_node)
|
128
130
|
|
data/lib/rubocop/cop/team.rb
CHANGED
@@ -2,7 +2,13 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
#
|
5
|
+
# A group of cops, ready to be called on duty to inspect files.
|
6
|
+
# Team is responsible for selecting only relevant cops to be sent on duty,
|
7
|
+
# as well as insuring that the needed forces are sent along with them.
|
8
|
+
#
|
9
|
+
# For performance reasons, Team will first dispatch cops & forces in two groups,
|
10
|
+
# first the ones needed for autocorrection (if any), then the rest
|
11
|
+
# (unless autocorrections happened).
|
6
12
|
class Team
|
7
13
|
DEFAULT_OPTIONS = {
|
8
14
|
auto_correct: false,
|
@@ -11,12 +17,12 @@ module RuboCop
|
|
11
17
|
|
12
18
|
Investigation = Struct.new(:offenses, :errors)
|
13
19
|
|
14
|
-
attr_reader :errors, :warnings, :updated_source_file
|
20
|
+
attr_reader :errors, :warnings, :updated_source_file, :cops
|
15
21
|
|
16
22
|
alias updated_source_file? updated_source_file
|
17
23
|
|
18
|
-
def initialize(
|
19
|
-
@
|
24
|
+
def initialize(cops, config = nil, options = nil)
|
25
|
+
@cops = cops
|
20
26
|
@config = config
|
21
27
|
@options = options || DEFAULT_OPTIONS
|
22
28
|
@errors = []
|
@@ -25,6 +31,23 @@ module RuboCop
|
|
25
31
|
validate_config
|
26
32
|
end
|
27
33
|
|
34
|
+
# @return [Team] with cops assembled from the given `cop_classes`
|
35
|
+
def self.mobilize(cop_classes, config, options = nil)
|
36
|
+
options ||= DEFAULT_OPTIONS
|
37
|
+
cops = mobilize_cops(cop_classes, config, options)
|
38
|
+
new(cops, config, options)
|
39
|
+
end
|
40
|
+
|
41
|
+
# @return [Array<Cop::Cop>]
|
42
|
+
def self.mobilize_cops(cop_classes, config, options = nil)
|
43
|
+
options ||= DEFAULT_OPTIONS
|
44
|
+
only = options.fetch(:only, [])
|
45
|
+
safe = options.fetch(:safe, false)
|
46
|
+
cop_classes.enabled(config, only, safe).map do |cop_class|
|
47
|
+
cop_class.new(config, options)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
28
51
|
def autocorrect?
|
29
52
|
@options[:auto_correct]
|
30
53
|
end
|
@@ -44,14 +67,6 @@ module RuboCop
|
|
44
67
|
offenses(processed_source)
|
45
68
|
end
|
46
69
|
|
47
|
-
def cops
|
48
|
-
only = @options.fetch(:only, [])
|
49
|
-
safe = @options.fetch(:safe, false)
|
50
|
-
@cops ||= @cop_classes.enabled(@config, only, safe).map do |cop_class|
|
51
|
-
cop_class.new(@config, @options)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
70
|
def forces
|
56
71
|
@forces ||= forces_for(cops)
|
57
72
|
end
|
@@ -93,21 +108,23 @@ module RuboCop
|
|
93
108
|
|
94
109
|
private
|
95
110
|
|
96
|
-
def offenses(processed_source)
|
111
|
+
def offenses(processed_source) # rubocop:disable Metrics/AbcSize
|
97
112
|
# The autocorrection process may have to be repeated multiple times
|
98
113
|
# until there are no corrections left to perform
|
99
114
|
# To speed things up, run auto-correcting cops by themselves, and only
|
100
115
|
# run the other cops when no corrections are left
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
116
|
+
on_duty = roundup_relevant_cops(processed_source.file_path)
|
117
|
+
|
118
|
+
autocorrect_cops, other_cops = on_duty.partition(&:autocorrect?)
|
119
|
+
|
120
|
+
autocorrect = investigate(autocorrect_cops, processed_source)
|
121
|
+
|
122
|
+
if autocorrect(processed_source.buffer, autocorrect_cops)
|
123
|
+
# We corrected some errors. Another round of inspection will be
|
124
|
+
# done, and any other offenses will be caught then, so we don't
|
125
|
+
# need to continue.
|
126
|
+
return autocorrect.offenses
|
127
|
+
end
|
111
128
|
|
112
129
|
other = investigate(other_cops, processed_source)
|
113
130
|
|
@@ -120,13 +137,32 @@ module RuboCop
|
|
120
137
|
def investigate(cops, processed_source)
|
121
138
|
return Investigation.new([], {}) if cops.empty?
|
122
139
|
|
123
|
-
commissioner = Commissioner.new(cops, forces_for(cops))
|
140
|
+
commissioner = Commissioner.new(cops, forces_for(cops), @options)
|
124
141
|
offenses = commissioner.investigate(processed_source)
|
125
|
-
yield offenses if block_given?
|
126
142
|
|
127
143
|
Investigation.new(offenses, commissioner.errors)
|
128
144
|
end
|
129
145
|
|
146
|
+
def roundup_relevant_cops(filename)
|
147
|
+
cops.reject do |cop|
|
148
|
+
cop.excluded_file?(filename) ||
|
149
|
+
!support_target_ruby_version?(cop) ||
|
150
|
+
!support_target_rails_version?(cop)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def support_target_ruby_version?(cop)
|
155
|
+
return true unless cop.class.respond_to?(:support_target_ruby_version?)
|
156
|
+
|
157
|
+
cop.class.support_target_ruby_version?(cop.target_ruby_version)
|
158
|
+
end
|
159
|
+
|
160
|
+
def support_target_rails_version?(cop)
|
161
|
+
return true unless cop.class.respond_to?(:support_target_rails_version?)
|
162
|
+
|
163
|
+
cop.class.support_target_rails_version?(cop.target_rails_version)
|
164
|
+
end
|
165
|
+
|
130
166
|
def autocorrect_all_cops(buffer, cops)
|
131
167
|
corrector = Corrector.new(buffer)
|
132
168
|
|
data/lib/rubocop/cop/util.rb
CHANGED
@@ -108,7 +108,7 @@ module RuboCop
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def trim_string_interporation_escape_character(str)
|
111
|
-
str.gsub(
|
111
|
+
str.gsub(/\\\#\{(.*?)\}/) { "\#{#{Regexp.last_match(1)}}" }
|
112
112
|
end
|
113
113
|
|
114
114
|
def interpret_string_escapes(string)
|
@@ -109,7 +109,9 @@ module RuboCop
|
|
109
109
|
return false if may_jump_to_other_branch?
|
110
110
|
|
111
111
|
other.each_ancestor(include_self: true) do |other_ancestor|
|
112
|
-
|
112
|
+
if control_node.equal?(other_ancestor.control_node)
|
113
|
+
return !child_node.equal?(other_ancestor.child_node)
|
114
|
+
end
|
113
115
|
end
|
114
116
|
|
115
117
|
if parent
|
@@ -35,19 +35,29 @@ module RuboCop
|
|
35
35
|
#
|
36
36
|
# In the future, it would be preferable to return only enabled cops.
|
37
37
|
Cop::Cop.all.each do |cop|
|
38
|
+
target_offenses = offenses_for_cop(offenses, cop)
|
39
|
+
|
40
|
+
next unless relevant_for_output?(options, target_offenses)
|
41
|
+
|
38
42
|
REXML::Element.new('testcase', @testsuite).tap do |testcase|
|
39
43
|
testcase.attributes['classname'] = classname_attribute_value(file)
|
40
44
|
testcase.attributes['name'] = cop.cop_name
|
41
45
|
|
42
|
-
target_offenses = offenses.select do |offense|
|
43
|
-
offense.cop_name == cop.cop_name
|
44
|
-
end
|
45
|
-
|
46
46
|
add_failure_to(testcase, target_offenses, cop.cop_name)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
def relevant_for_output?(options, target_offenses)
|
52
|
+
!options[:display_only_failed] || target_offenses.any?
|
53
|
+
end
|
54
|
+
|
55
|
+
def offenses_for_cop(all_offenses, cop)
|
56
|
+
all_offenses.select do |offense|
|
57
|
+
offense.cop_name == cop.cop_name
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
51
61
|
def classname_attribute_value(file)
|
52
62
|
file.gsub(/\.rb\Z/, '').gsub("#{Dir.pwd}/", '').tr('/', '.')
|
53
63
|
end
|
@@ -133,7 +133,7 @@ module RuboCop
|
|
133
133
|
# @see https://www.gnu.org/software/emacs/manual/html_node/emacs/Specify-Coding.html
|
134
134
|
# @see https://git.io/vMCXh Emacs handling in Ruby's parse.y
|
135
135
|
class EmacsComment < EditorComment
|
136
|
-
FORMAT =
|
136
|
+
FORMAT = /-\*-(.+)-\*-/.freeze
|
137
137
|
SEPARATOR = ';'
|
138
138
|
OPERATOR = ':'
|
139
139
|
|
data/lib/rubocop/options.rb
CHANGED
@@ -143,6 +143,8 @@ module RuboCop
|
|
143
143
|
@options[:output_path] = path
|
144
144
|
end
|
145
145
|
end
|
146
|
+
|
147
|
+
option(opts, '--display-only-failed')
|
146
148
|
end
|
147
149
|
|
148
150
|
def add_severity_option(opts)
|
@@ -276,7 +278,9 @@ module RuboCop
|
|
276
278
|
'be used with --only.'
|
277
279
|
end
|
278
280
|
raise OptionArgumentError, 'Syntax checking cannot be turned off.' if except_syntax?
|
279
|
-
|
281
|
+
unless boolean_or_empty_cache?
|
282
|
+
raise OptionArgumentError, '-C/--cache argument must be true or false'
|
283
|
+
end
|
280
284
|
|
281
285
|
if display_only_fail_level_offenses_with_autocorrect?
|
282
286
|
raise OptionArgumentError, '--autocorrect cannot be used with ' \
|
@@ -284,6 +288,7 @@ module RuboCop
|
|
284
288
|
end
|
285
289
|
validate_auto_gen_config
|
286
290
|
validate_auto_correct
|
291
|
+
validate_display_only_failed
|
287
292
|
validate_parallel
|
288
293
|
|
289
294
|
return if incompatible_options.size <= 1
|
@@ -307,13 +312,20 @@ module RuboCop
|
|
307
312
|
end
|
308
313
|
end
|
309
314
|
|
315
|
+
def validate_display_only_failed
|
316
|
+
return unless @options.key?(:display_only_failed)
|
317
|
+
return if @options[:format] == 'junit'
|
318
|
+
|
319
|
+
raise OptionArgumentError,
|
320
|
+
format('--display-only-failed can only be used together with --format junit.')
|
321
|
+
end
|
322
|
+
|
310
323
|
def validate_auto_correct
|
311
324
|
return if @options.key?(:auto_correct)
|
312
325
|
return unless @options.key?(:disable_uncorrectable)
|
313
326
|
|
314
327
|
raise OptionArgumentError,
|
315
|
-
format('
|
316
|
-
flag: '--disable-uncorrectable')
|
328
|
+
format('--disable-uncorrectable can only be used together with --auto-correct.')
|
317
329
|
end
|
318
330
|
|
319
331
|
def validate_parallel
|
@@ -429,6 +441,8 @@ module RuboCop
|
|
429
441
|
'if no format is specified.'],
|
430
442
|
fail_level: ['Minimum severity (A/R/C/W/E/F) for exit',
|
431
443
|
'with error code.'],
|
444
|
+
display_only_failed: ['Only output offense messages. Omit passing',
|
445
|
+
'cops. Only valid for --format junit.'],
|
432
446
|
display_only_fail_level_offenses:
|
433
447
|
['Only output offense messages at',
|
434
448
|
'the specified --fail-level or above'],
|
data/lib/rubocop/result_cache.rb
CHANGED
@@ -33,7 +33,7 @@ module RuboCop
|
|
33
33
|
|
34
34
|
def requires_file_removal?(file_count, config_store)
|
35
35
|
file_count > 1 &&
|
36
|
-
file_count > config_store.
|
36
|
+
file_count > config_store.for_dir('.').for_all_cops['MaxFilesInCache']
|
37
37
|
end
|
38
38
|
|
39
39
|
def remove_oldest_files(files, dirs, cache_root, verbose)
|
@@ -60,7 +60,7 @@ module RuboCop
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def self.cache_root(config_store)
|
63
|
-
root = config_store.
|
63
|
+
root = config_store.for_dir('.').for_all_cops['CacheRootDirectory']
|
64
64
|
root ||= if ENV.key?('XDG_CACHE_HOME')
|
65
65
|
# Include user ID in the path to make sure the user has write
|
66
66
|
# access.
|
@@ -72,7 +72,7 @@ module RuboCop
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def self.allow_symlinks_in_cache_location?(config_store)
|
75
|
-
config_store.
|
75
|
+
config_store.for_dir('.').for_all_cops['AllowSymlinksInCacheRootDirectory']
|
76
76
|
end
|
77
77
|
|
78
78
|
def initialize(file, team, options, config_store, cache_root = nil)
|
@@ -143,7 +143,7 @@ module RuboCop
|
|
143
143
|
digester = Digest::SHA1.new
|
144
144
|
mode = File.stat(file).mode
|
145
145
|
digester.update(
|
146
|
-
"#{file}#{mode}#{config_store.
|
146
|
+
"#{file}#{mode}#{config_store.for_file(file).signature}"
|
147
147
|
)
|
148
148
|
digester.file(file)
|
149
149
|
digester.hexdigest
|
@@ -48,30 +48,9 @@ module CopHelper
|
|
48
48
|
corrector.rewrite
|
49
49
|
end
|
50
50
|
|
51
|
-
def autocorrect_source_with_loop(source, file = nil)
|
52
|
-
cnt = 0
|
53
|
-
loop do
|
54
|
-
cop.instance_variable_set(:@corrections, [])
|
55
|
-
new_source = autocorrect_source(source, file)
|
56
|
-
return new_source if new_source == source
|
57
|
-
|
58
|
-
source = new_source
|
59
|
-
cnt += 1
|
60
|
-
raise RuboCop::Runner::InfiniteCorrectionLoop.new(file, []) if cnt > RuboCop::Runner::MAX_ITERATIONS
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
51
|
def _investigate(cop, processed_source)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
instances << klass.new([cop])
|
69
|
-
end
|
70
|
-
|
71
|
-
commissioner =
|
72
|
-
RuboCop::Cop::Commissioner.new([cop], forces, raise_error: true)
|
73
|
-
commissioner.investigate(processed_source)
|
74
|
-
commissioner
|
52
|
+
team = RuboCop::Cop::Team.new([cop], nil, raise_error: true)
|
53
|
+
team.inspect_file(processed_source)
|
75
54
|
end
|
76
55
|
end
|
77
56
|
|