Skip to content

Commit c8edd7d

Browse files
committed
Cut 1.66
1 parent 9c106a5 commit c8edd7d

15 files changed

+199
-65
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ output by `rubocop -V`, include them as well. Here's an example:
3838

3939
```
4040
$ [bundle exec] rubocop -V
41-
1.65.1 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
41+
1.66.0 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
4242
- rubocop-performance 1.18.0
4343
- rubocop-rspec 2.23.2
4444
```

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
## master (unreleased)
1313

14+
## 1.66.0 (2024-08-31)
15+
1416
### New features
1517

1618
* [#13077](https://github.com/rubocop/rubocop/pull/13077): Add new global `StringLiteralsFrozenByDefault` option for correct analysis with `RUBYOPT=--enable=frozen-string-literal`. ([@earlopain][])

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ do so.
1717

1818
```console
1919
$ rubocop -V
20-
1.65.1 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
20+
1.66.0 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
2121
- rubocop-performance 1.18.0
2222
- rubocop-rspec 2.23.2
2323
```

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
5252
in your `Gemfile`:
5353

5454
```rb
55-
gem 'rubocop', '~> 1.65', require: false
55+
gem 'rubocop', '~> 1.66', require: false
5656
```
5757

5858
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.

config/default.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2543,7 +2543,7 @@ Lint/UselessAssignment:
25432543
Enabled: true
25442544
AutoCorrect: contextual
25452545
VersionAdded: '0.11'
2546-
VersionChanged: '<<next>>'
2546+
VersionChanged: '1.66'
25472547

25482548
Lint/UselessElseWithoutRescue:
25492549
Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
@@ -2562,7 +2562,7 @@ Lint/UselessMethodDefinition:
25622562
Lint/UselessNumericOperation:
25632563
Description: 'Checks for useless numeric operations.'
25642564
Enabled: pending
2565-
VersionAdded: '<<next>>'
2565+
VersionAdded: '1.66'
25662566

25672567
Lint/UselessRescue:
25682568
Description: 'Checks for useless `rescue`s.'
@@ -5065,7 +5065,7 @@ Style/RedundantInterpolation:
50655065
Style/RedundantInterpolationUnfreeze:
50665066
Description: 'Checks for redundant unfreezing of interpolated strings.'
50675067
Enabled: pending
5068-
VersionAdded: '<<next>>'
5068+
VersionAdded: '1.66'
50695069

50705070
Style/RedundantLineContinuation:
50715071
Description: 'Check for redundant line continuation.'

docs/antora.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ name: rubocop
22
title: RuboCop
33
# We always provide version without patch here (e.g. 1.1),
44
# as patch versions should not appear in the docs.
5-
version: ~
5+
version: '1.66'
66
nav:
77
- modules/ROOT/nav.adoc

docs/modules/ROOT/pages/cops.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ In the following section you find all available cops:
332332
* xref:cops_lint.adoc#lintuselessassignment[Lint/UselessAssignment]
333333
* xref:cops_lint.adoc#lintuselesselsewithoutrescue[Lint/UselessElseWithoutRescue]
334334
* xref:cops_lint.adoc#lintuselessmethoddefinition[Lint/UselessMethodDefinition]
335+
* xref:cops_lint.adoc#lintuselessnumericoperation[Lint/UselessNumericOperation]
335336
* xref:cops_lint.adoc#lintuselessrescue[Lint/UselessRescue]
336337
* xref:cops_lint.adoc#lintuselessruby2keywords[Lint/UselessRuby2Keywords]
337338
* xref:cops_lint.adoc#lintuselesssettercall[Lint/UselessSetterCall]
@@ -575,6 +576,7 @@ In the following section you find all available cops:
575576
* xref:cops_style.adoc#styleredundantheredocdelimiterquotes[Style/RedundantHeredocDelimiterQuotes]
576577
* xref:cops_style.adoc#styleredundantinitialize[Style/RedundantInitialize]
577578
* xref:cops_style.adoc#styleredundantinterpolation[Style/RedundantInterpolation]
579+
* xref:cops_style.adoc#styleredundantinterpolationunfreeze[Style/RedundantInterpolationUnfreeze]
578580
* xref:cops_style.adoc#styleredundantlinecontinuation[Style/RedundantLineContinuation]
579581
* xref:cops_style.adoc#styleredundantparentheses[Style/RedundantParentheses]
580582
* xref:cops_style.adoc#styleredundantpercentq[Style/RedundantPercentQ]

docs/modules/ROOT/pages/cops_layout.adoc

+15-18
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ start of the line where the `do` appeared.
369369
start of the line where the expression started.
370370
371371
`either` (which is the default) : the `end` is allowed to be in either
372-
location. The autofixer will default to `start_of_line`.
372+
location. The autocorrect will default to `start_of_line`.
373373
374374
=== Examples
375375
@@ -2825,7 +2825,6 @@ but_in_a_method_call([
28252825
# defined inside a method call.
28262826
28272827
# bad
2828-
# consistent
28292828
array = [
28302829
:value
28312830
]
@@ -2850,13 +2849,11 @@ and_in_a_method_call([
28502849
# brackets are indented to the same position.
28512850
28522851
# bad
2853-
# align_brackets
28542852
and_now_for_something = [
28552853
:completely_different
28562854
]
28572855
28582856
# good
2859-
# align_brackets
28602857
and_now_for_something = [
28612858
:completely_different
28622859
]
@@ -4487,20 +4484,20 @@ are recommended to further format the broken lines.
44874484
* `Layout/ArrayAlignment`
44884485
* `Layout/BlockAlignment`
44894486
* `Layout/BlockEndNewline`
4490-
* `LayoutClosingParenthesisIndentation`
4491-
* `LayoutFirstArgumentIndentation`
4492-
* `LayoutFirstArrayElementIndentation`
4493-
* `LayoutFirstHashElementIndentation`
4494-
* `LayoutFirstParameterIndentation`
4495-
* `LayoutHashAlignment`
4496-
* `LayoutIndentationWidth`
4497-
* `LayoutMultilineArrayLineBreaks`
4498-
* `LayoutMultilineBlockLayout`
4499-
* `LayoutMultilineHashBraceLayout`
4500-
* `LayoutMultilineHashKeyLineBreaks`
4501-
* `LayoutMultilineMethodArgumentLineBreaks`
4502-
* `LayoutMultilineMethodParameterLineBreaks`
4503-
* `Layout/ParameterAlignment`
4487+
* `Layout/ClosingParenthesisIndentation`
4488+
* `Layout/FirstArgumentIndentation`
4489+
* `Layout/FirstArrayElementIndentation`
4490+
* `Layout/FirstHashElementIndentation`
4491+
* `Layout/FirstParameterIndentation`
4492+
* `Layout/HashAlignment`
4493+
* `Layout/IndentationWidth`
4494+
* `Layout/MultilineArrayLineBreaks`
4495+
* `Layout/MultilineBlockLayout`
4496+
* `Layout/MultilineHashBraceLayout`
4497+
* `Layout/MultilineHashKeyLineBreaks`
4498+
* `Layout/MultilineMethodArgumentLineBreaks`
4499+
* `Layout/MultilineMethodParameterLineBreaks`
4500+
* `Layout//ParameterAlignment`
45044501
* `Style/BlockDelimiters`
45054502
45064503
Together, these cops will pretty print hashes, arrays,

docs/modules/ROOT/pages/cops_lint.adoc

+48-9
Original file line numberDiff line numberDiff line change
@@ -6981,9 +6981,9 @@ end
69816981
69826982
| Enabled
69836983
| Yes
6984-
| Command-line only (Unsafe)
6984+
| Command-line only
69856985
| 0.11
6986-
| 1.61
6986+
| 1.66
69876987
|===
69886988
69896989
Checks for every useless assignment to local variable in every
@@ -6999,16 +6999,14 @@ Currently this cop has advanced logic that detects unreferenced
69996999
reassignments and properly handles varied cases such as branch, loop,
70007000
rescue, ensure, etc.
70017001
7002-
NOTE: Given the assignment `foo = 1, bar = 2`, removing unused variables
7003-
can lead to a syntax error, so this case is not autocorrected.
7004-
7005-
=== Safety
7006-
7007-
This cop's autocorrection is unsafe because removing assignment from
7002+
This cop's autocorrection avoids cases like `a ||= 1` because removing assignment from
70087003
operator assignment can cause NameError if this assignment has been used to declare
7009-
local variable. For example, replacing `a ||= 1` to `a || 1` may cause
7004+
a local variable. For example, replacing `a ||= 1` with `a || 1` may cause
70107005
"undefined local variable or method `a' for main:Object (NameError)".
70117006
7007+
NOTE: Given the assignment `foo = 1, bar = 2`, removing unused variables
7008+
can lead to a syntax error, so this case is not autocorrected.
7009+
70127010
=== Examples
70137011
70147012
[source,ruby]
@@ -7116,6 +7114,47 @@ def method(*args)
71167114
end
71177115
----
71187116
7117+
== Lint/UselessNumericOperation
7118+
7119+
|===
7120+
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
7121+
7122+
| Pending
7123+
| Yes
7124+
| Always
7125+
| 1.66
7126+
| -
7127+
|===
7128+
7129+
Certain numeric operations have no impact, being:
7130+
Adding or subtracting 0, multiplying or dividing by 1 or raising to the power of 1.
7131+
These are probably leftover from debugging, or are mistakes.
7132+
7133+
=== Examples
7134+
7135+
[source,ruby]
7136+
----
7137+
# bad
7138+
x + 0
7139+
x - 0
7140+
x * 1
7141+
x / 1
7142+
x ** 1
7143+
7144+
# good
7145+
x
7146+
7147+
# bad
7148+
x += 0
7149+
x -= 0
7150+
x *= 1
7151+
x /= 1
7152+
x **= 1
7153+
7154+
# good
7155+
x = x
7156+
----
7157+
71197158
== Lint/UselessRescue
71207159
71217160
|===

docs/modules/ROOT/pages/cops_metrics.adoc

+24-20
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ The maximum allowed length is configurable.
101101
The cop can be configured to ignore blocks passed to certain methods.
102102
103103
You can set constructs you want to fold with `CountAsOne`.
104-
Available are: 'array', 'hash', 'heredoc', and 'method_call'. Each construct
105-
will be counted as one line regardless of its actual size.
104+
105+
Available are: 'array', 'hash', 'heredoc', and 'method_call'.
106+
Each construct will be counted as one line regardless of its actual size.
106107
107108
NOTE: This cop does not apply for `Struct` definitions.
108109
@@ -112,7 +113,7 @@ instead. By default, there are no methods to allowed.
112113
113114
=== Examples
114115
115-
==== CountAsOne: ['array', 'heredoc', 'method_call']
116+
==== CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
116117
117118
[source,ruby]
118119
----
@@ -122,7 +123,7 @@ something do
122123
2
123124
]
124125
125-
hash = { # +3
126+
hash = { # +1
126127
key: 'value'
127128
}
128129
@@ -135,7 +136,7 @@ something do
135136
1,
136137
2
137138
)
138-
end # 6 points
139+
end # 4 points
139140
----
140141
141142
=== Configurable attributes
@@ -228,14 +229,15 @@ Comment lines can optionally be ignored.
228229
The maximum allowed length is configurable.
229230
230231
You can set constructs you want to fold with `CountAsOne`.
231-
Available are: 'array', 'hash', 'heredoc', and 'method_call'. Each construct
232-
will be counted as one line regardless of its actual size.
232+
233+
Available are: 'array', 'hash', 'heredoc', and 'method_call'.
234+
Each construct will be counted as one line regardless of its actual size.
233235
234236
NOTE: This cop also applies for `Struct` definitions.
235237
236238
=== Examples
237239
238-
==== CountAsOne: ['array', 'heredoc', 'method_call']
240+
==== CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
239241
240242
[source,ruby]
241243
----
@@ -245,7 +247,7 @@ class Foo
245247
2
246248
]
247249
248-
HASH = { # +3
250+
HASH = { # +1
249251
key: 'value'
250252
}
251253
@@ -258,7 +260,7 @@ class Foo
258260
1,
259261
2
260262
)
261-
end # 6 points
263+
end # 4 points
262264
----
263265
264266
=== Configurable attributes
@@ -423,8 +425,9 @@ Comment lines can optionally be allowed.
423425
The maximum allowed length is configurable.
424426
425427
You can set constructs you want to fold with `CountAsOne`.
426-
Available are: 'array', 'hash', 'heredoc', and 'method_call'. Each construct
427-
will be counted as one line regardless of its actual size.
428+
429+
Available are: 'array', 'hash', 'heredoc', and 'method_call'.
430+
Each construct will be counted as one line regardless of its actual size.
428431
429432
NOTE: The `ExcludedMethods` and `IgnoredMethods` configuration is
430433
deprecated and only kept for backwards compatibility.
@@ -433,7 +436,7 @@ By default, there are no methods to allowed.
433436
434437
=== Examples
435438
436-
==== CountAsOne: ['array', 'heredoc', 'method_call']
439+
==== CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
437440
438441
[source,ruby]
439442
----
@@ -443,7 +446,7 @@ def m
443446
2
444447
]
445448
446-
hash = { # +3
449+
hash = { # +1
447450
key: 'value'
448451
}
449452
@@ -456,7 +459,7 @@ def m
456459
1,
457460
2
458461
)
459-
end # 6 points
462+
end # 4 points
460463
----
461464
462465
=== Configurable attributes
@@ -506,12 +509,13 @@ Comment lines can optionally be ignored.
506509
The maximum allowed length is configurable.
507510
508511
You can set constructs you want to fold with `CountAsOne`.
509-
Available are: 'array', 'hash', 'heredoc', and 'method_call'. Each construct
510-
will be counted as one line regardless of its actual size.
512+
513+
Available are: 'array', 'hash', 'heredoc', and 'method_call'.
514+
Each construct will be counted as one line regardless of its actual size.
511515
512516
=== Examples
513517
514-
==== CountAsOne: ['array', 'heredoc', 'method_call']
518+
==== CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
515519
516520
[source,ruby]
517521
----
@@ -521,7 +525,7 @@ module M
521525
2
522526
]
523527
524-
HASH = { # +3
528+
HASH = { # +1
525529
key: 'value'
526530
}
527531
@@ -534,7 +538,7 @@ module M
534538
1,
535539
2
536540
)
537-
end # 6 points
541+
end # 4 points
538542
----
539543
540544
=== Configurable attributes

docs/modules/ROOT/pages/cops_naming.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ define_method(:even?) { |value| }
11751175
def_node_matcher(:is_even) { |value| }
11761176
11771177
# good
1178-
# def_node_matcher(:even?) { |value| }
1178+
def_node_matcher(:even?) { |value| }
11791179
----
11801180
11811181
=== Configurable attributes

0 commit comments

Comments
 (0)