rubocop 1.76.0 → 1.77.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 +4 -4
- data/README.md +2 -2
- data/config/default.yml +24 -2
- data/lib/rubocop/cop/correctors/parentheses_corrector.rb +5 -2
- data/lib/rubocop/cop/gemspec/attribute_assignment.rb +91 -0
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +0 -22
- data/lib/rubocop/cop/gemspec/require_mfa.rb +15 -1
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +4 -4
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +1 -1
- data/lib/rubocop/cop/layout/line_length.rb +26 -5
- data/lib/rubocop/cop/layout/space_before_brackets.rb +2 -9
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +7 -2
- data/lib/rubocop/cop/lint/ambiguous_range.rb +5 -0
- data/lib/rubocop/cop/lint/empty_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/float_comparison.rb +4 -4
- data/lib/rubocop/cop/lint/literal_as_condition.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +1 -1
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +4 -4
- data/lib/rubocop/cop/lint/self_assignment.rb +25 -0
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +29 -4
- data/lib/rubocop/cop/lint/useless_default_value_argument.rb +4 -1
- data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +3 -3
- data/lib/rubocop/cop/mixin/alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -1
- data/lib/rubocop/cop/mixin/gemspec_help.rb +22 -0
- data/lib/rubocop/cop/mixin/line_length_help.rb +24 -8
- data/lib/rubocop/cop/naming/file_name.rb +2 -2
- data/lib/rubocop/cop/naming/predicate_method.rb +74 -9
- data/lib/rubocop/cop/naming/predicate_prefix.rb +2 -2
- data/lib/rubocop/cop/style/case_like_if.rb +1 -1
- data/lib/rubocop/cop/style/collection_querying.rb +167 -0
- data/lib/rubocop/cop/style/conditional_assignment.rb +3 -1
- data/lib/rubocop/cop/style/exponential_notation.rb +2 -2
- data/lib/rubocop/cop/style/fetch_env_var.rb +32 -6
- data/lib/rubocop/cop/style/hash_conversion.rb +12 -3
- data/lib/rubocop/cop/style/if_unless_modifier.rb +11 -2
- data/lib/rubocop/cop/style/it_block_parameter.rb +2 -2
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/min_max_comparison.rb +13 -5
- data/lib/rubocop/cop/style/redundant_array_flatten.rb +3 -1
- data/lib/rubocop/cop/style/redundant_interpolation.rb +1 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +12 -2
- data/lib/rubocop/cop/style/redundant_self.rb +8 -5
- data/lib/rubocop/cop/style/safe_navigation.rb +14 -4
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +2 -1
- data/lib/rubocop/cop/style/symbol_proc.rb +1 -1
- data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
- data/lib/rubocop/formatter/fuubar_style_formatter.rb +1 -1
- data/lib/rubocop/formatter/offense_count_formatter.rb +1 -1
- data/lib/rubocop/lsp/diagnostic.rb +4 -4
- data/lib/rubocop/rspec/expect_offense.rb +9 -3
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +2 -0
- data/lib/ruby_lsp/rubocop/addon.rb +2 -2
- metadata +8 -6
@@ -9,7 +9,20 @@ module RuboCop
|
|
9
9
|
# On the other hand, `ENV.fetch` raises `KeyError` or returns the explicitly
|
10
10
|
# specified default value.
|
11
11
|
#
|
12
|
-
# @example
|
12
|
+
# @example DefaultToNil: true (default)
|
13
|
+
# # bad
|
14
|
+
# ENV['X']
|
15
|
+
# x = ENV['X']
|
16
|
+
#
|
17
|
+
# # good
|
18
|
+
# ENV.fetch('X', nil)
|
19
|
+
# x = ENV.fetch('X', nil)
|
20
|
+
#
|
21
|
+
# # also good
|
22
|
+
# !ENV['X']
|
23
|
+
# ENV['X'].some_method # (e.g. `.nil?`)
|
24
|
+
#
|
25
|
+
# @example DefaultToNil: false
|
13
26
|
# # bad
|
14
27
|
# ENV['X']
|
15
28
|
# x = ENV['X']
|
@@ -25,7 +38,8 @@ module RuboCop
|
|
25
38
|
class FetchEnvVar < Base
|
26
39
|
extend AutoCorrector
|
27
40
|
|
28
|
-
|
41
|
+
MSG_WITH_NIL = 'Use `ENV.fetch(%<key>s, nil)` instead of `ENV[%<key>s]`.'
|
42
|
+
MSG_WITHOUT_NIL = 'Use `ENV.fetch(%<key>s)` instead of `ENV[%<key>s]`.'
|
29
43
|
RESTRICT_ON_SEND = [:[]].freeze
|
30
44
|
|
31
45
|
# @!method env_with_bracket?(node)
|
@@ -37,7 +51,7 @@ module RuboCop
|
|
37
51
|
env_with_bracket?(node) do |name_node|
|
38
52
|
break unless offensive?(node)
|
39
53
|
|
40
|
-
message = format(
|
54
|
+
message = format(offense_message, key: name_node.source)
|
41
55
|
add_offense(node, message: message) do |corrector|
|
42
56
|
corrector.replace(node, new_code(name_node))
|
43
57
|
end
|
@@ -46,6 +60,14 @@ module RuboCop
|
|
46
60
|
|
47
61
|
private
|
48
62
|
|
63
|
+
def default_to_nil?
|
64
|
+
cop_config.fetch('DefaultToNil', true)
|
65
|
+
end
|
66
|
+
|
67
|
+
def offense_message
|
68
|
+
default_to_nil? ? MSG_WITH_NIL : MSG_WITHOUT_NIL
|
69
|
+
end
|
70
|
+
|
49
71
|
def allowed_var?(node)
|
50
72
|
env_key_node = node.children.last
|
51
73
|
env_key_node.str_type? && cop_config['AllowedVars'].include?(env_key_node.value)
|
@@ -53,12 +75,12 @@ module RuboCop
|
|
53
75
|
|
54
76
|
def used_as_flag?(node)
|
55
77
|
return false if node.root?
|
56
|
-
return true if used_if_condition_in_body(node)
|
78
|
+
return true if used_if_condition_in_body?(node)
|
57
79
|
|
58
80
|
node.parent.send_type? && (node.parent.prefix_bang? || node.parent.comparison_method?)
|
59
81
|
end
|
60
82
|
|
61
|
-
def used_if_condition_in_body(node)
|
83
|
+
def used_if_condition_in_body?(node)
|
62
84
|
if_node = node.ancestors.find(&:if_type?)
|
63
85
|
|
64
86
|
return false unless (condition = if_node&.condition)
|
@@ -125,7 +147,11 @@ module RuboCop
|
|
125
147
|
end
|
126
148
|
|
127
149
|
def new_code(name_node)
|
128
|
-
|
150
|
+
if default_to_nil?
|
151
|
+
"ENV.fetch(#{name_node.source}, nil)"
|
152
|
+
else
|
153
|
+
"ENV.fetch(#{name_node.source})"
|
154
|
+
end
|
129
155
|
end
|
130
156
|
end
|
131
157
|
end
|
@@ -54,7 +54,7 @@ module RuboCop
|
|
54
54
|
def_node_matcher :hash_from_array?, '(send (const {nil? cbase} :Hash) :[] ...)'
|
55
55
|
|
56
56
|
def on_send(node)
|
57
|
-
return
|
57
|
+
return if part_of_ignored_node?(node) || !hash_from_array?(node)
|
58
58
|
|
59
59
|
# There are several cases:
|
60
60
|
# If there is one argument:
|
@@ -63,11 +63,12 @@ module RuboCop
|
|
63
63
|
# If there is 0 or 2+ arguments:
|
64
64
|
# Hash[a1, a2, a3, a4] => {a1 => a2, a3 => a4}
|
65
65
|
# ...but don't suggest correction if there is odd number of them (it is a bug)
|
66
|
-
node.arguments.
|
66
|
+
node.arguments.one? ? single_argument(node) : multi_argument(node)
|
67
67
|
end
|
68
68
|
|
69
69
|
private
|
70
70
|
|
71
|
+
# rubocop:disable Metrics/MethodLength
|
71
72
|
def single_argument(node)
|
72
73
|
first_argument = node.first_argument
|
73
74
|
if first_argument.hash_type?
|
@@ -82,8 +83,11 @@ module RuboCop
|
|
82
83
|
replacement = "(#{replacement})" if requires_parens?(first_argument)
|
83
84
|
corrector.replace(node, "#{replacement}.to_h")
|
84
85
|
end
|
86
|
+
|
87
|
+
ignore_node(node)
|
85
88
|
end
|
86
89
|
end
|
90
|
+
# rubocop:enable Metrics/MethodLength
|
87
91
|
|
88
92
|
def use_zip_method_without_argument?(first_argument)
|
89
93
|
return false unless first_argument&.send_type?
|
@@ -111,7 +115,12 @@ module RuboCop
|
|
111
115
|
end
|
112
116
|
|
113
117
|
def requires_parens?(node)
|
114
|
-
|
118
|
+
if node.call_type?
|
119
|
+
return false if node.method?(:[])
|
120
|
+
return true if node.arguments.any? && !node.parenthesized?
|
121
|
+
end
|
122
|
+
|
123
|
+
node.operator_keyword?
|
115
124
|
end
|
116
125
|
|
117
126
|
def multi_argument(node)
|
@@ -223,8 +223,17 @@ module RuboCop
|
|
223
223
|
|
224
224
|
def too_long_line_based_on_allow_uri?(line)
|
225
225
|
if allow_uri?
|
226
|
-
uri_range =
|
227
|
-
return false if uri_range &&
|
226
|
+
uri_range = find_excessive_range(line, :uri)
|
227
|
+
return false if uri_range && allowed_position?(line, uri_range)
|
228
|
+
end
|
229
|
+
|
230
|
+
true
|
231
|
+
end
|
232
|
+
|
233
|
+
def too_long_line_based_on_allow_qualified_name?(line)
|
234
|
+
if allow_qualified_name?
|
235
|
+
namespace_range = find_excessive_range(line, :namespace)
|
236
|
+
return false if namespace_range && allowed_position?(line, namespace_range)
|
228
237
|
end
|
229
238
|
|
230
239
|
true
|
@@ -57,7 +57,7 @@ module RuboCop
|
|
57
57
|
|
58
58
|
MSG_USE_IT_PARAMETER = 'Use `it` block parameter.'
|
59
59
|
MSG_AVOID_IT_PARAMETER = 'Avoid using `it` block parameter.'
|
60
|
-
|
60
|
+
MSG_AVOID_IT_PARAMETER_MULTILINE = 'Avoid using `it` block parameter for multi-line blocks.'
|
61
61
|
|
62
62
|
minimum_target_ruby_version 3.4
|
63
63
|
|
@@ -96,7 +96,7 @@ module RuboCop
|
|
96
96
|
when :allow_single_line
|
97
97
|
return if node.single_line?
|
98
98
|
|
99
|
-
add_offense(node, message:
|
99
|
+
add_offense(node, message: MSG_AVOID_IT_PARAMETER_MULTILINE)
|
100
100
|
when :disallow
|
101
101
|
variables = find_block_variables(node, 'it')
|
102
102
|
|
@@ -251,7 +251,7 @@ module RuboCop
|
|
251
251
|
return false unless (last_argument = node.last_argument)
|
252
252
|
return true if last_argument.forwarded_restarg_type?
|
253
253
|
|
254
|
-
last_argument.hash_type? && last_argument.children.
|
254
|
+
last_argument.hash_type? && last_argument.children.any?(&:forwarded_kwrestarg_type?)
|
255
255
|
end
|
256
256
|
end
|
257
257
|
# rubocop:enable Metrics/ModuleLength, Metrics/CyclomaticComplexity
|
@@ -39,13 +39,21 @@ module RuboCop
|
|
39
39
|
include RangeHelp
|
40
40
|
|
41
41
|
MSG = 'Use `%<prefer>s` instead.'
|
42
|
-
|
42
|
+
GREATER_OPERATORS = %i[> >=].freeze
|
43
43
|
LESS_OPERATORS = %i[< <=].freeze
|
44
|
-
COMPARISON_OPERATORS =
|
44
|
+
COMPARISON_OPERATORS = (GREATER_OPERATORS + LESS_OPERATORS).to_set.freeze
|
45
|
+
|
46
|
+
# @!method comparison_condition(node, name)
|
47
|
+
def_node_matcher :comparison_condition, <<~PATTERN
|
48
|
+
{
|
49
|
+
(send $_lhs $COMPARISON_OPERATORS $_rhs)
|
50
|
+
(begin (send $_lhs $COMPARISON_OPERATORS $_rhs))
|
51
|
+
}
|
52
|
+
PATTERN
|
45
53
|
|
46
54
|
def on_if(node)
|
47
|
-
lhs, operator, rhs =
|
48
|
-
return unless
|
55
|
+
lhs, operator, rhs = comparison_condition(node.condition)
|
56
|
+
return unless operator
|
49
57
|
|
50
58
|
if_branch = node.if_branch
|
51
59
|
else_branch = node.else_branch
|
@@ -63,7 +71,7 @@ module RuboCop
|
|
63
71
|
|
64
72
|
def preferred_method(operator, lhs, rhs, if_branch, else_branch)
|
65
73
|
if lhs == if_branch && rhs == else_branch
|
66
|
-
|
74
|
+
GREATER_OPERATORS.include?(operator) ? 'max' : 'min'
|
67
75
|
elsif lhs == else_branch && rhs == if_branch
|
68
76
|
LESS_OPERATORS.include?(operator) ? 'max' : 'min'
|
69
77
|
end
|
@@ -12,6 +12,8 @@ module RuboCop
|
|
12
12
|
# Cop is unsafe because the receiver of `flatten` method might not
|
13
13
|
# be an `Array`, so it's possible it won't respond to `join` method,
|
14
14
|
# or the end result would be different.
|
15
|
+
# Also, if the global variable `$,` is set to a value other than the default `nil`,
|
16
|
+
# false positives may occur.
|
15
17
|
#
|
16
18
|
# @example
|
17
19
|
# # bad
|
@@ -30,7 +32,7 @@ module RuboCop
|
|
30
32
|
|
31
33
|
# @!method flatten_join?(node)
|
32
34
|
def_node_matcher :flatten_join?, <<~PATTERN
|
33
|
-
(call (call !nil? :flatten _?) :join
|
35
|
+
(call (call !nil? :flatten _?) :join (nil)?)
|
34
36
|
PATTERN
|
35
37
|
|
36
38
|
def on_send(node)
|
@@ -164,8 +164,9 @@ module RuboCop
|
|
164
164
|
if node.lambda_or_proc? && (node.braces? || node.send_node.lambda_literal?)
|
165
165
|
return 'an expression'
|
166
166
|
end
|
167
|
-
|
168
|
-
|
167
|
+
if disallowed_one_line_pattern_matching?(begin_node, node)
|
168
|
+
return 'a one-line pattern matching'
|
169
|
+
end
|
169
170
|
return 'an interpolated expression' if interpolation?(begin_node)
|
170
171
|
return 'a method argument' if argument_of_parenthesized_method_call?(begin_node, node)
|
171
172
|
|
@@ -253,6 +254,15 @@ module RuboCop
|
|
253
254
|
end
|
254
255
|
end
|
255
256
|
|
257
|
+
def disallowed_one_line_pattern_matching?(begin_node, node)
|
258
|
+
if (parent = begin_node.parent)
|
259
|
+
return false if parent.any_def_type? && parent.endless?
|
260
|
+
return false if parent.assignment?
|
261
|
+
end
|
262
|
+
|
263
|
+
node.any_match_pattern_type? && node.each_ancestor.none?(&:operator_keyword?)
|
264
|
+
end
|
265
|
+
|
256
266
|
def raised_to_power_negative_numeric?(begin_node, node)
|
257
267
|
return false unless node.numeric_type?
|
258
268
|
|
@@ -67,6 +67,9 @@ module RuboCop
|
|
67
67
|
|
68
68
|
def on_or_asgn(node)
|
69
69
|
allow_self(node.lhs)
|
70
|
+
|
71
|
+
lhs_name = node.lhs.lvasgn_type? ? node.lhs.name : node.lhs
|
72
|
+
add_lhs_to_local_variables_scopes(node.rhs, lhs_name)
|
70
73
|
end
|
71
74
|
alias on_and_asgn on_or_asgn
|
72
75
|
|
@@ -123,11 +126,11 @@ module RuboCop
|
|
123
126
|
def on_if(node)
|
124
127
|
# Allow conditional nodes to use `self` in the condition if that variable
|
125
128
|
# name is used in an `lvasgn` or `masgn` within the `if`.
|
126
|
-
node.
|
127
|
-
if
|
128
|
-
add_lhs_to_local_variables_scopes(node.condition,
|
129
|
-
|
130
|
-
add_masgn_lhs_variables(node.condition,
|
129
|
+
node.each_descendant(:lvasgn, :masgn) do |descendant_node|
|
130
|
+
if descendant_node.lvasgn_type?
|
131
|
+
add_lhs_to_local_variables_scopes(node.condition, descendant_node.lhs)
|
132
|
+
else
|
133
|
+
add_masgn_lhs_variables(node.condition, descendant_node.lhs)
|
131
134
|
end
|
132
135
|
end
|
133
136
|
end
|
@@ -86,6 +86,10 @@ module RuboCop
|
|
86
86
|
# foo.baz = bar if foo
|
87
87
|
# foo.baz + bar if foo
|
88
88
|
# foo.bar > 2 if foo
|
89
|
+
#
|
90
|
+
# foo ? foo[index] : nil # Ignored `foo&.[](index)` due to unclear readability benefit.
|
91
|
+
# foo ? foo[idx] = v : nil # Ignored `foo&.[]=(idx, v)` due to unclear readability benefit.
|
92
|
+
# foo ? foo * 42 : nil # Ignored `foo&.*(42)` due to unclear readability benefit.
|
89
93
|
class SafeNavigation < Base # rubocop:disable Metrics/ClassLength
|
90
94
|
include NilMethods
|
91
95
|
include RangeHelp
|
@@ -146,6 +150,7 @@ module RuboCop
|
|
146
150
|
|
147
151
|
body = extract_if_body(node)
|
148
152
|
method_call = receiver.parent
|
153
|
+
return if dotless_operator_call?(method_call) || method_call.double_colon?
|
149
154
|
|
150
155
|
removal_ranges = [begin_range(node, body), end_range(node, body)]
|
151
156
|
|
@@ -181,6 +186,8 @@ module RuboCop
|
|
181
186
|
end
|
182
187
|
end
|
183
188
|
|
189
|
+
private
|
190
|
+
|
184
191
|
def report_offense(node, rhs, rhs_receiver, *removal_ranges, offense_range: node)
|
185
192
|
add_offense(offense_range) do |corrector|
|
186
193
|
next if ignored_node?(node)
|
@@ -198,8 +205,6 @@ module RuboCop
|
|
198
205
|
end
|
199
206
|
end
|
200
207
|
|
201
|
-
private
|
202
|
-
|
203
208
|
def find_method_chain(node)
|
204
209
|
return node unless node&.parent&.call_type?
|
205
210
|
|
@@ -253,6 +258,12 @@ module RuboCop
|
|
253
258
|
end
|
254
259
|
end
|
255
260
|
|
261
|
+
def dotless_operator_call?(method_call)
|
262
|
+
return false if method_call.loc.dot
|
263
|
+
|
264
|
+
method_call.method?(:[]) || method_call.method?(:[]=) || method_call.operator_method?
|
265
|
+
end
|
266
|
+
|
256
267
|
def handle_comments(corrector, node, method_call)
|
257
268
|
comments = comments(node)
|
258
269
|
return if comments.empty?
|
@@ -380,8 +391,7 @@ module RuboCop
|
|
380
391
|
method_chain)
|
381
392
|
start_method.each_ancestor do |ancestor|
|
382
393
|
break unless %i[send block].include?(ancestor.type)
|
383
|
-
next
|
384
|
-
next if ancestor.safe_navigation?
|
394
|
+
next if !ancestor.send_type? || ancestor.operator_method?
|
385
395
|
|
386
396
|
corrector.insert_before(ancestor.loc.dot, '&')
|
387
397
|
|
@@ -115,8 +115,9 @@ module RuboCop
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def correct_node(corrector, node)
|
118
|
-
corrector.replace(node.loc.keyword, 'if') if node.unless?
|
118
|
+
corrector.replace(node.loc.keyword, 'if') if node.unless? && !part_of_ignored_node?(node)
|
119
119
|
corrector.replace(node.condition, chainable_condition(node))
|
120
|
+
ignore_node(node)
|
120
121
|
end
|
121
122
|
|
122
123
|
def correct_for_guard_condition_style(corrector, node, if_branch)
|
@@ -270,7 +270,7 @@ module RuboCop
|
|
270
270
|
end
|
271
271
|
|
272
272
|
def allow_if_method_has_argument?(send_node)
|
273
|
-
!!cop_config.fetch('AllowMethodsWithArguments', false) &&
|
273
|
+
!!cop_config.fetch('AllowMethodsWithArguments', false) && send_node.arguments.any?
|
274
274
|
end
|
275
275
|
|
276
276
|
def allow_comments?
|
@@ -79,7 +79,7 @@ module RuboCop
|
|
79
79
|
LanguageServer::Protocol::Interface::CodeDescription.new(href: doc_url)
|
80
80
|
end
|
81
81
|
|
82
|
-
# rubocop:disable
|
82
|
+
# rubocop:disable Metrics/MethodLength
|
83
83
|
def autocorrect_action
|
84
84
|
LanguageServer::Protocol::Interface::CodeAction.new(
|
85
85
|
title: "Autocorrect #{@offense.cop_name}",
|
@@ -98,7 +98,7 @@ module RuboCop
|
|
98
98
|
is_preferred: true
|
99
99
|
)
|
100
100
|
end
|
101
|
-
# rubocop:enable
|
101
|
+
# rubocop:enable Metrics/MethodLength
|
102
102
|
|
103
103
|
# rubocop:disable Metrics/MethodLength
|
104
104
|
def offense_replacements
|
@@ -120,7 +120,7 @@ module RuboCop
|
|
120
120
|
end
|
121
121
|
# rubocop:enable Metrics/MethodLength
|
122
122
|
|
123
|
-
# rubocop:disable
|
123
|
+
# rubocop:disable Metrics/MethodLength
|
124
124
|
def disable_line_action
|
125
125
|
LanguageServer::Protocol::Interface::CodeAction.new(
|
126
126
|
title: "Disable #{@offense.cop_name} for this line",
|
@@ -138,7 +138,7 @@ module RuboCop
|
|
138
138
|
)
|
139
139
|
)
|
140
140
|
end
|
141
|
-
# rubocop:enable
|
141
|
+
# rubocop:enable Metrics/MethodLength
|
142
142
|
|
143
143
|
def line_disable_comment
|
144
144
|
new_text = if @offense.source_line.include?(' # rubocop:disable ')
|
@@ -72,9 +72,15 @@ module RuboCop
|
|
72
72
|
#
|
73
73
|
# expect_no_corrections
|
74
74
|
#
|
75
|
-
# If your code has variables of different lengths, you can use
|
76
|
-
#
|
77
|
-
#
|
75
|
+
# If your code has variables of different lengths, you can use the
|
76
|
+
# following markers to format your template by passing the variables as a
|
77
|
+
# keyword arguments:
|
78
|
+
#
|
79
|
+
# - `%{foo}`: Interpolates `foo`
|
80
|
+
# - `^{foo}`: Inserts `'^' * foo.size` for dynamic offense range length
|
81
|
+
# - `_{foo}`: Inserts `' ' * foo.size` for dynamic offense range indentation
|
82
|
+
#
|
83
|
+
# You can also abbreviate offense messages with `[...]`.
|
78
84
|
#
|
79
85
|
# %w[raise fail].each do |keyword|
|
80
86
|
# expect_offense(<<~RUBY, keyword: keyword)
|
data/lib/rubocop/version.rb
CHANGED
data/lib/rubocop.rb
CHANGED
@@ -180,6 +180,7 @@ require_relative 'rubocop/cop/bundler/insecure_protocol_source'
|
|
180
180
|
require_relative 'rubocop/cop/bundler/ordered_gems'
|
181
181
|
|
182
182
|
require_relative 'rubocop/cop/gemspec/add_runtime_dependency'
|
183
|
+
require_relative 'rubocop/cop/gemspec/attribute_assignment'
|
183
184
|
require_relative 'rubocop/cop/gemspec/dependency_version'
|
184
185
|
require_relative 'rubocop/cop/gemspec/deprecated_attribute_assignment'
|
185
186
|
require_relative 'rubocop/cop/gemspec/development_dependencies'
|
@@ -507,6 +508,7 @@ require_relative 'rubocop/cop/style/class_methods_definitions'
|
|
507
508
|
require_relative 'rubocop/cop/style/class_vars'
|
508
509
|
require_relative 'rubocop/cop/style/collection_compact'
|
509
510
|
require_relative 'rubocop/cop/style/collection_methods'
|
511
|
+
require_relative 'rubocop/cop/style/collection_querying'
|
510
512
|
require_relative 'rubocop/cop/style/colon_method_call'
|
511
513
|
require_relative 'rubocop/cop/style/colon_method_definition'
|
512
514
|
require_relative 'rubocop/cop/style/combinable_defined'
|
@@ -34,7 +34,7 @@ module RubyLsp
|
|
34
34
|
@runtime_adapter = nil
|
35
35
|
end
|
36
36
|
|
37
|
-
# rubocop:disable
|
37
|
+
# rubocop:disable Metrics/MethodLength
|
38
38
|
def register_additional_file_watchers(global_state, message_queue)
|
39
39
|
return unless global_state.supports_watching_files
|
40
40
|
|
@@ -59,7 +59,7 @@ module RubyLsp
|
|
59
59
|
)
|
60
60
|
)
|
61
61
|
end
|
62
|
-
# rubocop:enable
|
62
|
+
# rubocop:enable Metrics/MethodLength
|
63
63
|
|
64
64
|
def workspace_did_change_watched_files(changes)
|
65
65
|
return unless changes.any? { |change| change[:uri].end_with?('.rubocop.yml') }
|
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: 1.
|
4
|
+
version: 1.77.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
- Yuji Nakayama
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-06-
|
12
|
+
date: 2025-06-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -127,7 +127,7 @@ dependencies:
|
|
127
127
|
requirements:
|
128
128
|
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: 1.45.
|
130
|
+
version: 1.45.1
|
131
131
|
- - "<"
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '2.0'
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
requirements:
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
version: 1.45.
|
140
|
+
version: 1.45.1
|
141
141
|
- - "<"
|
142
142
|
- !ruby/object:Gem::Version
|
143
143
|
version: '2.0'
|
@@ -265,6 +265,7 @@ files:
|
|
265
265
|
- lib/rubocop/cop/exclude_limit.rb
|
266
266
|
- lib/rubocop/cop/force.rb
|
267
267
|
- lib/rubocop/cop/gemspec/add_runtime_dependency.rb
|
268
|
+
- lib/rubocop/cop/gemspec/attribute_assignment.rb
|
268
269
|
- lib/rubocop/cop/gemspec/dependency_version.rb
|
269
270
|
- lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb
|
270
271
|
- lib/rubocop/cop/gemspec/development_dependencies.rb
|
@@ -727,6 +728,7 @@ files:
|
|
727
728
|
- lib/rubocop/cop/style/class_vars.rb
|
728
729
|
- lib/rubocop/cop/style/collection_compact.rb
|
729
730
|
- lib/rubocop/cop/style/collection_methods.rb
|
731
|
+
- lib/rubocop/cop/style/collection_querying.rb
|
730
732
|
- lib/rubocop/cop/style/colon_method_call.rb
|
731
733
|
- lib/rubocop/cop/style/colon_method_definition.rb
|
732
734
|
- lib/rubocop/cop/style/combinable_defined.rb
|
@@ -1085,9 +1087,9 @@ licenses:
|
|
1085
1087
|
- MIT
|
1086
1088
|
metadata:
|
1087
1089
|
homepage_uri: https://rubocop.org/
|
1088
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.
|
1090
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.77.0
|
1089
1091
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1090
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
1092
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.77/
|
1091
1093
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
1092
1094
|
rubygems_mfa_required: 'true'
|
1093
1095
|
rdoc_options: []
|