rubocop 1.65.0 → 1.65.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/cop/cop.rb +2 -2
- data/lib/rubocop/cop/layout/assignment_indentation.rb +3 -2
- data/lib/rubocop/cop/layout/condition_position.rb +0 -4
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +0 -2
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +0 -2
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +0 -2
- data/lib/rubocop/cop/lint/boolean_symbol.rb +0 -2
- data/lib/rubocop/cop/lint/circular_argument_reference.rb +0 -13
- data/lib/rubocop/cop/lint/debugger.rb +0 -4
- data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +0 -10
- data/lib/rubocop/cop/lint/duplicate_case_condition.rb +0 -4
- data/lib/rubocop/cop/lint/duplicate_hash_key.rb +0 -4
- data/lib/rubocop/cop/lint/duplicate_methods.rb +0 -10
- data/lib/rubocop/cop/lint/each_with_object_argument.rb +0 -4
- data/lib/rubocop/cop/lint/else_layout.rb +0 -2
- data/lib/rubocop/cop/lint/empty_ensure.rb +1 -11
- data/lib/rubocop/cop/lint/empty_interpolation.rb +0 -4
- data/lib/rubocop/cop/lint/empty_when.rb +0 -2
- data/lib/rubocop/cop/lint/ensure_return.rb +1 -6
- data/lib/rubocop/cop/lint/float_comparison.rb +3 -1
- data/lib/rubocop/cop/lint/float_out_of_range.rb +0 -4
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +0 -10
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -5
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +0 -7
- data/lib/rubocop/cop/lint/interpolation_check.rb +0 -4
- data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +0 -4
- data/lib/rubocop/cop/lint/loop.rb +6 -12
- data/lib/rubocop/cop/lint/nested_method_definition.rb +0 -6
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +0 -4
- data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +0 -5
- data/lib/rubocop/cop/lint/percent_string_array.rb +0 -4
- data/lib/rubocop/cop/lint/percent_symbol_array.rb +0 -4
- data/lib/rubocop/cop/lint/rand_one.rb +0 -4
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +3 -1
- data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +0 -4
- data/lib/rubocop/cop/lint/require_parentheses.rb +0 -4
- data/lib/rubocop/cop/lint/rescue_exception.rb +0 -4
- data/lib/rubocop/cop/lint/return_in_void_context.rb +0 -2
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +0 -4
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +6 -10
- data/lib/rubocop/cop/lint/unified_integer.rb +0 -4
- data/lib/rubocop/cop/lint/unreachable_code.rb +0 -5
- data/lib/rubocop/cop/lint/useless_assignment.rb +1 -5
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +0 -4
- data/lib/rubocop/cop/lint/useless_setter_call.rb +0 -4
- data/lib/rubocop/cop/naming/predicate_name.rb +52 -26
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +10 -1
- data/lib/rubocop/cop/style/def_with_parentheses.rb +0 -2
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +0 -1
- data/lib/rubocop/cop/style/eval_with_location.rb +12 -11
- data/lib/rubocop/cop/style/file_read.rb +2 -5
- data/lib/rubocop/cop/style/file_write.rb +2 -5
- data/lib/rubocop/cop/style/global_std_stream.rb +7 -1
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +0 -1
- data/lib/rubocop/cop/style/invertible_unless_condition.rb +2 -2
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/missing_else.rb +0 -4
- data/lib/rubocop/cop/style/multiline_when_then.rb +0 -4
- data/lib/rubocop/cop/style/redundant_condition.rb +0 -1
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +8 -24
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +21 -2
- data/lib/rubocop/cop/style/while_until_do.rb +0 -2
- data/lib/rubocop/cop/style/while_until_modifier.rb +0 -1
- data/lib/rubocop/cop/style/zero_length_predicate.rb +5 -1
- data/lib/rubocop/cop/variable_force.rb +13 -1
- data/lib/rubocop/core_ext/string.rb +2 -6
- data/lib/rubocop/ext/regexp_node.rb +9 -31
- data/lib/rubocop/options.rb +3 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +5 -0
- metadata +7 -7
@@ -159,7 +159,13 @@ module RuboCop
|
|
159
159
|
node_to_check = condition&.block_type? ? condition.send_node : condition
|
160
160
|
return unless wrap_condition?(node_to_check)
|
161
161
|
|
162
|
-
|
162
|
+
if condition.call_type?
|
163
|
+
source = parenthesized_method_arguments(condition)
|
164
|
+
|
165
|
+
corrector.replace(condition, source)
|
166
|
+
else
|
167
|
+
corrector.wrap(condition, '(', ')')
|
168
|
+
end
|
163
169
|
end
|
164
170
|
|
165
171
|
def correct_for_outer_condition_modify_form_style(corrector, node, if_branch)
|
@@ -236,7 +242,20 @@ module RuboCop
|
|
236
242
|
end
|
237
243
|
|
238
244
|
def replace_condition(condition)
|
239
|
-
|
245
|
+
return condition.source unless wrap_condition?(condition)
|
246
|
+
|
247
|
+
if condition.call_type?
|
248
|
+
parenthesized_method_arguments(condition)
|
249
|
+
else
|
250
|
+
"(#{condition.source})"
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
def parenthesized_method_arguments(node)
|
255
|
+
method_call = node.source_range.begin.join(node.loc.selector.end).source
|
256
|
+
arguments = node.first_argument.source_range.begin.join(node.source_range.end).source
|
257
|
+
|
258
|
+
"#{method_call}(#{arguments})"
|
240
259
|
end
|
241
260
|
|
242
261
|
def allow_modifier?
|
@@ -27,7 +27,10 @@ module RuboCop
|
|
27
27
|
class VariableForce < Force # rubocop:disable Metrics/ClassLength
|
28
28
|
VARIABLE_ASSIGNMENT_TYPE = :lvasgn
|
29
29
|
REGEXP_NAMED_CAPTURE_TYPE = :match_with_lvasgn
|
30
|
-
|
30
|
+
PATTERN_MATCH_VARIABLE_TYPE = :match_var
|
31
|
+
VARIABLE_ASSIGNMENT_TYPES = [
|
32
|
+
VARIABLE_ASSIGNMENT_TYPE, REGEXP_NAMED_CAPTURE_TYPE, PATTERN_MATCH_VARIABLE_TYPE
|
33
|
+
].freeze
|
31
34
|
|
32
35
|
ARGUMENT_DECLARATION_TYPES = [
|
33
36
|
:arg, :optarg, :restarg,
|
@@ -112,6 +115,7 @@ module RuboCop
|
|
112
115
|
NODE_HANDLER_METHOD_NAMES = [
|
113
116
|
[VARIABLE_ASSIGNMENT_TYPE, :process_variable_assignment],
|
114
117
|
[REGEXP_NAMED_CAPTURE_TYPE, :process_regexp_named_captures],
|
118
|
+
[PATTERN_MATCH_VARIABLE_TYPE, :process_pattern_match_variable],
|
115
119
|
[MULTIPLE_ASSIGNMENT_TYPE, :process_variable_multiple_assignment],
|
116
120
|
[VARIABLE_REFERENCE_TYPE, :process_variable_referencing],
|
117
121
|
[RESCUE_TYPE, :process_rescue],
|
@@ -175,6 +179,14 @@ module RuboCop
|
|
175
179
|
skip_children!
|
176
180
|
end
|
177
181
|
|
182
|
+
def process_pattern_match_variable(node)
|
183
|
+
name = node.children.first
|
184
|
+
|
185
|
+
variable_table.declare_variable(name, node) unless variable_table.variable_exist?(name)
|
186
|
+
|
187
|
+
skip_children!
|
188
|
+
end
|
189
|
+
|
178
190
|
def regexp_captured_names(node)
|
179
191
|
regexp = node.to_regexp
|
180
192
|
|
@@ -9,12 +9,8 @@ class String
|
|
9
9
|
# @return [Boolean] true is the string is blank, false otherwise
|
10
10
|
#
|
11
11
|
# @example
|
12
|
-
# ''.blank?
|
13
|
-
#
|
14
|
-
# @example
|
15
|
-
# ' '.blank? #=> true
|
16
|
-
#
|
17
|
-
# @example
|
12
|
+
# ''.blank? #=> true
|
13
|
+
# ' '.blank? #=> true
|
18
14
|
# ' test'.blank? #=> false
|
19
15
|
def blank?
|
20
16
|
empty? || lstrip.empty?
|
@@ -15,39 +15,17 @@ module RuboCop
|
|
15
15
|
# see `ext/regexp_parser`.
|
16
16
|
attr_reader :parsed_tree
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
super
|
18
|
+
def assign_properties(*)
|
19
|
+
super
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
origin = loc.begin.end
|
29
|
-
@parsed_tree&.each_expression(true) { |e| e.origin = origin }
|
30
|
-
end
|
31
|
-
# Please remove this `else` branch when support for regexp_parser 1.8 will be dropped.
|
32
|
-
# It's for compatibility with regexp_parser 1.8 and will never be maintained.
|
33
|
-
else
|
34
|
-
def assign_properties(*)
|
35
|
-
super
|
36
|
-
|
37
|
-
str = with_interpolations_blanked
|
38
|
-
begin
|
39
|
-
@parsed_tree = Regexp::Parser.parse(str, options: options)
|
40
|
-
rescue StandardError
|
41
|
-
@parsed_tree = nil
|
42
|
-
else
|
43
|
-
origin = loc.begin.end
|
44
|
-
source = @parsed_tree.to_s
|
45
|
-
@parsed_tree.each_expression(true) do |e|
|
46
|
-
e.origin = origin
|
47
|
-
e.source = source
|
48
|
-
end
|
49
|
-
end
|
21
|
+
str = with_interpolations_blanked
|
22
|
+
@parsed_tree = begin
|
23
|
+
Regexp::Parser.parse(str, options: options)
|
24
|
+
rescue StandardError
|
25
|
+
nil
|
50
26
|
end
|
27
|
+
origin = loc.begin.end
|
28
|
+
@parsed_tree&.each_expression(true) { |e| e.origin = origin }
|
51
29
|
end
|
52
30
|
|
53
31
|
def each_capture(named: ANY)
|
data/lib/rubocop/options.rb
CHANGED
@@ -615,7 +615,9 @@ module RuboCop
|
|
615
615
|
version: 'Display version.',
|
616
616
|
verbose_version: 'Display verbose version.',
|
617
617
|
parallel: ['Use available CPUs to execute inspection in',
|
618
|
-
'parallel. Default is true.'
|
618
|
+
'parallel. Default is true.',
|
619
|
+
'You can specify the number of parallel processes using',
|
620
|
+
'the $PARALLEL_PROCESSOR_COUNT environment variable.'],
|
619
621
|
stdin: ['Pipe source from STDIN, using FILE in offense',
|
620
622
|
'reports. This is useful for editor integration.'],
|
621
623
|
editor_mode: ['Optimize real-time feedback in editors,',
|
data/lib/rubocop/version.rb
CHANGED
data/lib/rubocop.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.65.
|
4
|
+
version: 1.65.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
8
8
|
- Jonas Arvidsson
|
9
9
|
- Yuji Nakayama
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-08-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -1035,12 +1035,12 @@ licenses:
|
|
1035
1035
|
- MIT
|
1036
1036
|
metadata:
|
1037
1037
|
homepage_uri: https://rubocop.org/
|
1038
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.65.
|
1038
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.65.1
|
1039
1039
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1040
1040
|
documentation_uri: https://docs.rubocop.org/rubocop/1.65/
|
1041
1041
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
1042
1042
|
rubygems_mfa_required: 'true'
|
1043
|
-
post_install_message:
|
1043
|
+
post_install_message:
|
1044
1044
|
rdoc_options: []
|
1045
1045
|
require_paths:
|
1046
1046
|
- lib
|
@@ -1055,8 +1055,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1055
1055
|
- !ruby/object:Gem::Version
|
1056
1056
|
version: '0'
|
1057
1057
|
requirements: []
|
1058
|
-
rubygems_version: 3.
|
1059
|
-
signing_key:
|
1058
|
+
rubygems_version: 3.3.7
|
1059
|
+
signing_key:
|
1060
1060
|
specification_version: 4
|
1061
1061
|
summary: Automatic Ruby code style checking tool.
|
1062
1062
|
test_files: []
|