rubocop 1.71.1 → 1.71.2
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/layout/else_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +0 -6
- data/lib/rubocop/cop/lint/empty_expression.rb +0 -2
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +1 -6
- data/lib/rubocop/cop/style/each_with_object.rb +2 -3
- data/lib/rubocop/cop/style/explicit_block_argument.rb +14 -1
- data/lib/rubocop/cop/style/while_until_modifier.rb +0 -1
- data/lib/rubocop/cop/variable_force/variable.rb +13 -1
- data/lib/rubocop/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d7c6408a777042eced58bec2bc889312b24d8701f5db99da3b471088f589d6f
|
4
|
+
data.tar.gz: 27423e682d55f04840a3bf3d5e0301556e4a1c419857e3422ced38ec423c0003
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8729a8ea3adae11fcb2501bfea338821a8f9894209ea6fb482b62ebfae87019e07ded7bf02d3371c18726b28c2491c79952e7b86c193388a045f886a833b427c
|
7
|
+
data.tar.gz: 44251afbbbc2aa7c121033ea05f25e1b3447afba7487d04a81f9463347ba28bcea05bdc2e434248f15cd235d9e452cb3f9f378f94adb5507eeb6d5ce58ba4119
|
@@ -92,7 +92,7 @@ module RuboCop
|
|
92
92
|
case parent.type
|
93
93
|
when :def, :defs then base_for_method_definition(parent)
|
94
94
|
when :kwbegin then parent.loc.begin
|
95
|
-
when :block
|
95
|
+
when :block, :numblock
|
96
96
|
assignment_node = assignment_node(parent)
|
97
97
|
if same_line?(parent, assignment_node)
|
98
98
|
assignment_node.source_range
|
@@ -22,8 +22,6 @@ module RuboCop
|
|
22
22
|
# def b
|
23
23
|
# end
|
24
24
|
#
|
25
|
-
# @example
|
26
|
-
#
|
27
25
|
# # good
|
28
26
|
# def a
|
29
27
|
# end
|
@@ -42,8 +40,6 @@ module RuboCop
|
|
42
40
|
# def b
|
43
41
|
# end
|
44
42
|
#
|
45
|
-
# @example
|
46
|
-
#
|
47
43
|
# # good
|
48
44
|
# class A
|
49
45
|
# end
|
@@ -65,8 +61,6 @@ module RuboCop
|
|
65
61
|
# def b
|
66
62
|
# end
|
67
63
|
#
|
68
|
-
# @example
|
69
|
-
#
|
70
64
|
# # good
|
71
65
|
# module A
|
72
66
|
# end
|
@@ -130,7 +130,7 @@ module RuboCop
|
|
130
130
|
|
131
131
|
block_body_node.each_descendant(:next, :break) do |n|
|
132
132
|
# Ignore `next`/`break` inside an inner block
|
133
|
-
next if n.each_ancestor(:
|
133
|
+
next if n.each_ancestor(:any_block).first != block_body_node.parent
|
134
134
|
next unless n.first_argument
|
135
135
|
|
136
136
|
nodes << n.first_argument
|
@@ -103,7 +103,7 @@ module RuboCop
|
|
103
103
|
expressions.pop unless in_void_context?(node)
|
104
104
|
expressions.each do |expr|
|
105
105
|
check_void_op(expr) do
|
106
|
-
block_node = node.each_ancestor(:
|
106
|
+
block_node = node.each_ancestor(:any_block).first
|
107
107
|
|
108
108
|
block_node&.method?(:each)
|
109
109
|
end
|
@@ -201,11 +201,6 @@ module RuboCop
|
|
201
201
|
# NOTE: the `begin` node case is already handled via `on_begin`
|
202
202
|
return if body.begin_type?
|
203
203
|
|
204
|
-
check_void_op(body) do
|
205
|
-
block_node = node.each_ancestor(:block).first
|
206
|
-
block_node&.method?(:each)
|
207
|
-
end
|
208
|
-
|
209
204
|
check_expression(body)
|
210
205
|
end
|
211
206
|
|
@@ -58,7 +58,7 @@ module RuboCop
|
|
58
58
|
|
59
59
|
# @!method each_with_object_block_candidate?(node)
|
60
60
|
def_node_matcher :each_with_object_block_candidate?, <<~PATTERN
|
61
|
-
(block $(call _ {:inject :reduce} _) $_ $_)
|
61
|
+
(block $(call _ {:inject :reduce} _) $(args _ _) $_)
|
62
62
|
PATTERN
|
63
63
|
|
64
64
|
# @!method each_with_object_numblock_candidate?(node)
|
@@ -71,8 +71,7 @@ module RuboCop
|
|
71
71
|
|
72
72
|
first_arg, second_arg = *node.arguments
|
73
73
|
|
74
|
-
corrector.
|
75
|
-
corrector.replace(second_arg, first_arg.source)
|
74
|
+
corrector.swap(first_arg, second_arg)
|
76
75
|
|
77
76
|
if return_value_occupies_whole_line?(return_value)
|
78
77
|
corrector.remove(whole_line_expression(return_value))
|
@@ -135,7 +135,13 @@ module RuboCop
|
|
135
135
|
end
|
136
136
|
|
137
137
|
def correct_call_node(node, corrector, block_name)
|
138
|
-
|
138
|
+
new_arguments = if node.zsuper_type?
|
139
|
+
args = build_new_arguments_for_zsuper(node) << "&#{block_name}"
|
140
|
+
args.join(', ')
|
141
|
+
else
|
142
|
+
"&#{block_name}"
|
143
|
+
end
|
144
|
+
corrector.insert_after(node, "(#{new_arguments})")
|
139
145
|
return unless node.parenthesized?
|
140
146
|
|
141
147
|
args_begin = Util.args_begin(node)
|
@@ -144,6 +150,13 @@ module RuboCop
|
|
144
150
|
corrector.remove(range)
|
145
151
|
end
|
146
152
|
|
153
|
+
def build_new_arguments_for_zsuper(node)
|
154
|
+
def_node = node.each_ancestor(:def, :defs).first
|
155
|
+
def_node.arguments.map do |arg|
|
156
|
+
arg.optarg_type? ? arg.node_parts[0] : arg.source
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
147
160
|
def block_body_range(block_node, send_node)
|
148
161
|
range_between(send_node.source_range.end_pos, block_node.loc.end.end_pos)
|
149
162
|
end
|
@@ -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
|
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
|
@@ -1049,7 +1049,7 @@ licenses:
|
|
1049
1049
|
- MIT
|
1050
1050
|
metadata:
|
1051
1051
|
homepage_uri: https://rubocop.org/
|
1052
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.71.
|
1052
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.71.2
|
1053
1053
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1054
1054
|
documentation_uri: https://docs.rubocop.org/rubocop/1.71/
|
1055
1055
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|