Skip to content

Commit

Permalink
Cut 1.43
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed Jan 10, 2023
1 parent d1e7287 commit c311137
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 12 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.42.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2) [x86_64-linux]
1.43.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2) [x86_64-linux]
- rubocop-performance 1.9.1
- rubocop-rspec 2.0.0
```
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## master (unreleased)

## 1.43.0 (2023-01-10)

### New features

* [#11359](https://github.com/rubocop/rubocop/issues/11359): Add new `Lint/UselessRescue` cop. ([@fatkodima][])
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.42.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2) [x86_64-linux]
1.43.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2) [x86_64-linux]
- rubocop-performance 1.9.1
- rubocop-rspec 2.0.0
```
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
in your `Gemfile`:

```rb
gem 'rubocop', '~> 1.42', require: false
gem 'rubocop', '~> 1.43', require: false
```

See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
Expand Down
4 changes: 2 additions & 2 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2455,7 +2455,7 @@ Lint/UselessMethodDefinition:
Lint/UselessRescue:
Description: 'Checks for useless `rescue`s.'
Enabled: pending
VersionAdded: '<<next>>'
VersionAdded: '1.43'

Lint/UselessRuby2Keywords:
Description: 'Finds unnecessary uses of `ruby2_keywords`.'
Expand Down Expand Up @@ -5449,7 +5449,7 @@ Style/YodaExpression:
Enabled: false
Safe: false
VersionAdded: '1.42'
VersionChanged: '<<next>>'
VersionChanged: '1.43'
SupportedOperators:
- '*'
- '+'
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.43'
nav:
- modules/ROOT/nav.adoc
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/cops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,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#lintuselessrescue[Lint/UselessRescue]
* xref:cops_lint.adoc#lintuselessruby2keywords[Lint/UselessRuby2Keywords]
* xref:cops_lint.adoc#lintuselesssettercall[Lint/UselessSetterCall]
* xref:cops_lint.adoc#lintuselesstimes[Lint/UselessTimes]
Expand Down
59 changes: 59 additions & 0 deletions docs/modules/ROOT/pages/cops_lint.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6938,6 +6938,65 @@ def method(*args)
end
----

== Lint/UselessRescue

|===
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed

| Pending
| Yes
| No
| 1.43
| -
|===

Checks for useless `rescue`s, which only reraise rescued exceptions.

=== Examples

[source,ruby]
----
# bad
def foo
do_something
rescue
raise
end
# bad
def foo
do_something
rescue => e
raise # or 'raise e', or 'raise $!', or 'raise $ERROR_INFO'
end
# good
def foo
do_something
rescue
do_cleanup
raise
end
# bad (latest rescue)
def foo
do_something
rescue ArgumentError
# noop
rescue
raise
end
# good (not the latest rescue)
def foo
do_something
rescue ArgumentError
raise
rescue
# noop
end
----

== Lint/UselessRuby2Keywords

|===
Expand Down
14 changes: 14 additions & 0 deletions docs/modules/ROOT/pages/cops_metrics.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,20 @@ The maximum number of parameters is configurable.
Keyword arguments can optionally be excluded from the total count,
as they add less complexity than positional or optional parameters.

Any number of arguments for `initialize` method inside a block of
`Struct.new` and `Data.define` like this is always allowed:

[source,ruby]
----
Struct.new(:one, :two, :three, :four, :five, keyword_init: true) do
def initialize(one:, two:, three:, four:, five:)
end
end
----

This is because checking the number of arguments of the `initialize` method
does not make sense.

NOTE: Explicit block argument `&block` is not counted to prevent
erroneous change that is avoided by making block argument implicit.

Expand Down
15 changes: 11 additions & 4 deletions docs/modules/ROOT/pages/cops_style.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5171,7 +5171,7 @@ execute(sql).values.each { |v| p v }
| Name | Default value | Configurable values

| AllowedReceivers
| `[]`
| `Thread.current`
| Array
|===

Expand Down Expand Up @@ -7330,7 +7330,7 @@ a <= b ? a : b

| Disabled
| Yes
| No
| Yes
| 0.30
| 0.38
|===
Expand Down Expand Up @@ -15256,17 +15256,24 @@ bar > 10
|===
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed

| Pending
| Disabled
| No
| Yes (Unsafe)
| 1.42
| -
| 1.43
|===

Forbids Yoda expressions, i.e. binary operations (using `*`, `+`, `&`, `|`,
and `^` operators) where the order of expression is reversed, eg. `1 + x`.
This cop complements `Style/YodaCondition` cop, which has a similar purpose.

This cop is disabled by default to respect user intentions such as:

[source,ruby]
----
config.server_port = 9000 + ENV["TEST_ENV_NUMBER"].to_i
----

=== Safety

This cop is unsafe because binary operators can be defined
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/installation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ in your `Gemfile`:

[source,rb]
----
gem 'rubocop', '~> 1.42', require: false
gem 'rubocop', '~> 1.43', require: false
----

.A Modular RuboCop
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module RuboCop
# This module holds the RuboCop version information.
module Version
STRING = '1.42.0'
STRING = '1.43.0'

MSG = '%<version>s (using Parser %<parser_version>s, ' \
'rubocop-ast %<rubocop_ast_version>s, ' \
Expand Down
34 changes: 34 additions & 0 deletions relnotes/v1.43.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### New features

* [#11359](https://github.com/rubocop/rubocop/issues/11359): Add new `Lint/UselessRescue` cop. ([@fatkodima][])
* [#11389](https://github.com/rubocop/rubocop/pull/11389): Add autocorrect for `Style/MissingElse`. ([@FnControlOption][])

### Bug fixes

* [#11386](https://github.com/rubocop/rubocop/pull/11386): Fix a false positive for `Style/OperatorMethodCall` when using anonymous forwarding. ([@koic][])
* [#11409](https://github.com/rubocop/rubocop/issues/11409): Fix an incorrect autocorrect for `Style/HashSyntax` when using hash value omission and `EnforcedStyle: no_mixed_keys`. ([@koic][])
* [#11405](https://github.com/rubocop/rubocop/issues/11405): Fix undefined method `range_between' for Style/WhileUntilModifier. ([@such][])
* [#11374](https://github.com/rubocop/rubocop/pull/11374): Fix an error for `Style/StringHashKeys` when using invalid symbol in encoding UTF-8 as keys. ([@koic][])
* [#11392](https://github.com/rubocop/rubocop/pull/11392): Fix an incorrect autocorrect for `Style/RedundantDoubleSplatHashBraces` using double splat in double splat hash braces. ([@koic][])
* [#8990](https://github.com/rubocop/rubocop/issues/8990): Make `Style/HashEachMethods` aware of built-in `Thread.current`. ([@koic][])
* [#11390](https://github.com/rubocop/rubocop/issues/11390): Fix an incorrect autocorrect for `Style/HashSyntax` when hash first argument key and hash value only are the same which has a method call on the next line. ([@koic][])
* [#11379](https://github.com/rubocop/rubocop/pull/11379): Fix a false negative for `Style/OperatorMethodCall` when using `a.+ b.something`. ([@koic][])
* [#11180](https://github.com/rubocop/rubocop/issues/11180): Fix an error for `Style/RedundantRegexpEscape` when using `%r` to provide regexp expressions. ([@si-lens][])
* [#11403](https://github.com/rubocop/rubocop/pull/11403): Fix bad offense for parenthesised calls in literals for `omit_parentheses` style in `Style/MethodCallWithArgsParentheses`. ([@gsamokovarov][])
* [#11407](https://github.com/rubocop/rubocop/pull/11407): Fix an error for `Style/HashSyntax` when expression follows hash key assignment. ([@fatkodima][])
* [#11377](https://github.com/rubocop/rubocop/issues/11377): Fix `Style/OperatorMethodCall` when forwarding arguments. ([@sambostock][])

### Changes

* [#11382](https://github.com/rubocop/rubocop/pull/11382): Require `unicode-display_width` 2.4.0 or higher. ([@fatkodima][])
* [#11381](https://github.com/rubocop/rubocop/pull/11381): Require Parser 3.2.0.0 or higher. ([@koic][])
* [#11380](https://github.com/rubocop/rubocop/pull/11380): Disable `Style/YodaExpression` by default. ([@koic][])
* [#11303](https://github.com/rubocop/rubocop/issues/11303): Make `Metrics/ParameterLists` aware of `Struct.new` and `Data.define` blocks. ([@koic][])

[@fatkodima]: https://github.com/fatkodima
[@FnControlOption]: https://github.com/FnControlOption
[@koic]: https://github.com/koic
[@such]: https://github.com/such
[@si-lens]: https://github.com/si-lens
[@gsamokovarov]: https://github.com/gsamokovarov
[@sambostock]: https://github.com/sambostock

0 comments on commit c311137

Please sign in to comment.