rubocop 1.72.1 → 1.72.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +2 -0
- data/lib/rubocop/cop/internal_affairs/example_description.rb +4 -2
- data/lib/rubocop/cop/lint/useless_constant_scoping.rb +7 -1
- data/lib/rubocop/cop/mixin/allowed_pattern.rb +4 -4
- data/lib/rubocop/cop/naming/block_forwarding.rb +3 -3
- data/lib/rubocop/cop/style/arguments_forwarding.rb +3 -3
- data/lib/rubocop/cop/style/redundant_format.rb +18 -2
- data/lib/rubocop/cop/style/redundant_parentheses.rb +1 -3
- data/lib/rubocop/plugin/configuration_integrator.rb +2 -0
- data/lib/rubocop/rspec/cop_helper.rb +2 -0
- 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: 4a6ff0f849d961da13d2131ff60e0ed49dce01a4c2d32caa8484a2344344609b
|
4
|
+
data.tar.gz: 9da9fc43212c62cd6542649c90423e9365f50cb00e82b6337be1a241c6a17283
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ff34957554167b3b1e30645e3754094968fae93d0284a3882460b3e24f44fd64bcf358b23fd0e8154489206fd9c95fc6555b551f1af5ac810805fac2b6d27be
|
7
|
+
data.tar.gz: 48e989049de37523554c740ba1368e32de38bc0f879c1fc717924a758a1ba465ef4413cba80a42be59ccaaf87616b52c0ad437256702bf5fd091c4a5818f428a
|
data/config/default.yml
CHANGED
@@ -5171,7 +5171,9 @@ Style/RedundantFilterChain:
|
|
5171
5171
|
Style/RedundantFormat:
|
5172
5172
|
Description: 'Checks for usages of `Kernel#format` or `Kernel#sprintf` with only a single argument.'
|
5173
5173
|
Enabled: pending
|
5174
|
+
SafeAutoCorrect: false
|
5174
5175
|
VersionAdded: '1.72'
|
5176
|
+
VersionChanged: '1.72'
|
5175
5177
|
|
5176
5178
|
Style/RedundantFreeze:
|
5177
5179
|
Description: "Checks usages of Object#freeze on immutable objects."
|
@@ -90,8 +90,10 @@ module RuboCop
|
|
90
90
|
description_text = string_contents(current_description)
|
91
91
|
return unless (new_description = correct_description(description_text, description_map))
|
92
92
|
|
93
|
+
quote = current_description.dstr_type? ? '"' : "'"
|
94
|
+
|
93
95
|
add_offense(current_description, message: message) do |corrector|
|
94
|
-
corrector.replace(current_description, "
|
96
|
+
corrector.replace(current_description, "#{quote}#{new_description}#{quote}")
|
95
97
|
end
|
96
98
|
end
|
97
99
|
|
@@ -106,7 +108,7 @@ module RuboCop
|
|
106
108
|
end
|
107
109
|
|
108
110
|
def string_contents(node)
|
109
|
-
node.
|
111
|
+
node.type?(:str, :dstr) ? node.value : node.source
|
110
112
|
end
|
111
113
|
end
|
112
114
|
end
|
@@ -56,7 +56,13 @@ module RuboCop
|
|
56
56
|
private
|
57
57
|
|
58
58
|
def after_private_modifier?(left_siblings)
|
59
|
-
left_siblings.compact.select
|
59
|
+
access_modifier_candidates = left_siblings.compact.select do |left_sibling|
|
60
|
+
left_sibling.respond_to?(:send_type?) && left_sibling.send_type?
|
61
|
+
end
|
62
|
+
|
63
|
+
access_modifier_candidates.any? do |candidate|
|
64
|
+
candidate.command?(:private) && candidate.arguments.none?
|
65
|
+
end
|
60
66
|
end
|
61
67
|
|
62
68
|
def private_constantize?(right_siblings, const_value)
|
@@ -18,12 +18,12 @@ module RuboCop
|
|
18
18
|
end
|
19
19
|
|
20
20
|
# @deprecated Use allowed_line? instead
|
21
|
-
def ignored_line?
|
21
|
+
def ignored_line?(line)
|
22
22
|
warn Rainbow(<<~WARNING).yellow, uplevel: 1
|
23
23
|
`ignored_line?` is deprecated. Use `allowed_line?` instead.
|
24
24
|
WARNING
|
25
25
|
|
26
|
-
allowed_line?
|
26
|
+
allowed_line?(line)
|
27
27
|
end
|
28
28
|
|
29
29
|
def matches_allowed_pattern?(line)
|
@@ -31,12 +31,12 @@ module RuboCop
|
|
31
31
|
end
|
32
32
|
|
33
33
|
# @deprecated Use matches_allowed_pattern? instead
|
34
|
-
def matches_ignored_pattern?
|
34
|
+
def matches_ignored_pattern?(line)
|
35
35
|
warn Rainbow(<<~WARNING).yellow, uplevel: 1
|
36
36
|
`matches_ignored_pattern?` is deprecated. Use `matches_allowed_pattern?` instead.
|
37
37
|
WARNING
|
38
38
|
|
39
|
-
matches_allowed_pattern?
|
39
|
+
matches_allowed_pattern?(line)
|
40
40
|
end
|
41
41
|
|
42
42
|
def allowed_patterns
|
@@ -14,10 +14,10 @@ module RuboCop
|
|
14
14
|
# autocorrected.
|
15
15
|
#
|
16
16
|
# [NOTE]
|
17
|
-
#
|
17
|
+
# ====
|
18
18
|
# Because of a bug in Ruby 3.3.0, when a block is referenced inside of another block,
|
19
19
|
# no offense will be registered until Ruby 3.4:
|
20
|
-
|
20
|
+
#
|
21
21
|
# [source,ruby]
|
22
22
|
# ----
|
23
23
|
# def foo(&block)
|
@@ -25,7 +25,7 @@ module RuboCop
|
|
25
25
|
# block_method { bar(&block) }
|
26
26
|
# end
|
27
27
|
# ----
|
28
|
-
#
|
28
|
+
# ====
|
29
29
|
#
|
30
30
|
# @example EnforcedStyle: anonymous (default)
|
31
31
|
#
|
@@ -32,10 +32,10 @@ module RuboCop
|
|
32
32
|
# This cop handles not only method forwarding but also forwarding to `super`.
|
33
33
|
#
|
34
34
|
# [NOTE]
|
35
|
-
#
|
35
|
+
# ====
|
36
36
|
# Because of a bug in Ruby 3.3.0, when a block is referenced inside of another block,
|
37
37
|
# no offense will be registered until Ruby 3.4:
|
38
|
-
|
38
|
+
#
|
39
39
|
# [source,ruby]
|
40
40
|
# ----
|
41
41
|
# def foo(&block)
|
@@ -43,7 +43,7 @@ module RuboCop
|
|
43
43
|
# block_method { bar(&block) }
|
44
44
|
# end
|
45
45
|
# ----
|
46
|
-
#
|
46
|
+
# ====
|
47
47
|
#
|
48
48
|
# @example
|
49
49
|
# # bad
|
@@ -12,6 +12,22 @@ module RuboCop
|
|
12
12
|
# inlined into a string easily. This applies to the `%s`, `%d`, `%i`, `%u`, and
|
13
13
|
# `%f` format specifiers.
|
14
14
|
#
|
15
|
+
# @safety
|
16
|
+
# This cop's autocorrection is unsafe because string object returned by
|
17
|
+
# `format` and `sprintf` are never frozen. If `format('string')` is autocorrected to
|
18
|
+
# `'string'`, `FrozenError` may occur when calling a destructive method like `String#<<`.
|
19
|
+
# Consider using `'string'.dup` instead of `format('string')`.
|
20
|
+
# Additionally, since the necessity of `dup` cannot be determined automatically,
|
21
|
+
# this autocorrection is inherently unsafe.
|
22
|
+
#
|
23
|
+
# [source,ruby]
|
24
|
+
# ----
|
25
|
+
# # frozen_string_literal: true
|
26
|
+
#
|
27
|
+
# format('template').frozen? # => false
|
28
|
+
# 'template'.frozen? # => true
|
29
|
+
# ----
|
30
|
+
#
|
15
31
|
# @example
|
16
32
|
#
|
17
33
|
# # bad
|
@@ -113,7 +129,7 @@ module RuboCop
|
|
113
129
|
end
|
114
130
|
|
115
131
|
def find_argument(sequence, arguments, hash)
|
116
|
-
if sequence.annotated? || sequence.template?
|
132
|
+
if hash && (sequence.annotated? || sequence.template?)
|
117
133
|
find_hash_value_node(hash, sequence.name.to_sym).first
|
118
134
|
elsif sequence.arg_number
|
119
135
|
arguments[sequence.arg_number.to_i - 1]
|
@@ -144,7 +160,7 @@ module RuboCop
|
|
144
160
|
end
|
145
161
|
|
146
162
|
def numeric?(argument)
|
147
|
-
argument
|
163
|
+
argument&.type?(:numeric, :str) ||
|
148
164
|
rational_number?(argument) ||
|
149
165
|
complex_number?(argument)
|
150
166
|
end
|
@@ -13,8 +13,7 @@ module RuboCop
|
|
13
13
|
# # good
|
14
14
|
# x if y.z.nil?
|
15
15
|
#
|
16
|
-
# rubocop:disable Metrics/ClassLength
|
17
|
-
class RedundantParentheses < Base
|
16
|
+
class RedundantParentheses < Base # rubocop:disable Metrics/ClassLength
|
18
17
|
include Parentheses
|
19
18
|
extend AutoCorrector
|
20
19
|
|
@@ -299,7 +298,6 @@ module RuboCop
|
|
299
298
|
block.keywords? && begin_node.each_ancestor(:call).any?
|
300
299
|
end
|
301
300
|
end
|
302
|
-
# rubocop:enable Metrics/ClassLength
|
303
301
|
end
|
304
302
|
end
|
305
303
|
end
|
@@ -14,6 +14,8 @@ module CopHelper
|
|
14
14
|
let(:rails_version) { false }
|
15
15
|
|
16
16
|
before(:all) do
|
17
|
+
next if ENV['RUBOCOP_CORE_DEVELOPMENT']
|
18
|
+
|
17
19
|
plugins = Gem.loaded_specs.filter_map do |feature_name, feature_specification|
|
18
20
|
feature_name if feature_specification.metadata['default_lint_roller_plugin']
|
19
21
|
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.72.
|
4
|
+
version: 1.72.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-02-
|
12
|
+
date: 2025-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -1075,7 +1075,7 @@ licenses:
|
|
1075
1075
|
- MIT
|
1076
1076
|
metadata:
|
1077
1077
|
homepage_uri: https://rubocop.org/
|
1078
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.72.
|
1078
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.72.2
|
1079
1079
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1080
1080
|
documentation_uri: https://docs.rubocop.org/rubocop/1.72/
|
1081
1081
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|