From 25112e6cbc5198ee5c19cbc3d443524d79e4b609 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Mon, 13 Sep 2021 16:09:10 +0300 Subject: [PATCH] Cut 1.21 --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- CHANGELOG.md | 2 + CONTRIBUTING.md | 2 +- README.md | 2 +- config/default.yml | 10 ++-- docs/antora.yml | 2 +- docs/modules/ROOT/pages/cops.adoc | 2 + docs/modules/ROOT/pages/cops_bundler.adoc | 22 +++---- docs/modules/ROOT/pages/cops_layout.adoc | 4 -- docs/modules/ROOT/pages/cops_lint.adoc | 72 +++++++++++++++++++++++ docs/modules/ROOT/pages/cops_naming.adoc | 4 +- docs/modules/ROOT/pages/cops_style.adoc | 31 ++++++---- docs/modules/ROOT/pages/installation.adoc | 2 +- lib/rubocop/version.rb | 2 +- relnotes/v1.21.0.md | 24 ++++++++ 15 files changed, 142 insertions(+), 41 deletions(-) create mode 100644 relnotes/v1.21.0.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 151a983a4e07..c324c1b21350 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -38,7 +38,7 @@ output by `rubocop -V`, include them as well. Here's an example: ``` $ [bundle exec] rubocop -V -1.20.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux) +1.21.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 ``` diff --git a/CHANGELOG.md b/CHANGELOG.md index be76fedc4a20..e23912a030da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## master (unreleased) +## 1.21.0 (2021-09-13) + ### New features * [#7849](https://github.com/rubocop/rubocop/issues/7849): Add new `Lint/AmbiguousOperatorPrecedence` cop. ([@dvandersluis][]) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5b63b75dcf15..796863125dff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,7 +17,7 @@ do so. ``` $ rubocop -V -1.20.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux) +1.21.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 ``` diff --git a/README.md b/README.md index b007ba553650..a7a903de93f3 100644 --- a/README.md +++ b/README.md @@ -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.20', require: false +gem 'rubocop', '~> 1.21', require: false ``` See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details. diff --git a/config/default.yml b/config/default.yml index d283be4622ad..5f7b357ce2a7 100644 --- a/config/default.yml +++ b/config/default.yml @@ -1452,7 +1452,7 @@ Lint/AmbiguousOperatorPrecedence: Checks for expressions containing multiple binary operations with ambiguous precedence. Enabled: pending - VersionAdded: '<>' + VersionAdded: '1.21' Lint/AmbiguousRange: Description: Checks for ranges with ambiguous boundaries. @@ -1780,7 +1780,7 @@ Lint/ImplicitStringConcatenation: Lint/IncompatibleIoSelectWithFiberScheduler: Description: 'Checks for `IO.select` that is incompatible with Fiber Scheduler.' Enabled: pending - VersionAdded: '<>' + VersionAdded: '1.21' Lint/IneffectiveAccessModifier: Description: >- @@ -2576,7 +2576,7 @@ Naming/InclusiveLanguage: Description: 'Recommend the use of inclusive language instead of problematic terms.' Enabled: false VersionAdded: '1.18' - VersionChanged: '<>' + VersionChanged: '1.21' CheckIdentifiers: true CheckConstants: true CheckVariables: true @@ -2810,7 +2810,7 @@ Style/AndOr: Enabled: true SafeAutoCorrect: false VersionAdded: '0.9' - VersionChanged: '<>' + VersionChanged: '1.21' # Whether `and` and `or` are banned only in conditionals (conditionals) # or completely (always). EnforcedStyle: conditionals @@ -2846,7 +2846,7 @@ Style/AsciiComments: StyleGuide: '#english-comments' Enabled: false VersionAdded: '0.9' - VersionChanged: '<>' + VersionChanged: '1.21' AllowedChars: - © diff --git a/docs/antora.yml b/docs/antora.yml index 52f2c59156f5..f71cd93f68e2 100644 --- a/docs/antora.yml +++ b/docs/antora.yml @@ -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.21' nav: - modules/ROOT/nav.adoc diff --git a/docs/modules/ROOT/pages/cops.adoc b/docs/modules/ROOT/pages/cops.adoc index 589d6d5eb94b..fa6bd025a338 100644 --- a/docs/modules/ROOT/pages/cops.adoc +++ b/docs/modules/ROOT/pages/cops.adoc @@ -192,6 +192,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#lintambiguousoperatorprecedence[Lint/AmbiguousOperatorPrecedence] * xref:cops_lint.adoc#lintambiguousrange[Lint/AmbiguousRange] * xref:cops_lint.adoc#lintambiguousregexpliteral[Lint/AmbiguousRegexpLiteral] * xref:cops_lint.adoc#lintassignmentincondition[Lint/AssignmentInCondition] @@ -235,6 +236,7 @@ In the following section you find all available cops: * xref:cops_lint.adoc#lintheredocmethodcallposition[Lint/HeredocMethodCallPosition] * xref:cops_lint.adoc#lintidentitycomparison[Lint/IdentityComparison] * xref:cops_lint.adoc#lintimplicitstringconcatenation[Lint/ImplicitStringConcatenation] +* xref:cops_lint.adoc#lintincompatibleioselectwithfiberscheduler[Lint/IncompatibleIoSelectWithFiberScheduler] * xref:cops_lint.adoc#lintineffectiveaccessmodifier[Lint/IneffectiveAccessModifier] * xref:cops_lint.adoc#lintinheritexception[Lint/InheritException] * xref:cops_lint.adoc#lintinterpolationcheck[Lint/InterpolationCheck] diff --git a/docs/modules/ROOT/pages/cops_bundler.adoc b/docs/modules/ROOT/pages/cops_bundler.adoc index e73687acb65f..a66591962147 100644 --- a/docs/modules/ROOT/pages/cops_bundler.adoc +++ b/docs/modules/ROOT/pages/cops_bundler.adoc @@ -342,18 +342,18 @@ gem 'rubocop', tag: 'v1.17.0' | - |=== -The symbol argument `:gemcutter`, `:rubygems`, and `:rubyforge` -are deprecated. So please change your source to URL string that -'https://rubygems.org' if possible, or 'http://rubygems.org' if not. +Passing symbol arguments to `source` (e.g. `source :rubygems`) is +deprecated because they default to using HTTP requests. Instead, specify +`'https://rubygems.org'` if possible, or `'http://rubygems.org'` if not. -This autocorrect will replace these symbols with 'https://rubygems.org'. -Because it is secure, HTTPS request is strongly recommended. And in -most use cases HTTPS will be fine. +When autocorrecting, this cop will replace symbol arguments with +`'https://rubygems.org'`. -However, it don't replace all `sources` of `http://` with `https://`. -For example, when specifying an internal gem server using HTTP on the -intranet, a use case where HTTPS cannot be specified was considered. -Consider using HTTP only if you cannot use HTTPS. +This cop will not replace existing sources that use `http://`. This may +be necessary where HTTPS is not available. For example, where using an +internal gem server via an intranet, or where HTTPS is prohibited. +However, you should strongly prefer `https://` where possible, as it is +more secure. === Examples @@ -366,7 +366,7 @@ source :rubyforge # good source 'https://rubygems.org' # strongly recommended -source 'http://rubygems.org' +source 'http://rubygems.org' # use only if HTTPS is unavailable ---- === Configurable attributes diff --git a/docs/modules/ROOT/pages/cops_layout.adoc b/docs/modules/ROOT/pages/cops_layout.adoc index 913560bacaec..f32bb6ba372a 100644 --- a/docs/modules/ROOT/pages/cops_layout.adoc +++ b/docs/modules/ROOT/pages/cops_layout.adoc @@ -4096,10 +4096,6 @@ bar: "0000000000", baz: "0000000000"} |=== | Name | Default value | Configurable values -| AutoCorrect -| `true` -| Boolean - | Max | `120` | Integer diff --git a/docs/modules/ROOT/pages/cops_lint.adoc b/docs/modules/ROOT/pages/cops_lint.adoc index 36dc1d912ff3..1e7a1604adb2 100644 --- a/docs/modules/ROOT/pages/cops_lint.adoc +++ b/docs/modules/ROOT/pages/cops_lint.adoc @@ -133,6 +133,47 @@ do_something(*some_array) * https://rubystyle.guide#method-invocation-parens +== Lint/AmbiguousOperatorPrecedence + +|=== +| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged + +| Pending +| Yes +| Yes +| 1.21 +| - +|=== + +This cop looks for expressions containing multiple binary operators +where precedence is ambiguous due to lack of parentheses. For example, +in `1 + 2 * 3`, the multiplication will happen before the addition, but +lexically it appears that the addition will happen first. + +The cop does not consider unary operators (ie. `!a` or `-b`) or comparison +operators (ie. `a =~ b`) because those are not ambiguous. + +NOTE: Ranges are handled by `Lint/AmbiguousRange`. + +=== Examples + +[source,ruby] +---- +# bad +a + b * c +a || b && c +a ** b + c + +# good (different precedence) +a + (b * c) +a || (b && c) +(a ** b) + c + +# good (same precedence) +a + b + c +a * b / c % d +---- + == Lint/AmbiguousRange |=== @@ -2478,6 +2519,37 @@ array = [ ] ---- +== Lint/IncompatibleIoSelectWithFiberScheduler + +|=== +| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged + +| Pending +| Yes +| Yes +| 1.21 +| - +|=== + +This cop checks for `IO.select` that is incompatible with Fiber Scheduler since Ruby 3.0. + +=== Examples + +[source,ruby] +---- +# bad +IO.select([io], [], [], timeout) + +# good +io.wait_readable(timeout) + +# bad +IO.select([], [io], [], timeout) + +# good +io.wait_writable(timeout) +---- + == Lint/IneffectiveAccessModifier |=== diff --git a/docs/modules/ROOT/pages/cops_naming.adoc b/docs/modules/ROOT/pages/cops_naming.adoc index bc93d337d877..61856567f714 100644 --- a/docs/modules/ROOT/pages/cops_naming.adoc +++ b/docs/modules/ROOT/pages/cops_naming.adoc @@ -514,11 +514,11 @@ EOS |=== | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged -| Pending +| Disabled | Yes | No | 1.18 -| - +| 1.21 |=== This cops recommends the use of inclusive language instead of problematic terms. diff --git a/docs/modules/ROOT/pages/cops_style.adoc b/docs/modules/ROOT/pages/cops_style.adoc index 45b33416363b..86c3922a1498 100644 --- a/docs/modules/ROOT/pages/cops_style.adoc +++ b/docs/modules/ROOT/pages/cops_style.adoc @@ -230,15 +230,19 @@ alias_method :bar, :foo | Enabled | Yes -| Yes +| Yes (Unsafe) | 0.9 -| 0.25 +| 1.21 |=== This cop checks for uses of `and` and `or`, and suggests using `&&` and `||` instead. It can be configured to check only in conditions or in all contexts. +It is marked as unsafe auto-correction because it may change the +operator precedence between logical operators (`&&` and `||`) and +semantic operators (`and` and `or`). + === Examples ==== EnforcedStyle: always @@ -443,11 +447,11 @@ array literal or the second is a string literal. |=== | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged -| Enabled +| Disabled | Yes | No | 0.9 -| 0.52 +| 1.21 |=== This cop checks for non-ascii (non-English) characters @@ -914,12 +918,14 @@ end This cop checks for uses of the case equality operator(===). +If `AllowOnConstant` option is enabled, the cop will ignore violations when the receiver of +the case equality operator is a constant. + === Examples [source,ruby] ---- # bad -Array === something (1..100) === 7 /something/ === some_string @@ -929,21 +935,20 @@ something.is_a?(Array) /something/.match?(some_string) ---- -==== AllowOnConstant +==== AllowOnConstant: false (default) [source,ruby] ---- -# Style/CaseEquality: -# AllowOnConstant: true - # bad -(1..100) === 7 -/something/ === some_string +Array === something +---- + +==== AllowOnConstant: true +[source,ruby] +---- # good Array === something -(1..100).include?(7) -/something/.match?(some_string) ---- === Configurable attributes diff --git a/docs/modules/ROOT/pages/installation.adoc b/docs/modules/ROOT/pages/installation.adoc index 0dff82724a28..1bc442f5ba36 100644 --- a/docs/modules/ROOT/pages/installation.adoc +++ b/docs/modules/ROOT/pages/installation.adoc @@ -22,7 +22,7 @@ in your `Gemfile`: [source,rb] ---- -gem 'rubocop', '~> 1.20', require: false +gem 'rubocop', '~> 1.21', require: false ---- NOTE: You can check out our progress on the road to version 1.0 https://github.com/rubocop/rubocop/milestone/4[here]. diff --git a/lib/rubocop/version.rb b/lib/rubocop/version.rb index daafffd58428..a0408599d954 100644 --- a/lib/rubocop/version.rb +++ b/lib/rubocop/version.rb @@ -3,7 +3,7 @@ module RuboCop # This module holds the RuboCop version information. module Version - STRING = '1.20.0' + STRING = '1.21.0' MSG = '%s (using Parser %s, '\ 'rubocop-ast %s, ' \ diff --git a/relnotes/v1.21.0.md b/relnotes/v1.21.0.md new file mode 100644 index 000000000000..49042a4c941b --- /dev/null +++ b/relnotes/v1.21.0.md @@ -0,0 +1,24 @@ +### New features + +* [#7849](https://github.com/rubocop/rubocop/issues/7849): Add new `Lint/AmbiguousOperatorPrecedence` cop. ([@dvandersluis][]) +* [#9061](https://github.com/rubocop/rubocop/issues/9061): Add new `Lint/IncompatibleIoSelectWithFiberScheduler` cop. ([@koic][]) + +### Bug fixes + +* [#10067](https://github.com/rubocop/rubocop/pull/10067): Fix an error for `Lint/NumberConversion` when using nested number conversion methods. ([@koic][]) +* [#10054](https://github.com/rubocop/rubocop/pull/10054): Fix a false positive for `Layout/SpaceAroundOperators` when match operators between `<<` and `+=`. ([@koic][]) +* [#10061](https://github.com/rubocop/rubocop/issues/10061): Fix a false positive for `Style/RedundantSort` when using `size` method in the block. ([@koic][]) +* [#10063](https://github.com/rubocop/rubocop/pull/10063): Fix a false positive for `Layout/SingleLineBlockChain` when method call chained on a new line after a single line block with trailing dot. ([@koic][]) +* [#10064](https://github.com/rubocop/rubocop/pull/10064): Fix `Style/ExplicitBlockArgument` corrector assuming any existing block argument was named `block`. ([@byroot][]) +* [#10070](https://github.com/rubocop/rubocop/issues/10070): Fix a false positive for `Style/MutableConstant` when using non-interpolated heredoc in Ruby 3.0. ([@koic][]) + +### Changes + +* [#9674](https://github.com/rubocop/rubocop/issues/9674): Disable `Style/AsciiComments` by default. ([@dvandersluis][]) +* [#10051](https://github.com/rubocop/rubocop/pull/10051): Improve the messaging for `Style/Documentation` to be more clear about what class/module needs documentation. ([@dvandersluis][]) +* [#10074](https://github.com/rubocop/rubocop/pull/10074): Update `Naming/InclusiveLanguage` to be disabled by default. ([@dvandersluis][]) +* [#10068](https://github.com/rubocop/rubocop/pull/10068): Mark `Style/AndOr` as unsafe auto-correction. ([@koic][]) + +[@dvandersluis]: https://github.com/dvandersluis +[@koic]: https://github.com/koic +[@byroot]: https://github.com/byroot