Skip to content

Commit

Permalink
Cut 1.26
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed Mar 9, 2022
1 parent ff85270 commit e1e4637
Show file tree
Hide file tree
Showing 16 changed files with 130 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Expand Up @@ -38,7 +38,7 @@ output by `rubocop -V`, include them as well. Here's an example:

```
$ [bundle exec] rubocop -V
1.25.1 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
1.26.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
Expand Up @@ -2,6 +2,8 @@

## master (unreleased)

## 1.26.0 (2022-03-09)

### New features

* [#10419](https://github.com/rubocop/rubocop/pull/10419): Add new `Style/NestedFileDirname` cop. ([@koic][])
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -17,7 +17,7 @@ do so.

```
$ rubocop -V
1.25.1 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
1.26.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
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.25', require: false
gem 'rubocop', '~> 1.26', require: false
```

See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
Expand Down
8 changes: 4 additions & 4 deletions config/default.yml
Expand Up @@ -1818,7 +1818,7 @@ Lint/InheritException:
Enabled: true
SafeAutoCorrect: false
VersionAdded: '0.41'
VersionChanged: '<<next>>'
VersionChanged: '1.26'
# The default base class in favour of `Exception`.
EnforcedStyle: standard_error
SupportedStyles:
Expand Down Expand Up @@ -2013,7 +2013,7 @@ Lint/RedundantDirGlobSort:
Description: 'Checks for redundant `sort` method to `Dir.glob` and `Dir[]`.'
Enabled: pending
VersionAdded: '1.8'
VersionChanged: '<<next>>'
VersionChanged: '1.26'
SafeAutoCorrect: false

Lint/RedundantRequireStatement:
Expand Down Expand Up @@ -3548,7 +3548,7 @@ Style/For:
Enabled: true
SafeAutoCorrect: false
VersionAdded: '0.13'
VersionChanged: '<<next>>'
VersionChanged: '1.26'
EnforcedStyle: each
SupportedStyles:
- each
Expand Down Expand Up @@ -4130,7 +4130,7 @@ Style/NegatedWhile:
Style/NestedFileDirname:
Description: 'Checks for nested `File.dirname`.'
Enabled: pending
VersionAdded: '<<next>>'
VersionAdded: '1.26'

Style/NestedModifier:
Description: 'Avoid using nested modifiers.'
Expand Down
2 changes: 1 addition & 1 deletion docs/antora.yml
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.26'
nav:
- modules/ROOT/nav.adoc
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/cops.adoc
Expand Up @@ -484,6 +484,7 @@ In the following section you find all available cops:
* xref:cops_style.adoc#stylenegatedifelsecondition[Style/NegatedIfElseCondition]
* xref:cops_style.adoc#stylenegatedunless[Style/NegatedUnless]
* xref:cops_style.adoc#stylenegatedwhile[Style/NegatedWhile]
* xref:cops_style.adoc#stylenestedfiledirname[Style/NestedFileDirname]
* xref:cops_style.adoc#stylenestedmodifier[Style/NestedModifier]
* xref:cops_style.adoc#stylenestedparenthesizedcalls[Style/NestedParenthesizedCalls]
* xref:cops_style.adoc#stylenestedternaryoperator[Style/NestedTernaryOperator]
Expand Down
15 changes: 7 additions & 8 deletions docs/modules/ROOT/pages/cops_layout.adoc
Expand Up @@ -5037,13 +5037,12 @@ end
| -
|===

This cop checks the indentation of the right hand side operand in
binary operations that span more than one line.
This cop checks the indentation of the right hand side operand in binary operations that
span more than one line.

The `aligned` style checks that operators are aligned if they are part
of an `if` or `while` condition, a `return` statement, etc. In other
contexts, the second operand should be indented regardless of enforced
style.
The `aligned` style checks that operators are aligned if they are part of an `if` or `while`
condition, an explicit `return` statement, etc. In other contexts, the second operand should
be indented regardless of enforced style.

=== Examples

Expand All @@ -5055,14 +5054,14 @@ style.
if a +
b
something &&
something_else
something_else
end
# good
if a +
b
something &&
something_else
something_else
end
----

Expand Down
39 changes: 21 additions & 18 deletions docs/modules/ROOT/pages/cops_lint.adoc
Expand Up @@ -2680,19 +2680,24 @@ end

| Enabled
| Yes
| Yes
| Yes (Unsafe)
| 0.41
| -
| 1.26
|===

This cop looks for error classes inheriting from `Exception`
and its standard library subclasses, excluding subclasses of
`StandardError`. It is configurable to suggest using either
`RuntimeError` (default) or `StandardError` instead.
This cop looks for error classes inheriting from `Exception`.
It is configurable to suggest using either `StandardError` (default) or
`RuntimeError` instead.

=== Safety

This cop's autocorrection is unsafe because `rescue` that omit
exception class handle `StandardError` and its subclasses,
but not `Exception` and its subclasses.

=== Examples

==== EnforcedStyle: runtime_error (default)
==== EnforcedStyle: standard_error (default)

[source,ruby]
----
Expand All @@ -2704,12 +2709,12 @@ C = Class.new(Exception)
# good
class C < RuntimeError; end
class C < StandardError; end
C = Class.new(RuntimeError)
C = Class.new(StandardError)
----

==== EnforcedStyle: standard_error
==== EnforcedStyle: runtime_error

[source,ruby]
----
Expand All @@ -2721,9 +2726,9 @@ C = Class.new(Exception)
# good
class C < StandardError; end
class C < RuntimeError; end
C = Class.new(StandardError)
C = Class.new(RuntimeError)
----

=== Configurable attributes
Expand All @@ -2732,8 +2737,8 @@ C = Class.new(StandardError)
| Name | Default value | Configurable values

| EnforcedStyle
| `runtime_error`
| `runtime_error`, `standard_error`
| `standard_error`
| `standard_error`, `runtime_error`
|===

== Lint/InterpolationCheck
Expand Down Expand Up @@ -4000,17 +4005,15 @@ NOTE: Required Ruby version: 3.0
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed

| Pending
| No
| Yes
| Yes (Unsafe)
| 1.8
| -
| 1.26
|===

Sort globbed results by default in Ruby 3.0.
This cop checks for redundant `sort` method to `Dir.glob` and `Dir[]`.

=== Safety

This cop is unsafe, in case of having a file and a directory with
identical names, since directory will be loaded before the file, which
will break `exe/files.rb` that rely on `exe.rb` file.
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/cops_metrics.adoc
Expand Up @@ -148,7 +148,7 @@ end # 5 points
| Array

| Exclude
| `**/*.gemspec`
| `+**/*.gemspec+`
| Array
|===

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/cops_naming.adoc
Expand Up @@ -1122,7 +1122,7 @@ end
| Array

| Exclude
| `spec/**/*`
| `+spec/**/*+`
| Array
|===

Expand Down
10 changes: 7 additions & 3 deletions docs/modules/ROOT/pages/cops_security.adoc
Expand Up @@ -205,6 +205,8 @@ This cop checks for the use of YAML class methods which have
potential security issues leading to remote code execution when
loading from an untrusted source.

NOTE: Ruby 3.1+ (Psych 4) uses `Psych.load` as `Psych.safe_load` by default.

=== Safety

The behaviour of the code might change depending on what was
Expand All @@ -215,11 +217,13 @@ in the YAML payload, since `YAML.safe_load` is more restrictive.
[source,ruby]
----
# bad
YAML.load("--- foo")
YAML.load("--- !ruby/object:Foo {}") # Psych 3 is unsafe by default
# good
YAML.safe_load("--- foo")
YAML.dump("foo")
YAML.safe_load("--- !ruby/object:Foo {}", [Foo]) # Ruby 2.5 (Psych 3)
YAML.safe_load("--- !ruby/object:Foo {}", permitted_classes: [Foo]) # Ruby 3.0- (Psych 3)
YAML.load("--- !ruby/object:Foo {}", permitted_classes: [Foo]) # Ruby 3.1+ (Psych 4)
YAML.dump(foo)
----

=== References
Expand Down
63 changes: 51 additions & 12 deletions docs/modules/ROOT/pages/cops_style.adoc
Expand Up @@ -2316,28 +2316,34 @@ class/singleton methods are checked.
----
# bad
def foo()
# does a thing
do_something
end
# good
def foo
# does a thing
do_something
end
# also good
def foo() does_a_thing end
# bad
def foo() = do_something
# good
def foo = do_something
# good (without parentheses it's a syntax error)
def foo() do_something end
----

[source,ruby]
----
# bad
def Baz.foo()
# does a thing
do_something
end
# good
def Baz.foo
# does a thing
do_something
end
----

Expand Down Expand Up @@ -2617,7 +2623,7 @@ module A
| Array

| Exclude
| `spec/**/*`, `test/**/*`
| `+spec/**/*+`, `+test/**/*+`
| Array
|===

Expand Down Expand Up @@ -2738,7 +2744,7 @@ end
| Name | Default value | Configurable values

| Exclude
| `spec/**/*`, `test/**/*`
| `+spec/**/*+`, `+test/**/*+`
| Array

| RequireForNonPublicMethods
Expand Down Expand Up @@ -3916,16 +3922,21 @@ a.fdiv(b)

| Enabled
| Yes
| Yes
| Yes (Unsafe)
| 0.13
| 0.59
| 1.26
|===

This cop looks for uses of the `for` keyword or `each` method. The
preferred alternative is set in the EnforcedStyle configuration
parameter. An `each` call with a block on a single line is always
allowed.

=== Safety

This cop's autocorrection is unsafe because the scope of
variables is different between `each` and `for`.

=== Examples

==== EnforcedStyle: each (default)
Expand Down Expand Up @@ -5609,7 +5620,7 @@ ip_address = ENV['DEPLOYMENT_IP_ADDRESS']
| Array

| Exclude
| `**/*.gemfile`, `**/Gemfile`, `**/gems.rb`, `**/*.gemspec`
| `+**/*.gemfile+`, `+**/Gemfile+`, `+**/gems.rb+`, `+**/*.gemspec+`
| Array
|===

Expand Down Expand Up @@ -7602,6 +7613,34 @@ bar while !foo && baz

* https://rubystyle.guide#until-for-negatives

== Style/NestedFileDirname

NOTE: Required Ruby version: 3.1

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

| Pending
| Yes
| Yes
| 1.26
| -
|===

This cop checks for nested `File.dirname`.
It replaces nested `File.dirname` with the level argument introduced in Ruby 3.1.

=== Examples

[source,ruby]
----
# bad
File.dirname(File.dirname(path))
# good
File.dirname(path, 2)
----

== Style/NestedModifier

|===
Expand Down Expand Up @@ -8316,7 +8355,7 @@ bar.baz > 0
| Array

| Exclude
| `spec/**/*`
| `+spec/**/*+`
| Array
|===

Expand Down

0 comments on commit e1e4637

Please sign in to comment.