Skip to content

Commit

Permalink
Cut 1.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed Aug 12, 2021
1 parent 6d44d57 commit a6d8d92
Show file tree
Hide file tree
Showing 14 changed files with 290 additions and 37 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.18.4 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
1.19.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.19.0 (2021-08-12)

### New features

* [#4182](https://github.com/rubocop/rubocop/issues/4182): Add `Lint/AmbiguousRange` cop to check for ranges with ambiguous boundaries. ([@dvandersluis][])
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.

```
$ rubocop -V
1.18.4 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
1.19.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 @@ -54,7 +54,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
in your `Gemfile`:

```rb
gem 'rubocop', '~> 1.18', require: false
gem 'rubocop', '~> 1.19', require: false
```

See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
Expand Down
10 changes: 5 additions & 5 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ Lint/AmbiguousOperator:
Lint/AmbiguousRange:
Description: Checks for ranges with ambiguous boundaries.
Enabled: pending
VersionAdded: '<<next>>'
VersionAdded: '1.19'
SafeAutoCorrect: false
RequireParenthesesForMethodChains: false

Expand Down Expand Up @@ -3164,7 +3164,7 @@ Style/CommentedKeyword:
Enabled: true
SafeAutoCorrect: false
VersionAdded: '0.51'
VersionChanged: '<<next>>'
VersionChanged: '1.19'

Style/ConditionalAssignment:
Description: >-
Expand Down Expand Up @@ -3613,7 +3613,7 @@ Style/IdenticalConditionalBranches:
Enabled: true
SafeAutoCorrect: false
VersionAdded: '0.36'
VersionChanged: '<<next>>'
VersionChanged: '1.19'

Style/IfInsideElse:
Description: 'Finds if nodes inside else, which can be converted to elsif.'
Expand Down Expand Up @@ -4418,7 +4418,7 @@ Style/RedundantSelfAssignment:
Style/RedundantSelfAssignmentBranch:
Description: 'Checks for places where conditional branch makes redundant self-assignment.'
Enabled: pending
VersionAdded: '<<next>>'
VersionAdded: '1.19'

Style/RedundantSort:
Description: >-
Expand Down Expand Up @@ -4936,7 +4936,7 @@ Style/WordArray:
StyleGuide: '#percent-w'
Enabled: true
VersionAdded: '0.9'
VersionChanged: '<<next>>'
VersionChanged: '1.19'
EnforcedStyle: percent
SupportedStyles:
# percent style: %w(word1 word2)
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: 'master'
version: '1.19'
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 @@ -191,6 +191,7 @@ In the following section you find all available cops:
* xref:cops_lint.adoc#lintambiguousassignment[Lint/AmbiguousAssignment]
* xref:cops_lint.adoc#lintambiguousblockassociation[Lint/AmbiguousBlockAssociation]
* xref:cops_lint.adoc#lintambiguousoperator[Lint/AmbiguousOperator]
* xref:cops_lint.adoc#lintambiguousrange[Lint/AmbiguousRange]
* xref:cops_lint.adoc#lintambiguousregexpliteral[Lint/AmbiguousRegexpLiteral]
* xref:cops_lint.adoc#lintassignmentincondition[Lint/AssignmentInCondition]
* xref:cops_lint.adoc#lintbigdecimalnew[Lint/BigDecimalNew]
Expand Down Expand Up @@ -516,6 +517,7 @@ In the following section you find all available cops:
* xref:cops_style.adoc#styleredundantreturn[Style/RedundantReturn]
* xref:cops_style.adoc#styleredundantself[Style/RedundantSelf]
* xref:cops_style.adoc#styleredundantselfassignment[Style/RedundantSelfAssignment]
* xref:cops_style.adoc#styleredundantselfassignmentbranch[Style/RedundantSelfAssignmentBranch]
* xref:cops_style.adoc#styleredundantsort[Style/RedundantSort]
* xref:cops_style.adoc#styleredundantsortby[Style/RedundantSortBy]
* xref:cops_style.adoc#styleregexpliteral[Style/RegexpLiteral]
Expand Down
28 changes: 21 additions & 7 deletions docs/modules/ROOT/pages/cops_layout.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3936,8 +3936,7 @@ first part. There are some exceptions, such as implicit return values, where the
concatenated string parts shall be indented regardless of `EnforcedStyle` configuration.

If `EnforcedStyle: indented` is set, it's the second line that shall be indented one step
more than the first line. Lines 3 and forward shall be aligned with line 2. Here too there
are exceptions. Values in a hash literal are always aligned.
more than the first line. Lines 3 and forward shall be aligned with line 2.

=== Examples

Expand All @@ -3961,11 +3960,6 @@ def some_method
'y' \
'z'
end
my_hash = {
first: 'a message' \
'in two parts'
}
----

==== EnforcedStyle: aligned (default)
Expand All @@ -3976,9 +3970,19 @@ my_hash = {
puts 'x' \
'y'
my_hash = {
first: 'a message' \
'in two parts'
}
# good
puts 'x' \
'y'
my_hash = {
first: 'a message' \
'in two parts'
}
----

==== EnforcedStyle: indented
Expand All @@ -3989,9 +3993,19 @@ puts 'x' \
result = 'x' \
'y'
my_hash = {
first: 'a message' \
'in two parts'
}
# good
result = 'x' \
'y'
my_hash = {
first: 'a message' \
'in two parts'
}
----

=== Configurable attributes
Expand Down
97 changes: 87 additions & 10 deletions docs/modules/ROOT/pages/cops_lint.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,93 @@ do_something(*some_array)

* https://rubystyle.guide#method-invocation-parens

== Lint/AmbiguousRange

|===
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged

| Pending
| Yes
| Yes (Unsafe)
| 1.19
| -
|===

This cop checks for ambiguous ranges.

Ranges have quite low precedence, which leads to unexpected behaviour when
using a range with other operators. This cop avoids that by making ranges
explicit by requiring parenthesis around complex range boundaries (anything
that is not a basic literal: numerics, strings, symbols, etc.).

NOTE: The cop auto-corrects by wrapping the entire boundary in parentheses, which
makes the outcome more explicit but is possible to not be the intention of the
programmer. For this reason, this cop's auto-correct is marked as unsafe (it
will not change the behaviour of the code, but will not necessarily match the
intent of the program).

This cop can be configured with `RequireParenthesesForMethodChains` in order to
specify whether method chains (including `self.foo`) should be wrapped in parens
by this cop.

NOTE: Regardless of this configuration, if a method receiver is a basic literal
value, it will be wrapped in order to prevent the ambiguity of `1..2.to_a`.

=== Examples

[source,ruby]
----
# bad
x || 1..2
(x || 1..2)
1..2.to_a
# good, unambiguous
1..2
'a'..'z'
:bar..:baz
MyClass::MIN..MyClass::MAX
@min..@max
a..b
-a..b
# good, ambiguity removed
x || (1..2)
(x || 1)..2
(x || 1)..(y || 2)
(1..2).to_a
----

==== RequireParenthesesForMethodChains: false (default)

[source,ruby]
----
# good
a.foo..b.bar
(a.foo)..(b.bar)
----

==== RequireParenthesesForMethodChains: true

[source,ruby]
----
# bad
a.foo..b.bar
# good
(a.foo)..(b.bar)
----

=== Configurable attributes

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

| RequireParenthesesForMethodChains
| `false`
| Boolean
|===

== Lint/AmbiguousRegexpLiteral

|===
Expand Down Expand Up @@ -2899,16 +2986,6 @@ x < y && y < z
10 <= x && x <= 20
----

=== Configurable attributes

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

| AllowMethodComparison
| `true`
| Boolean
|===

== Lint/NestedMethodDefinition

|===
Expand Down
17 changes: 16 additions & 1 deletion docs/modules/ROOT/pages/cops_naming.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ Flagged terms are configurable for the cop. For each flagged term an optional
Regex can be specified to identify offenses. Suggestions for replacing a flagged term can
be configured and will be displayed as part of the offense message.
An AllowedRegex can be specified for a flagged term to exempt allowed uses of the term.
`WholeWord: true` can be set on a flagged term to indicate the cop should only match when
a term matches the whole word (partial matches will not be offenses).

=== Examples

Expand Down Expand Up @@ -592,6 +594,19 @@ allow_list = %w(user1 user2)
# They had a master's degree
----

==== FlaggedTerms: { slave: { WholeWord: true } }

[source,ruby]
----
# Specify that only terms that are full matches will be flagged.
# bad
Slave
# good (won't be flagged despite containing `slave`)
TeslaVehicle
----

=== Configurable attributes

|===
Expand Down Expand Up @@ -626,7 +641,7 @@ allow_list = %w(user1 user2)
| Boolean

| FlaggedTerms
| `{"whitelist"=>{"Regex"=>/white[-_\s]?list/, "Suggestions"=>["allowlist", "permit"]}, "blacklist"=>{"Regex"=>/black[-_\s]?list/, "Suggestions"=>["denylist", "block"]}, "slave"=>{"Suggestions"=>["replica", "secondary", "follower"]}}`
| `{"whitelist"=>{"Regex"=>/white[-_\s]?list/, "Suggestions"=>["allowlist", "permit"]}, "blacklist"=>{"Regex"=>/black[-_\s]?list/, "Suggestions"=>["denylist", "block"]}, "slave"=>{"WholeWord"=>true, "Suggestions"=>["replica", "secondary", "follower"]}}`
|
|===

Expand Down
Loading

0 comments on commit a6d8d92

Please sign in to comment.