Skip to content

Commit

Permalink
Cut 1.33
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed Aug 4, 2022
1 parent 70e901d commit a9cef6d
Show file tree
Hide file tree
Showing 13 changed files with 376 additions and 63 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.32.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
1.33.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.33.0 (2022-08-04)

### Bug fixes

* [#10830](https://github.com/rubocop/rubocop/issues/10830): Fix an incorrect autocorrect for `Layout/FirstArgumentIndentation` when specifying `EnforcedStyle: with_fixed_indentation` of `Layout/ArgumentAlignment` and `EnforcedStyle: consistent` of `Layout/FirstArgumentIndentation` and enabling `Layout/FirstMethodArgumentLineBreak`. ([@koic][])
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.32.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
1.33.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.32', require: false
gem 'rubocop', '~> 1.33', require: false
```

See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
Expand Down
2 changes: 1 addition & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,7 @@ Lint/EmptyConditionalBody:
Enabled: true
AllowComments: true
VersionAdded: '0.89'
VersionChanged: '<<next>>'
VersionChanged: '1.33'

Lint/EmptyEnsure:
Description: 'Checks for empty ensure block.'
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.33'
nav:
- modules/ROOT/nav.adoc
88 changes: 77 additions & 11 deletions docs/modules/ROOT/pages/cops_lint.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ x != y # or x = !y
Checks for ambiguous block association with method
when param passed without parentheses.

This cop can customize ignored methods with `IgnoredMethods`.
By default, there are no methods to ignored.
This cop can customize allowed methods with `AllowedMethods`.
By default, there are no methods to allowed.

=== Examples

Expand All @@ -74,27 +74,52 @@ foo == bar { |b| b.baz }
foo = ->(bar) { bar.baz }
----

==== IgnoredMethods: [] (default)
==== AllowedMethods: [] (default)

[source,ruby]
----
# bad
expect { do_something }.to change { object.attribute }
----

==== IgnoredMethods: [change]
==== AllowedMethods: [change]

[source,ruby]
----
# good
expect { do_something }.to change { object.attribute }
----

==== AllowedPatterns: [] (default)

[source,ruby]
----
# bad
expect { do_something }.to change { object.attribute }
----

==== AllowedPatterns: [/change/]

[source,ruby]
----
# good
expect { do_something }.to change { object.attribute }
expect { do_something }.to not_change { object.attribute }
----

=== Configurable attributes

|===
| Name | Default value | Configurable values

| AllowedMethods
| `[]`
| Array

| AllowedPatterns
| `[]`
| Array

| IgnoredMethods
| `[]`
| Array
Expand Down Expand Up @@ -808,7 +833,18 @@ Specific default groups can be disabled if necessary:
[source,yaml]
----
Lint/Debugger:
WebConsole: ~
DebuggerMethods:
WebConsole: ~
----

You can also add your own methods by adding a new category:

[source,yaml]
----
Lint/Debugger:
DebuggerMethods:
MyDebugger:
MyDebugger.debug_this
----

=== Examples
Expand Down Expand Up @@ -1765,13 +1801,15 @@ end

| Enabled
| Yes
| No
| Yes
| 0.89
| -
| 1.33
|===

Checks for the presence of `if`, `elsif` and `unless` branches without a body.

NOTE: empty `else` branches are handled by `Style/EmptyElse`.

=== Examples

[source,ruby]
Expand Down Expand Up @@ -3449,6 +3487,10 @@ end
FileUtils.rm_f(path)
----

=== References

* https://rubystyle.guide#atomic-file-operations

== Lint/NonDeterministicRequireOrder

|===
Expand Down Expand Up @@ -3594,8 +3636,8 @@ always correct to raise if a value is not numeric.
NOTE: Some values cannot be converted properly using one of the `Kernel`
method (for instance, `Time` and `DateTime` values are allowed by this
cop by default). Similarly, Rails' duration methods do not work well
with `Integer()` and can be ignored with `IgnoredMethods`. By default,
there are no methods to ignored.
with `Integer()` and can be allowed with `AllowedMethods`. By default,
there are no methods to allowed.

=== Safety

Expand Down Expand Up @@ -3628,15 +3670,31 @@ foo.try { |i| Float(i) }
bar.send { |i| Complex(i) }
----

==== IgnoredMethods: [] (default)
==== AllowedMethods: [] (default)

[source,ruby]
----
# bad
10.minutes.to_i
----

==== AllowedMethods: [minutes]

[source,ruby]
----
# good
10.minutes.to_i
----

==== AllowedPatterns: [] (default)

[source,ruby]
----
# bad
10.minutes.to_i
----

==== IgnoredMethods: [minutes]
==== AllowedPatterns: [/min*/]

[source,ruby]
----
Expand All @@ -3657,6 +3715,14 @@ Time.now.to_datetime.to_i
|===
| Name | Default value | Configurable values

| AllowedMethods
| `[]`
| Array

| AllowedPatterns
| `[]`
| Array

| IgnoredMethods
| `[]`
| Array
Expand Down
58 changes: 50 additions & 8 deletions docs/modules/ROOT/pages/cops_metrics.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ You can have repeated "attributes" calls count as a single "branch".
For this purpose, attributes are any method with no argument; no attempt
is meant to distinguish actual `attr_reader` from other methods.

This cop also takes into account `IgnoredMethods` (defaults to `[]`)
This cop also takes into account `AllowedMethods` (defaults to `[]`)
And `AllowedPatterns` (defaults to `[]`)

=== Examples

Expand All @@ -54,6 +55,14 @@ end
|===
| Name | Default value | Configurable values

| AllowedMethods
| `[]`
| Array

| AllowedPatterns
| `[]`
| Array

| IgnoredMethods
| `[]`
| Array
Expand Down Expand Up @@ -95,8 +104,8 @@ will be counted as one line regardless of its actual size.


NOTE: The `ExcludedMethods` configuration is deprecated and only kept
for backwards compatibility. Please use `IgnoredMethods` instead.
By default, there are no methods to ignored.
for backwards compatibility. Please use `AllowedMethods` and `AllowedPatterns`
instead. By default, there are no methods to allowed.

NOTE: This cop does not apply for `Struct` definitions.

Expand Down Expand Up @@ -144,10 +153,18 @@ end # 5 points
| `[]`
| Array

| IgnoredMethods
| AllowedMethods
| `refine`
| Array

| AllowedPatterns
| `[]`
| Array

| IgnoredMethods
| `[]`
| Array

| Exclude
| `+**/*.gemspec+`
| Array
Expand Down Expand Up @@ -299,6 +316,14 @@ Blocks that are calls to builtin iteration methods
|===
| Name | Default value | Configurable values

| AllowedMethods
| `[]`
| Array

| AllowedPatterns
| `[]`
| Array

| IgnoredMethods
| `[]`
| Array
Expand All @@ -321,16 +346,17 @@ Blocks that are calls to builtin iteration methods
|===

Checks if the length of a method exceeds some maximum value.
Comment lines can optionally be ignored.
Comment lines can optionally be allowed.
The maximum allowed length is configurable.

You can set literals you want to fold with `CountAsOne`.
Available are: 'array', 'hash', and 'heredoc'. Each literal
will be counted as one line regardless of its actual size.

NOTE: The `ExcludedMethods` configuration is deprecated and only kept
for backwards compatibility. Please use `IgnoredMethods` instead.
By default, there are no methods to ignored.
NOTE: The `ExcludedMethods` and `IgnoredMethods` configuration is
deprecated and only kept for backwards compatibility.
Please use `AllowedMethods` and `AllowedPatterns` instead.
By default, there are no methods to allowed.

=== Examples

Expand Down Expand Up @@ -376,6 +402,14 @@ end # 5 points
| `[]`
| Array

| AllowedMethods
| `[]`
| Array

| AllowedPatterns
| `[]`
| Array

| IgnoredMethods
| `[]`
| Array
Expand Down Expand Up @@ -600,6 +634,14 @@ end # 7 complexity points
|===
| Name | Default value | Configurable values

| AllowedMethods
| `[]`
| Array

| AllowedPatterns
| `[]`
| Array

| IgnoredMethods
| `[]`
| Array
Expand Down
27 changes: 24 additions & 3 deletions docs/modules/ROOT/pages/cops_naming.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1075,9 +1075,30 @@ end
| 0.77
|===

Makes sure that predicates are named properly.
`is_a?` method is allowed by default.
These are customizable with `AllowedMethods` option.
Checks that predicate methods names end with a question mark and
do not start with a forbidden prefix.

A method is determined to be a predicate method if its name starts
with one of the prefixes defined in the `NamePrefix` configuration.
You can change what prefixes are considered by changing this option.
Any method name that starts with one of these prefixes is required by
the cop to end with a `?`. Other methods can be allowed by adding to
the `AllowedMethods` configuration.

NOTE: The `is_a?` method is allowed by default.

If `ForbiddenPrefixes` is set, methods that start with the configured
prefixes will not be allowed and will be removed by autocorrection.

In other words, if `ForbiddenPrefixes` is empty, a method named `is_foo`
will register an offense only due to the lack of question mark (and will be
autocorrected to `is_foo?`). If `ForbiddenPrefixes` contains `is_`,
`is_foo` will register an offense both because the ? is missing and because of
the `is_` prefix, and will be corrected to `foo?`.

NOTE: `ForbiddenPrefixes` is only applied to prefixes in `NamePrefix`;
a prefix in the former but not the latter will not be considered by
this cop.

=== Examples

Expand Down
Loading

0 comments on commit a9cef6d

Please sign in to comment.