Skip to content

Commit

Permalink
Cut 1.66
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed Aug 31, 2024
1 parent 9c106a5 commit c8edd7d
Show file tree
Hide file tree
Showing 15 changed files with 199 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ output by `rubocop -V`, include them as well. Here's an example:

```
$ [bundle exec] rubocop -V
1.65.1 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
1.66.0 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
- rubocop-performance 1.18.0
- rubocop-rspec 2.23.2
```
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

## master (unreleased)

## 1.66.0 (2024-08-31)

### New features

* [#13077](https://github.com/rubocop/rubocop/pull/13077): Add new global `StringLiteralsFrozenByDefault` option for correct analysis with `RUBYOPT=--enable=frozen-string-literal`. ([@earlopain][])
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ do so.

```console
$ rubocop -V
1.65.1 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
1.66.0 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
- rubocop-performance 1.18.0
- rubocop-rspec 2.23.2
```
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
in your `Gemfile`:

```rb
gem 'rubocop', '~> 1.65', require: false
gem 'rubocop', '~> 1.66', require: false
```

See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
Expand Down
6 changes: 3 additions & 3 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2543,7 +2543,7 @@ Lint/UselessAssignment:
Enabled: true
AutoCorrect: contextual
VersionAdded: '0.11'
VersionChanged: '<<next>>'
VersionChanged: '1.66'

Lint/UselessElseWithoutRescue:
Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
Expand All @@ -2562,7 +2562,7 @@ Lint/UselessMethodDefinition:
Lint/UselessNumericOperation:
Description: 'Checks for useless numeric operations.'
Enabled: pending
VersionAdded: '<<next>>'
VersionAdded: '1.66'

Lint/UselessRescue:
Description: 'Checks for useless `rescue`s.'
Expand Down Expand Up @@ -5065,7 +5065,7 @@ Style/RedundantInterpolation:
Style/RedundantInterpolationUnfreeze:
Description: 'Checks for redundant unfreezing of interpolated strings.'
Enabled: pending
VersionAdded: '<<next>>'
VersionAdded: '1.66'

Style/RedundantLineContinuation:
Description: 'Check for redundant line continuation.'
Expand Down
2 changes: 1 addition & 1 deletion docs/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ name: rubocop
title: RuboCop
# We always provide version without patch here (e.g. 1.1),
# as patch versions should not appear in the docs.
version: ~
version: '1.66'
nav:
- modules/ROOT/nav.adoc
2 changes: 2 additions & 0 deletions docs/modules/ROOT/pages/cops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ In the following section you find all available cops:
* xref:cops_lint.adoc#lintuselessassignment[Lint/UselessAssignment]
* xref:cops_lint.adoc#lintuselesselsewithoutrescue[Lint/UselessElseWithoutRescue]
* xref:cops_lint.adoc#lintuselessmethoddefinition[Lint/UselessMethodDefinition]
* xref:cops_lint.adoc#lintuselessnumericoperation[Lint/UselessNumericOperation]
* xref:cops_lint.adoc#lintuselessrescue[Lint/UselessRescue]
* xref:cops_lint.adoc#lintuselessruby2keywords[Lint/UselessRuby2Keywords]
* xref:cops_lint.adoc#lintuselesssettercall[Lint/UselessSetterCall]
Expand Down Expand Up @@ -575,6 +576,7 @@ In the following section you find all available cops:
* xref:cops_style.adoc#styleredundantheredocdelimiterquotes[Style/RedundantHeredocDelimiterQuotes]
* xref:cops_style.adoc#styleredundantinitialize[Style/RedundantInitialize]
* xref:cops_style.adoc#styleredundantinterpolation[Style/RedundantInterpolation]
* xref:cops_style.adoc#styleredundantinterpolationunfreeze[Style/RedundantInterpolationUnfreeze]
* xref:cops_style.adoc#styleredundantlinecontinuation[Style/RedundantLineContinuation]
* xref:cops_style.adoc#styleredundantparentheses[Style/RedundantParentheses]
* xref:cops_style.adoc#styleredundantpercentq[Style/RedundantPercentQ]
Expand Down
33 changes: 15 additions & 18 deletions docs/modules/ROOT/pages/cops_layout.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ start of the line where the `do` appeared.
start of the line where the expression started.
`either` (which is the default) : the `end` is allowed to be in either
location. The autofixer will default to `start_of_line`.
location. The autocorrect will default to `start_of_line`.
=== Examples
Expand Down Expand Up @@ -2825,7 +2825,6 @@ but_in_a_method_call([
# defined inside a method call.
# bad
# consistent
array = [
:value
]
Expand All @@ -2850,13 +2849,11 @@ and_in_a_method_call([
# brackets are indented to the same position.
# bad
# align_brackets
and_now_for_something = [
:completely_different
]
# good
# align_brackets
and_now_for_something = [
:completely_different
]
Expand Down Expand Up @@ -4487,20 +4484,20 @@ are recommended to further format the broken lines.
* `Layout/ArrayAlignment`
* `Layout/BlockAlignment`
* `Layout/BlockEndNewline`
* `LayoutClosingParenthesisIndentation`
* `LayoutFirstArgumentIndentation`
* `LayoutFirstArrayElementIndentation`
* `LayoutFirstHashElementIndentation`
* `LayoutFirstParameterIndentation`
* `LayoutHashAlignment`
* `LayoutIndentationWidth`
* `LayoutMultilineArrayLineBreaks`
* `LayoutMultilineBlockLayout`
* `LayoutMultilineHashBraceLayout`
* `LayoutMultilineHashKeyLineBreaks`
* `LayoutMultilineMethodArgumentLineBreaks`
* `LayoutMultilineMethodParameterLineBreaks`
* `Layout/ParameterAlignment`
* `Layout/ClosingParenthesisIndentation`
* `Layout/FirstArgumentIndentation`
* `Layout/FirstArrayElementIndentation`
* `Layout/FirstHashElementIndentation`
* `Layout/FirstParameterIndentation`
* `Layout/HashAlignment`
* `Layout/IndentationWidth`
* `Layout/MultilineArrayLineBreaks`
* `Layout/MultilineBlockLayout`
* `Layout/MultilineHashBraceLayout`
* `Layout/MultilineHashKeyLineBreaks`
* `Layout/MultilineMethodArgumentLineBreaks`
* `Layout/MultilineMethodParameterLineBreaks`
* `Layout//ParameterAlignment`
* `Style/BlockDelimiters`
Together, these cops will pretty print hashes, arrays,
Expand Down
57 changes: 48 additions & 9 deletions docs/modules/ROOT/pages/cops_lint.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6981,9 +6981,9 @@ end
| Enabled
| Yes
| Command-line only (Unsafe)
| Command-line only
| 0.11
| 1.61
| 1.66
|===
Checks for every useless assignment to local variable in every
Expand All @@ -6999,16 +6999,14 @@ Currently this cop has advanced logic that detects unreferenced
reassignments and properly handles varied cases such as branch, loop,
rescue, ensure, etc.
NOTE: Given the assignment `foo = 1, bar = 2`, removing unused variables
can lead to a syntax error, so this case is not autocorrected.
=== Safety
This cop's autocorrection is unsafe because removing assignment from
This cop's autocorrection avoids cases like `a ||= 1` because removing assignment from
operator assignment can cause NameError if this assignment has been used to declare
local variable. For example, replacing `a ||= 1` to `a || 1` may cause
a local variable. For example, replacing `a ||= 1` with `a || 1` may cause
"undefined local variable or method `a' for main:Object (NameError)".
NOTE: Given the assignment `foo = 1, bar = 2`, removing unused variables
can lead to a syntax error, so this case is not autocorrected.
=== Examples
[source,ruby]
Expand Down Expand Up @@ -7116,6 +7114,47 @@ def method(*args)
end
----
== Lint/UselessNumericOperation
|===
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
| Pending
| Yes
| Always
| 1.66
| -
|===
Certain numeric operations have no impact, being:
Adding or subtracting 0, multiplying or dividing by 1 or raising to the power of 1.
These are probably leftover from debugging, or are mistakes.
=== Examples
[source,ruby]
----
# bad
x + 0
x - 0
x * 1
x / 1
x ** 1
# good
x
# bad
x += 0
x -= 0
x *= 1
x /= 1
x **= 1
# good
x = x
----
== Lint/UselessRescue
|===
Expand Down
44 changes: 24 additions & 20 deletions docs/modules/ROOT/pages/cops_metrics.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ The maximum allowed length is configurable.
The cop can be configured to ignore blocks passed to certain methods.
You can set constructs you want to fold with `CountAsOne`.
Available are: 'array', 'hash', 'heredoc', and 'method_call'. Each construct
will be counted as one line regardless of its actual size.
Available are: 'array', 'hash', 'heredoc', and 'method_call'.
Each construct will be counted as one line regardless of its actual size.
NOTE: This cop does not apply for `Struct` definitions.
Expand All @@ -112,7 +113,7 @@ instead. By default, there are no methods to allowed.
=== Examples
==== CountAsOne: ['array', 'heredoc', 'method_call']
==== CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
[source,ruby]
----
Expand All @@ -122,7 +123,7 @@ something do
2
]
hash = { # +3
hash = { # +1
key: 'value'
}
Expand All @@ -135,7 +136,7 @@ something do
1,
2
)
end # 6 points
end # 4 points
----
=== Configurable attributes
Expand Down Expand Up @@ -228,14 +229,15 @@ Comment lines can optionally be ignored.
The maximum allowed length is configurable.
You can set constructs you want to fold with `CountAsOne`.
Available are: 'array', 'hash', 'heredoc', and 'method_call'. Each construct
will be counted as one line regardless of its actual size.
Available are: 'array', 'hash', 'heredoc', and 'method_call'.
Each construct will be counted as one line regardless of its actual size.
NOTE: This cop also applies for `Struct` definitions.
=== Examples
==== CountAsOne: ['array', 'heredoc', 'method_call']
==== CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
[source,ruby]
----
Expand All @@ -245,7 +247,7 @@ class Foo
2
]
HASH = { # +3
HASH = { # +1
key: 'value'
}
Expand All @@ -258,7 +260,7 @@ class Foo
1,
2
)
end # 6 points
end # 4 points
----
=== Configurable attributes
Expand Down Expand Up @@ -423,8 +425,9 @@ Comment lines can optionally be allowed.
The maximum allowed length is configurable.
You can set constructs you want to fold with `CountAsOne`.
Available are: 'array', 'hash', 'heredoc', and 'method_call'. Each construct
will be counted as one line regardless of its actual size.
Available are: 'array', 'hash', 'heredoc', and 'method_call'.
Each construct will be counted as one line regardless of its actual size.
NOTE: The `ExcludedMethods` and `IgnoredMethods` configuration is
deprecated and only kept for backwards compatibility.
Expand All @@ -433,7 +436,7 @@ By default, there are no methods to allowed.
=== Examples
==== CountAsOne: ['array', 'heredoc', 'method_call']
==== CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
[source,ruby]
----
Expand All @@ -443,7 +446,7 @@ def m
2
]
hash = { # +3
hash = { # +1
key: 'value'
}
Expand All @@ -456,7 +459,7 @@ def m
1,
2
)
end # 6 points
end # 4 points
----
=== Configurable attributes
Expand Down Expand Up @@ -506,12 +509,13 @@ Comment lines can optionally be ignored.
The maximum allowed length is configurable.
You can set constructs you want to fold with `CountAsOne`.
Available are: 'array', 'hash', 'heredoc', and 'method_call'. Each construct
will be counted as one line regardless of its actual size.
Available are: 'array', 'hash', 'heredoc', and 'method_call'.
Each construct will be counted as one line regardless of its actual size.
=== Examples
==== CountAsOne: ['array', 'heredoc', 'method_call']
==== CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
[source,ruby]
----
Expand All @@ -521,7 +525,7 @@ module M
2
]
HASH = { # +3
HASH = { # +1
key: 'value'
}
Expand All @@ -534,7 +538,7 @@ module M
1,
2
)
end # 6 points
end # 4 points
----
=== Configurable attributes
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/cops_naming.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ define_method(:even?) { |value| }
def_node_matcher(:is_even) { |value| }
# good
# def_node_matcher(:even?) { |value| }
def_node_matcher(:even?) { |value| }
----
=== Configurable attributes
Expand Down
Loading

0 comments on commit c8edd7d

Please sign in to comment.