rubocop 1.71.0 → 1.71.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/autocorrect_logic.rb +1 -1
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_processor.rb +63 -0
- data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb +131 -0
- data/lib/rubocop/cop/internal_affairs/node_pattern_groups.rb +229 -0
- data/lib/rubocop/cop/internal_affairs/node_type_multiple_predicates.rb +126 -0
- data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +1 -0
- data/lib/rubocop/cop/internal_affairs.rb +2 -0
- data/lib/rubocop/cop/layout/access_modifier_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/block_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/class_structure.rb +2 -2
- data/lib/rubocop/cop/layout/dot_position.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +7 -5
- data/lib/rubocop/cop/layout/end_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/first_parameter_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/redundant_line_break.rb +6 -5
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/single_line_block_chain.rb +1 -1
- data/lib/rubocop/cop/layout/space_after_colon.rb +2 -2
- data/lib/rubocop/cop/layout/space_after_comma.rb +1 -1
- data/lib/rubocop/cop/layout/space_after_semicolon.rb +1 -1
- data/lib/rubocop/cop/layout/space_before_comma.rb +1 -1
- data/lib/rubocop/cop/layout/space_before_semicolon.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +1 -3
- data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +1 -1
- data/lib/rubocop/cop/lint/constant_definition_in_block.rb +3 -3
- data/lib/rubocop/cop/lint/constant_reassignment.rb +2 -6
- data/lib/rubocop/cop/lint/debugger.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +1 -1
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +1 -1
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/missing_super.rb +2 -2
- data/lib/rubocop/cop/lint/nested_method_definition.rb +3 -3
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +1 -1
- data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +1 -1
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -5
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +1 -1
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +1 -1
- data/lib/rubocop/cop/lint/suppressed_exception.rb +1 -1
- data/lib/rubocop/cop/lint/symbol_conversion.rb +1 -1
- data/lib/rubocop/cop/lint/unexpected_block_arity.rb +1 -1
- data/lib/rubocop/cop/lint/unreachable_code.rb +1 -1
- data/lib/rubocop/cop/lint/unreachable_loop.rb +1 -1
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +4 -4
- data/lib/rubocop/cop/lint/useless_method_definition.rb +1 -1
- data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +2 -2
- data/lib/rubocop/cop/lint/void.rb +1 -1
- data/lib/rubocop/cop/metrics/block_nesting.rb +1 -1
- data/lib/rubocop/cop/metrics/module_length.rb +1 -1
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +5 -5
- data/lib/rubocop/cop/mixin/comments_help.rb +1 -1
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +4 -4
- data/lib/rubocop/cop/mixin/hash_subset.rb +19 -1
- data/lib/rubocop/cop/mixin/method_complexity.rb +1 -1
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +22 -8
- data/lib/rubocop/cop/mixin/string_help.rb +1 -1
- data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
- data/lib/rubocop/cop/naming/block_forwarding.rb +18 -14
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +3 -3
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +2 -4
- data/lib/rubocop/cop/style/arguments_forwarding.rb +38 -19
- data/lib/rubocop/cop/style/block_delimiters.rb +1 -1
- data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
- data/lib/rubocop/cop/style/combinable_defined.rb +1 -1
- data/lib/rubocop/cop/style/combinable_loops.rb +2 -2
- data/lib/rubocop/cop/style/concat_array_literals.rb +1 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +3 -3
- data/lib/rubocop/cop/style/documentation.rb +1 -1
- data/lib/rubocop/cop/style/double_negation.rb +3 -3
- data/lib/rubocop/cop/style/eval_with_location.rb +1 -1
- data/lib/rubocop/cop/style/explicit_block_argument.rb +1 -1
- data/lib/rubocop/cop/style/hash_each_methods.rb +2 -5
- data/lib/rubocop/cop/style/hash_except.rb +15 -0
- data/lib/rubocop/cop/style/hash_slice.rb +15 -0
- data/lib/rubocop/cop/style/hash_syntax.rb +1 -1
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +22 -3
- data/lib/rubocop/cop/style/if_unless_modifier.rb +3 -3
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +1 -1
- data/lib/rubocop/cop/style/if_with_semicolon.rb +2 -2
- data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
- data/lib/rubocop/cop/style/inverse_methods.rb +6 -6
- data/lib/rubocop/cop/style/it_assignment.rb +1 -1
- data/lib/rubocop/cop/style/keyword_parameters_order.rb +1 -1
- data/lib/rubocop/cop/style/map_into_array.rb +1 -1
- data/lib/rubocop/cop/style/map_to_hash.rb +1 -1
- data/lib/rubocop/cop/style/map_to_set.rb +1 -1
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +10 -13
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +2 -4
- data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/multiline_block_chain.rb +1 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +1 -1
- data/lib/rubocop/cop/style/negated_if_else_condition.rb +1 -1
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +1 -1
- data/lib/rubocop/cop/style/open_struct_use.rb +1 -1
- data/lib/rubocop/cop/style/parallel_assignment.rb +1 -5
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +2 -2
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
- data/lib/rubocop/cop/style/proc.rb +1 -2
- data/lib/rubocop/cop/style/redundant_begin.rb +1 -1
- data/lib/rubocop/cop/style/redundant_condition.rb +2 -2
- data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +6 -10
- data/lib/rubocop/cop/style/redundant_each.rb +1 -1
- data/lib/rubocop/cop/style/redundant_exception.rb +1 -1
- data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +6 -6
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +12 -27
- data/lib/rubocop/cop/style/redundant_sort.rb +2 -2
- data/lib/rubocop/cop/style/redundant_string_escape.rb +2 -2
- data/lib/rubocop/cop/style/return_nil.rb +1 -1
- data/lib/rubocop/cop/style/safe_navigation.rb +1 -1
- data/lib/rubocop/cop/style/semicolon.rb +1 -1
- data/lib/rubocop/cop/style/single_line_methods.rb +1 -1
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +1 -1
- data/lib/rubocop/cop/style/string_concatenation.rb +1 -1
- data/lib/rubocop/cop/style/string_literals.rb +1 -1
- data/lib/rubocop/cop/style/super_arguments.rb +4 -4
- data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/top_level_method_definition.rb +1 -1
- data/lib/rubocop/cop/style/yoda_expression.rb +1 -1
- data/lib/rubocop/cop/util.rb +2 -2
- data/lib/rubocop/cop/variable_force/variable.rb +1 -1
- data/lib/rubocop/cop/variable_force/variable_table.rb +3 -3
- data/lib/rubocop/rspec/support.rb +1 -2
- data/lib/rubocop/version.rb +1 -1
- metadata +9 -6
- data/lib/rubocop/rspec/host_environment_simulation_helper.rb +0 -28
@@ -312,7 +312,7 @@ module RuboCop
|
|
312
312
|
end
|
313
313
|
|
314
314
|
def chain_length(method_chain, method)
|
315
|
-
method.each_ancestor(:
|
315
|
+
method.each_ancestor(:call).inject(0) do |total, ancestor|
|
316
316
|
break total + 1 if ancestor == method_chain
|
317
317
|
|
318
318
|
total + 1
|
@@ -68,7 +68,7 @@ module RuboCop
|
|
68
68
|
return false if body_node.parent.assignment_method? ||
|
69
69
|
NOT_SUPPORTED_ENDLESS_METHOD_BODY_TYPES.include?(body_node.type)
|
70
70
|
|
71
|
-
!
|
71
|
+
!body_node.type?(:begin, :kwbegin)
|
72
72
|
end
|
73
73
|
|
74
74
|
def correct_to_multiline(corrector, node)
|
@@ -156,7 +156,7 @@ module RuboCop
|
|
156
156
|
# Handle `send` and `block` nodes that need to be wrapped in parens
|
157
157
|
# FIXME: autocorrection prevents syntax errors by wrapping the entire node in parens,
|
158
158
|
# but wrapping the argument list would be a more ergonomic correction.
|
159
|
-
node_to_check = condition&.
|
159
|
+
node_to_check = condition&.any_block_type? ? condition.send_node : condition
|
160
160
|
return unless wrap_condition?(node_to_check)
|
161
161
|
|
162
162
|
if condition.call_type?
|
@@ -98,7 +98,7 @@ module RuboCop
|
|
98
98
|
# When defining dynamic methods, implicitly calling `super` is not possible.
|
99
99
|
# Since there is a possibility of delegation to `define_method`,
|
100
100
|
# `super` used within the block is always allowed.
|
101
|
-
break if node.
|
101
|
+
break if node.any_block_type? && !block_sends_to_super?(super_node, node)
|
102
102
|
|
103
103
|
break node if DEF_TYPES.include?(node.type)
|
104
104
|
end
|
@@ -136,13 +136,13 @@ module RuboCop
|
|
136
136
|
# Checks if the send node of a block is the given super node,
|
137
137
|
# or a method chain containing it.
|
138
138
|
return false unless parent_node
|
139
|
-
return false unless parent_node.
|
139
|
+
return false unless parent_node.any_block_type?
|
140
140
|
|
141
141
|
parent_node.send_node.each_node(:super).any?(super_node)
|
142
142
|
end
|
143
143
|
|
144
144
|
def positional_arg_same?(def_arg, super_arg)
|
145
|
-
return false unless def_arg.
|
145
|
+
return false unless def_arg.type?(:arg, :optarg)
|
146
146
|
return false unless super_arg.lvar_type?
|
147
147
|
|
148
148
|
def_arg.name == super_arg.children.first
|
@@ -159,7 +159,7 @@ module RuboCop
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def keyword_arg_same?(def_arg, super_arg)
|
162
|
-
return false unless def_arg.
|
162
|
+
return false unless def_arg.type?(:kwarg, :kwoptarg)
|
163
163
|
return false unless (pair_node = super_arg).pair_type?
|
164
164
|
return false unless (sym_node = pair_node.key).sym_type?
|
165
165
|
return false unless (lvar_node = pair_node.value).lvar_type?
|
data/lib/rubocop/cop/util.rb
CHANGED
@@ -74,9 +74,9 @@ module RuboCop
|
|
74
74
|
|
75
75
|
def args_begin(node)
|
76
76
|
loc = node.loc
|
77
|
-
selector = if node.
|
77
|
+
selector = if node.type?(:super, :yield)
|
78
78
|
loc.keyword
|
79
|
-
elsif node.
|
79
|
+
elsif node.type?(:def, :defs)
|
80
80
|
loc.name
|
81
81
|
else
|
82
82
|
loc.selector
|
@@ -72,7 +72,7 @@ module RuboCop
|
|
72
72
|
parent = parent.parent if parent&.begin_type?
|
73
73
|
return false if parent.nil?
|
74
74
|
|
75
|
-
|
75
|
+
parent.type?(:if, :while, :until) && parent.modifier_form?
|
76
76
|
end
|
77
77
|
|
78
78
|
def capture_with_block!
|
@@ -100,7 +100,7 @@ module RuboCop
|
|
100
100
|
|
101
101
|
# Only block scope allows referencing outer scope variables.
|
102
102
|
node = scope.node
|
103
|
-
return nil unless node.
|
103
|
+
return nil unless node.any_block_type?
|
104
104
|
end
|
105
105
|
|
106
106
|
nil
|
@@ -113,14 +113,14 @@ module RuboCop
|
|
113
113
|
def accessible_variables
|
114
114
|
scope_stack.reverse_each.with_object([]) do |scope, variables|
|
115
115
|
variables.concat(scope.variables.values)
|
116
|
-
break variables unless scope.node.
|
116
|
+
break variables unless scope.node.any_block_type?
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
120
|
private
|
121
121
|
|
122
122
|
def mark_variable_as_captured_by_block_if_so(variable)
|
123
|
-
return unless current_scope.node.
|
123
|
+
return unless current_scope.node.any_block_type?
|
124
124
|
return if variable.scope == current_scope
|
125
125
|
|
126
126
|
variable.capture_with_block!
|
@@ -4,13 +4,12 @@
|
|
4
4
|
|
5
5
|
require_relative 'cop_helper'
|
6
6
|
require_relative 'expect_offense'
|
7
|
-
require_relative 'host_environment_simulation_helper'
|
8
7
|
require_relative 'parallel_formatter'
|
9
8
|
require_relative 'shared_contexts'
|
10
9
|
|
11
10
|
RSpec.configure do |config|
|
12
11
|
config.include CopHelper
|
13
|
-
config.include
|
12
|
+
config.include RuboCop::RSpec::ExpectOffense
|
14
13
|
config.include_context 'config', :config
|
15
14
|
config.include_context 'isolated environment', :isolated_environment
|
16
15
|
config.include_context 'isolated bundler', :isolated_bundler
|
data/lib/rubocop/version.rb
CHANGED
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.71.
|
4
|
+
version: 1.71.1
|
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-01-
|
12
|
+
date: 2025-01-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -113,7 +113,7 @@ dependencies:
|
|
113
113
|
requirements:
|
114
114
|
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: 1.
|
116
|
+
version: 1.38.0
|
117
117
|
- - "<"
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '2.0'
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
requirements:
|
124
124
|
- - ">="
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version: 1.
|
126
|
+
version: 1.38.0
|
127
127
|
- - "<"
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '2.0'
|
@@ -279,6 +279,10 @@ files:
|
|
279
279
|
- lib/rubocop/cop/internal_affairs/node_destructuring.rb
|
280
280
|
- lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb
|
281
281
|
- lib/rubocop/cop/internal_affairs/node_matcher_directive.rb
|
282
|
+
- lib/rubocop/cop/internal_affairs/node_pattern_groups.rb
|
283
|
+
- lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_processor.rb
|
284
|
+
- lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb
|
285
|
+
- lib/rubocop/cop/internal_affairs/node_type_multiple_predicates.rb
|
282
286
|
- lib/rubocop/cop/internal_affairs/node_type_predicate.rb
|
283
287
|
- lib/rubocop/cop/internal_affairs/numblock_handler.rb
|
284
288
|
- lib/rubocop/cop/internal_affairs/offense_location_keyword.rb
|
@@ -1009,7 +1013,6 @@ files:
|
|
1009
1013
|
- lib/rubocop/result_cache.rb
|
1010
1014
|
- lib/rubocop/rspec/cop_helper.rb
|
1011
1015
|
- lib/rubocop/rspec/expect_offense.rb
|
1012
|
-
- lib/rubocop/rspec/host_environment_simulation_helper.rb
|
1013
1016
|
- lib/rubocop/rspec/parallel_formatter.rb
|
1014
1017
|
- lib/rubocop/rspec/shared_contexts.rb
|
1015
1018
|
- lib/rubocop/rspec/support.rb
|
@@ -1046,7 +1049,7 @@ licenses:
|
|
1046
1049
|
- MIT
|
1047
1050
|
metadata:
|
1048
1051
|
homepage_uri: https://rubocop.org/
|
1049
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.71.
|
1052
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.71.1
|
1050
1053
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1051
1054
|
documentation_uri: https://docs.rubocop.org/rubocop/1.71/
|
1052
1055
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# RuboCop can be run in contexts where unexpected other libraries are included,
|
4
|
-
# which may interfere with its normal behavior. In order to test those
|
5
|
-
# situations, it may be necessary to require another library for the duration
|
6
|
-
# of one spec
|
7
|
-
module HostEnvironmentSimulatorHelper
|
8
|
-
def in_its_own_process_with(*files)
|
9
|
-
if ::Process.respond_to?(:fork)
|
10
|
-
pid = ::Process.fork do
|
11
|
-
# Need to write coverage result under different name
|
12
|
-
if defined?(SimpleCov)
|
13
|
-
SimpleCov.command_name "rspec-fork-#{Process.pid}"
|
14
|
-
SimpleCov.pid = Process.pid
|
15
|
-
end
|
16
|
-
|
17
|
-
files.each { |file| require file }
|
18
|
-
yield
|
19
|
-
end
|
20
|
-
::Process.wait(pid)
|
21
|
-
|
22
|
-
# assert that the block did not fail
|
23
|
-
expect($CHILD_STATUS).to be_success
|
24
|
-
else
|
25
|
-
warn 'Process.fork is not available.'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|