rubocop 1.71.0 → 1.71.2
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/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/else_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +7 -11
- 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/empty_expression.rb +0 -2
- 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/unmodified_reduce_accumulator.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 +2 -7
- 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/each_with_object.rb +2 -3
- data/lib/rubocop/cop/style/eval_with_location.rb +1 -1
- data/lib/rubocop/cop/style/explicit_block_argument.rb +15 -2
- 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/while_until_modifier.rb +0 -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 +14 -2
- 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
@@ -50,7 +50,7 @@ module RuboCop
|
|
50
50
|
def ignore_syntax?(node)
|
51
51
|
return false unless (parent = node.parent)
|
52
52
|
|
53
|
-
parent.
|
53
|
+
parent.type?(:while_post, :until_post, :match_with_lvasgn) ||
|
54
54
|
like_method_argument_parentheses?(parent) || multiline_control_flow_statements?(node)
|
55
55
|
end
|
56
56
|
|
@@ -72,7 +72,7 @@ module RuboCop
|
|
72
72
|
ancestor = node.ancestors.first
|
73
73
|
return false unless ancestor
|
74
74
|
|
75
|
-
!ancestor.
|
75
|
+
!ancestor.type?(:begin, :def, :any_block)
|
76
76
|
end
|
77
77
|
|
78
78
|
def allowed_ternary?(node)
|
@@ -89,7 +89,7 @@ module RuboCop
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def like_method_argument_parentheses?(node)
|
92
|
-
return false
|
92
|
+
return false unless node.type?(:send, :super, :yield)
|
93
93
|
|
94
94
|
node.arguments.one? && !node.parenthesized? &&
|
95
95
|
!node.arithmetic_operation? && node.first_argument.begin_type?
|
@@ -99,7 +99,7 @@ module RuboCop
|
|
99
99
|
return false unless (parent = node.parent)
|
100
100
|
return false if parent.single_line?
|
101
101
|
|
102
|
-
parent.
|
102
|
+
parent.type?(:return, :next, :break)
|
103
103
|
end
|
104
104
|
|
105
105
|
def empty_parentheses?(node)
|
@@ -279,9 +279,9 @@ module RuboCop
|
|
279
279
|
end
|
280
280
|
|
281
281
|
def do_end_block_in_method_chain?(begin_node, node)
|
282
|
-
return false unless (block = node.each_descendant(:
|
282
|
+
return false unless (block = node.each_descendant(:any_block).first)
|
283
283
|
|
284
|
-
block.keywords? && begin_node.each_ancestor(:
|
284
|
+
block.keywords? && begin_node.each_ancestor(:call).any?
|
285
285
|
end
|
286
286
|
end
|
287
287
|
end
|
@@ -21,12 +21,8 @@ module RuboCop
|
|
21
21
|
# args += foo
|
22
22
|
# hash.merge!(other)
|
23
23
|
#
|
24
|
-
# # bad
|
25
|
-
# self.foo = foo.concat(ary)
|
26
|
-
#
|
27
24
|
# # good
|
28
25
|
# foo.concat(ary)
|
29
|
-
# self.foo += ary
|
30
26
|
#
|
31
27
|
class RedundantSelfAssignment < Base
|
32
28
|
include RangeHelp
|
@@ -49,6 +45,16 @@ module RuboCop
|
|
49
45
|
gvasgn: :gvar
|
50
46
|
}.freeze
|
51
47
|
|
48
|
+
# @!method redundant_self_assignment?
|
49
|
+
def_node_matcher :redundant_self_assignment?, <<~PATTERN
|
50
|
+
(call
|
51
|
+
%1 _
|
52
|
+
(call
|
53
|
+
(call
|
54
|
+
%1 %2) #method_returning_self?
|
55
|
+
...))
|
56
|
+
PATTERN
|
57
|
+
|
52
58
|
# rubocop:disable Metrics/AbcSize
|
53
59
|
def on_lvasgn(node)
|
54
60
|
return unless (rhs = node.rhs)
|
@@ -85,31 +91,10 @@ module RuboCop
|
|
85
91
|
METHODS_RETURNING_SELF.include?(method_name)
|
86
92
|
end
|
87
93
|
|
88
|
-
# @!method redundant_self_assignment?(node, method_name)
|
89
|
-
def_node_matcher :redundant_self_assignment?, <<~PATTERN
|
90
|
-
(send
|
91
|
-
(self) _
|
92
|
-
(call
|
93
|
-
(send
|
94
|
-
{(self) nil?} %1) #method_returning_self?
|
95
|
-
...))
|
96
|
-
PATTERN
|
97
|
-
|
98
|
-
# @!method redundant_nonself_assignment?(node, receiver, method_name)
|
99
|
-
def_node_matcher :redundant_nonself_assignment?, <<~PATTERN
|
100
|
-
(call
|
101
|
-
%1 _
|
102
|
-
(call
|
103
|
-
(call
|
104
|
-
%1 %2) #method_returning_self?
|
105
|
-
...))
|
106
|
-
PATTERN
|
107
|
-
|
108
94
|
def redundant_assignment?(node)
|
109
|
-
receiver_name = node.method_name.to_s
|
95
|
+
receiver_name = node.method_name.to_s.delete_suffix('=').to_sym
|
110
96
|
|
111
|
-
redundant_self_assignment?(node, receiver_name)
|
112
|
-
redundant_nonself_assignment?(node, node.receiver, receiver_name)
|
97
|
+
redundant_self_assignment?(node, node.receiver, receiver_name)
|
113
98
|
end
|
114
99
|
|
115
100
|
def correction_range(node)
|
@@ -93,9 +93,9 @@ module RuboCop
|
|
93
93
|
(call $(call _ $:sort_by _) ${:last :first})
|
94
94
|
(send $(send _ $:sort_by _) ${:[] :at :slice} {(int 0) (int -1)})
|
95
95
|
|
96
|
-
(call (
|
96
|
+
(call (any_block $(call _ ${:sort_by :sort}) ...) ${:last :first})
|
97
97
|
(call
|
98
|
-
(
|
98
|
+
(any_block $(call _ ${:sort_by :sort}) ...)
|
99
99
|
${:[] :at :slice} {(int 0) (int -1)}
|
100
100
|
)
|
101
101
|
}
|
@@ -41,7 +41,7 @@ module RuboCop
|
|
41
41
|
MSG = 'Redundant escape of %<char>s inside string literal.'
|
42
42
|
|
43
43
|
def on_str(node)
|
44
|
-
return if node.parent&.
|
44
|
+
return if node.parent&.type?(:regexp, :xstr) || node.character_literal?
|
45
45
|
|
46
46
|
str_contents_range = str_contents_range(node)
|
47
47
|
|
@@ -147,7 +147,7 @@ module RuboCop
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def heredoc?(node)
|
150
|
-
|
150
|
+
node.type?(:str, :dstr) && node.heredoc?
|
151
151
|
end
|
152
152
|
|
153
153
|
def delimiter?(node, char)
|
@@ -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
|
@@ -6,6 +6,8 @@ module RuboCop
|
|
6
6
|
# A Variable represents existence of a local variable.
|
7
7
|
# This holds a variable declaration node and some states of the variable.
|
8
8
|
class Variable
|
9
|
+
extend NodePattern::Macros
|
10
|
+
|
9
11
|
VARIABLE_DECLARATION_TYPES = (VARIABLE_ASSIGNMENT_TYPES + ARGUMENT_DECLARATION_TYPES).freeze
|
10
12
|
|
11
13
|
attr_reader :name, :declaration_node, :scope, :assignments, :references, :captured_by_block
|
@@ -31,11 +33,21 @@ module RuboCop
|
|
31
33
|
def assign(node)
|
32
34
|
assignment = Assignment.new(node, self)
|
33
35
|
|
34
|
-
|
36
|
+
mark_last_as_reassigned!(assignment)
|
35
37
|
|
36
38
|
@assignments << assignment
|
37
39
|
end
|
38
40
|
|
41
|
+
def mark_last_as_reassigned!(assignment)
|
42
|
+
return if captured_by_block?
|
43
|
+
return if candidate_condition?(assignment.node.parent)
|
44
|
+
|
45
|
+
@assignments.last&.reassigned!
|
46
|
+
end
|
47
|
+
|
48
|
+
# @!method candidate_condition?(node)
|
49
|
+
def_node_matcher :candidate_condition?, '[{if case case_match when}]'
|
50
|
+
|
39
51
|
def referenced?
|
40
52
|
!@references.empty?
|
41
53
|
end
|
@@ -72,7 +84,7 @@ module RuboCop
|
|
72
84
|
parent = parent.parent if parent&.begin_type?
|
73
85
|
return false if parent.nil?
|
74
86
|
|
75
|
-
|
87
|
+
parent.type?(:if, :while, :until) && parent.modifier_form?
|
76
88
|
end
|
77
89
|
|
78
90
|
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.2
|
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-
|
12
|
+
date: 2025-02-04 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.2
|
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
|