rubocop 1.81.6 → 1.81.7
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/config/default.yml +1 -1
- data/lib/rubocop/config_loader_resolver.rb +5 -4
- data/lib/rubocop/cop/layout/hash_alignment.rb +2 -0
- data/lib/rubocop/cop/lint/debugger.rb +0 -2
- data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +16 -6
- data/lib/rubocop/cop/naming/method_name.rb +3 -1
- data/lib/rubocop/cop/naming/predicate_method.rb +4 -4
- data/lib/rubocop/cop/style/constant_visibility.rb +14 -9
- data/lib/rubocop/cop/style/float_division.rb +15 -1
- data/lib/rubocop/cop/style/semicolon.rb +3 -2
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +8 -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: 8acfafa4ed4b94c367e6ef95c84d2d02f01222a1e8a813790948977476f34456
|
|
4
|
+
data.tar.gz: 0d2ad56c4a81da58046a098351606bfb8314f09f9e5f946ad1dd825aa70fe0f7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ae4edea22ca7511df39ec99591df3d537bfd3fa8974d5bb461d2b1c674b48f15296f22c81b1cd9329719a68b0d3f8d36442eaa5742cbf8e0974c6e3e2e56e29c
|
|
7
|
+
data.tar.gz: ffce467cec50d2ed0ef7b312a15dd17e9b7fd1622b70528d12f0cfe16056ae3b5111f2d360b4e855ea5811befd092a306ff56ad091b89a6050f3354f3db205a4
|
data/config/default.yml
CHANGED
|
@@ -295,10 +295,11 @@ module RuboCop
|
|
|
295
295
|
begin
|
|
296
296
|
gem = Bundler.load.specs[gem_name].first
|
|
297
297
|
gem_path = gem.full_gem_path if gem
|
|
298
|
-
rescue
|
|
299
|
-
#
|
|
300
|
-
|
|
301
|
-
# The Gemfile exists but contains an uninstalled git source
|
|
298
|
+
rescue StandardError
|
|
299
|
+
# The Gemfile has a problem, which could be one of:
|
|
300
|
+
# - No Gemfile found. Bundler may be loaded manually
|
|
301
|
+
# - The Gemfile exists but contains an uninstalled git source
|
|
302
|
+
# - The Gemfile exists but cannot be loaded for some other reason
|
|
302
303
|
end
|
|
303
304
|
end
|
|
304
305
|
|
|
@@ -9,9 +9,21 @@ module RuboCop
|
|
|
9
9
|
# cop disables on wide ranges of code, that latter contributors to
|
|
10
10
|
# a file wouldn't be aware of.
|
|
11
11
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
12
|
+
# You can set `MaximumRangeSize` to define the maximum number of
|
|
13
|
+
# consecutive lines a cop can be disabled for.
|
|
14
|
+
#
|
|
15
|
+
# - `.inf` any size (default)
|
|
16
|
+
# - `0` allows only single-line disables
|
|
17
|
+
# - `1` means the maximum allowed is as follows:
|
|
18
|
+
#
|
|
19
|
+
# [source,ruby]
|
|
20
|
+
# ----
|
|
21
|
+
# # rubocop:disable SomeCop
|
|
22
|
+
# a = 1
|
|
23
|
+
# # rubocop:enable SomeCop
|
|
24
|
+
# ----
|
|
25
|
+
#
|
|
26
|
+
# @example MaximumRangeSize: .inf (default)
|
|
15
27
|
#
|
|
16
28
|
# # good
|
|
17
29
|
# # rubocop:disable Layout/SpaceAroundOperators
|
|
@@ -25,9 +37,7 @@ module RuboCop
|
|
|
25
37
|
# x= 0
|
|
26
38
|
# # EOF
|
|
27
39
|
#
|
|
28
|
-
# @example
|
|
29
|
-
# # Lint/MissingCopEnableDirective:
|
|
30
|
-
# # MaximumRangeSize: 2
|
|
40
|
+
# @example MaximumRangeSize: 2
|
|
31
41
|
#
|
|
32
42
|
# # good
|
|
33
43
|
# # rubocop:disable Layout/SpaceAroundOperators
|
|
@@ -147,7 +147,9 @@ module RuboCop
|
|
|
147
147
|
alias on_defs on_def
|
|
148
148
|
|
|
149
149
|
def on_alias(node)
|
|
150
|
-
|
|
150
|
+
return unless (new_identifier = node.new_identifier).sym_type?
|
|
151
|
+
|
|
152
|
+
handle_method_name(new_identifier, new_identifier.value)
|
|
151
153
|
end
|
|
152
154
|
|
|
153
155
|
private
|
|
@@ -193,8 +193,7 @@ module RuboCop
|
|
|
193
193
|
return_values << extract_return_value(return_node)
|
|
194
194
|
end
|
|
195
195
|
|
|
196
|
-
|
|
197
|
-
return_values << last_value if last_value
|
|
196
|
+
return_values << last_value(node)
|
|
198
197
|
|
|
199
198
|
process_return_values(return_values)
|
|
200
199
|
end
|
|
@@ -247,8 +246,9 @@ module RuboCop
|
|
|
247
246
|
end
|
|
248
247
|
|
|
249
248
|
def last_value(node)
|
|
250
|
-
value = node.begin_type? ? node.children.last : node
|
|
251
|
-
|
|
249
|
+
value = node.begin_type? ? node.children.last || s(:nil) : node
|
|
250
|
+
|
|
251
|
+
value.return_type? ? extract_return_value(value) : value
|
|
252
252
|
end
|
|
253
253
|
|
|
254
254
|
def process_return_values(return_values)
|
|
@@ -48,6 +48,11 @@ module RuboCop
|
|
|
48
48
|
MSG = 'Explicitly make `%<constant_name>s` public or private using ' \
|
|
49
49
|
'either `#public_constant` or `#private_constant`.'
|
|
50
50
|
|
|
51
|
+
# @!method visibility_declaration_for(node)
|
|
52
|
+
def_node_matcher :visibility_declaration_for, <<~PATTERN
|
|
53
|
+
(send nil? {:public_constant :private_constant} $...)
|
|
54
|
+
PATTERN
|
|
55
|
+
|
|
51
56
|
def on_casgn(node)
|
|
52
57
|
return unless class_or_module_scope?(node)
|
|
53
58
|
return if visibility_declaration?(node)
|
|
@@ -77,20 +82,20 @@ module RuboCop
|
|
|
77
82
|
end
|
|
78
83
|
end
|
|
79
84
|
|
|
85
|
+
# rubocop:disable Metrics/AbcSize
|
|
80
86
|
def visibility_declaration?(node)
|
|
81
87
|
node.parent.each_child_node(:send).any? do |child|
|
|
82
|
-
visibility_declaration_for
|
|
83
|
-
end
|
|
84
|
-
end
|
|
88
|
+
next false unless (arguments = visibility_declaration_for(child))
|
|
85
89
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
arguments = arguments.first.children.first.to_a if arguments.first&.splat_type?
|
|
91
|
+
constant_values = arguments.map do |argument|
|
|
92
|
+
argument.value.to_sym if argument.respond_to?(:value)
|
|
93
|
+
end
|
|
90
94
|
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
constant_values.include?(node.name)
|
|
96
|
+
end
|
|
93
97
|
end
|
|
98
|
+
# rubocop:enable Metrics/AbcSize
|
|
94
99
|
end
|
|
95
100
|
end
|
|
96
101
|
end
|
|
@@ -7,9 +7,12 @@ module RuboCop
|
|
|
7
7
|
# It is recommended to either always use `fdiv` or coerce one side only.
|
|
8
8
|
# This cop also provides other options for code consistency.
|
|
9
9
|
#
|
|
10
|
+
# For `Regexp.last_match` and nth reference (e.g., `$1`), it assumes that the value
|
|
11
|
+
# is a string matched by a regular expression, and allows conversion with `#to_f`.
|
|
12
|
+
#
|
|
10
13
|
# @safety
|
|
11
14
|
# This cop is unsafe, because if the operand variable is a string object
|
|
12
|
-
# then
|
|
15
|
+
# then `#to_f` will be removed and an error will occur.
|
|
13
16
|
#
|
|
14
17
|
# [source,ruby]
|
|
15
18
|
# ----
|
|
@@ -84,6 +87,14 @@ module RuboCop
|
|
|
84
87
|
(send !nil? :to_f)
|
|
85
88
|
PATTERN
|
|
86
89
|
|
|
90
|
+
# @!method regexp_last_match?(node)
|
|
91
|
+
def_node_matcher :regexp_last_match?, <<~PATTERN
|
|
92
|
+
{
|
|
93
|
+
(send (const {nil? cbase} :Regexp) :last_match int)
|
|
94
|
+
(:nth_ref _)
|
|
95
|
+
}
|
|
96
|
+
PATTERN
|
|
97
|
+
|
|
87
98
|
def on_send(node)
|
|
88
99
|
return unless offense_condition?(node)
|
|
89
100
|
|
|
@@ -104,6 +115,9 @@ module RuboCop
|
|
|
104
115
|
private
|
|
105
116
|
|
|
106
117
|
def offense_condition?(node)
|
|
118
|
+
return false if regexp_last_match?(node.receiver.receiver) ||
|
|
119
|
+
regexp_last_match?(node.first_argument.receiver)
|
|
120
|
+
|
|
107
121
|
case style
|
|
108
122
|
when :left_coerce
|
|
109
123
|
right_coerce?(node)
|
|
@@ -69,10 +69,11 @@ module RuboCop
|
|
|
69
69
|
|
|
70
70
|
def each_semicolon
|
|
71
71
|
tokens_for_lines.each do |line, tokens|
|
|
72
|
-
semicolon_pos = semicolon_position(tokens)
|
|
72
|
+
next unless (semicolon_pos = semicolon_position(tokens))
|
|
73
|
+
|
|
73
74
|
after_expr_pos = semicolon_pos == -1 ? -2 : semicolon_pos
|
|
74
75
|
|
|
75
|
-
yield line, tokens[semicolon_pos].column, tokens[after_expr_pos]
|
|
76
|
+
yield line, tokens[semicolon_pos].column, tokens[after_expr_pos]
|
|
76
77
|
end
|
|
77
78
|
end
|
|
78
79
|
|
|
@@ -129,6 +129,7 @@ module RuboCop
|
|
|
129
129
|
corrector.remove(range_with_surrounding_space(range, newlines: false))
|
|
130
130
|
end
|
|
131
131
|
|
|
132
|
+
# rubocop:disable Metrics/AbcSize
|
|
132
133
|
def correct_for_basic_condition_style(corrector, node, if_branch)
|
|
133
134
|
range = range_between(
|
|
134
135
|
node.condition.source_range.end_pos, if_branch.condition.source_range.begin_pos
|
|
@@ -137,8 +138,14 @@ module RuboCop
|
|
|
137
138
|
|
|
138
139
|
corrector.replace(if_branch.condition, chainable_condition(if_branch))
|
|
139
140
|
|
|
140
|
-
|
|
141
|
+
end_range = if same_line?(node.loc.end, node.if_branch.loc.end)
|
|
142
|
+
node.loc.end
|
|
143
|
+
else
|
|
144
|
+
range_by_whole_lines(node.loc.end, include_final_newline: true)
|
|
145
|
+
end
|
|
146
|
+
corrector.remove(end_range)
|
|
141
147
|
end
|
|
148
|
+
# rubocop:enable Metrics/AbcSize
|
|
142
149
|
|
|
143
150
|
def autocorrect_outer_condition_modify_form(corrector, node, if_branch)
|
|
144
151
|
correct_node(corrector, if_branch)
|
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.81.
|
|
4
|
+
version: 1.81.7
|
|
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-10-
|
|
12
|
+
date: 2025-10-31 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: json
|
|
@@ -1091,7 +1091,7 @@ licenses:
|
|
|
1091
1091
|
- MIT
|
|
1092
1092
|
metadata:
|
|
1093
1093
|
homepage_uri: https://rubocop.org/
|
|
1094
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.81.
|
|
1094
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.81.7
|
|
1095
1095
|
source_code_uri: https://github.com/rubocop/rubocop/
|
|
1096
1096
|
documentation_uri: https://docs.rubocop.org/rubocop/1.81/
|
|
1097
1097
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|