diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index ac6d10656622..0be3ce2cc635 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.56.2 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux] +1.56.3 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux] - rubocop-performance 1.18.0 - rubocop-rspec 2.23.2 ``` diff --git a/CHANGELOG.md b/CHANGELOG.md index dde6dd168157..44079df612b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ ## master (unreleased) +## 1.56.3 (2023-09-11) + ### Bug fixes * [#12151](https://github.com/rubocop/rubocop/issues/12151): Make `Layout/EmptyLineAfterGuardClause` allow `:nocov:` directive after guard clause. ([@koic][]) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2691d7b52fa3..4995d8fafae1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,7 +17,7 @@ do so. ```console $ rubocop -V -1.56.2 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux] +1.56.3 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux] - rubocop-performance 1.18.0 - rubocop-rspec 2.23.2 ``` diff --git a/docs/antora.yml b/docs/antora.yml index 9c897ea03d1d..b4de30cfda13 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: ~ +version: '1.56' nav: - modules/ROOT/nav.adoc diff --git a/docs/modules/ROOT/pages/cops_layout.adoc b/docs/modules/ROOT/pages/cops_layout.adoc index 7365918735bb..45f620d96162 100644 --- a/docs/modules/ROOT/pages/cops_layout.adoc +++ b/docs/modules/ROOT/pages/cops_layout.adoc @@ -1330,7 +1330,23 @@ end | 0.59 |=== -Enforces empty line after guard clause +Enforces empty line after guard clause. + +This cop allows `# :nocov:` directive after guard clause because +SimpleCov excludes code from the coverage report by wrapping it in `# :nocov:`: + +[source,ruby] +---- +def foo + # :nocov: + return if condition + # :nocov: + bar +end +---- + +Refer to SimpleCov's documentation for more details: +https://github.com/simplecov-ruby/simplecov#ignoringskipping-code === Examples @@ -3701,6 +3717,8 @@ opening HEREDOC tag. == Layout/HeredocIndentation +NOTE: Required Ruby version: 2.3 + |=== | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed diff --git a/docs/modules/ROOT/pages/cops_lint.adoc b/docs/modules/ROOT/pages/cops_lint.adoc index 8557fbd11b87..51bdcca28728 100644 --- a/docs/modules/ROOT/pages/cops_lint.adoc +++ b/docs/modules/ROOT/pages/cops_lint.adoc @@ -7070,12 +7070,18 @@ Checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of `ruby -cw`: - assigned but unused variable - foo +[source,console] +---- +assigned but unused variable - foo +---- Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc. +NOTE: Given the assignment `foo = 1, bar = 2`, removing unused variables +can lead to a syntax error, so this case is not autocorrected. + === Safety This cop's autocorrection is unsafe because removing assignment from diff --git a/docs/modules/ROOT/pages/cops_style.adoc b/docs/modules/ROOT/pages/cops_style.adoc index 4f9e28ca2dc6..cf2fe9a61384 100644 --- a/docs/modules/ROOT/pages/cops_style.adoc +++ b/docs/modules/ROOT/pages/cops_style.adoc @@ -522,6 +522,15 @@ can be replaced by `array1.intersect?(array2)`. The `array1.intersect?(array2)` method is faster than `(array1 & array2).any?` and is more readable. +In cases like the following, compatibility is not ensured, +so it will not be detected when using block argument. + +[source,ruby] +---- +([1] & [1,2]).any? { |x| false } # => false +[1].intersect?([1,2]) { |x| false } # => true +---- + === Safety This cop cannot guarantee that `array1` and `array2` are @@ -16156,25 +16165,26 @@ have the same result if reversed. === Examples -==== SupportedOperators: ['*', '+', '&''] +==== SupportedOperators: ['*', '+', '&', '|', '^'] (default) [source,ruby] ---- # bad -1 + x 10 * y +1 + x 1 & z +1 | x +1 ^ x 1 + CONST # good -60 * 24 -x + 1 y * 10 +x + 1 z & 1 +x | 1 +x ^ 1 CONST + 1 - -# good -1 | x +60 * 24 ---- === Configurable attributes diff --git a/lib/rubocop/version.rb b/lib/rubocop/version.rb index 63c371fbcdc0..1eaab127ff62 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.56.2' + STRING = '1.56.3' MSG = '%s (using Parser %s, ' \ 'rubocop-ast %s, ' \ diff --git a/relnotes/v1.56.3.md b/relnotes/v1.56.3.md new file mode 100644 index 000000000000..ac45bb7f35dd --- /dev/null +++ b/relnotes/v1.56.3.md @@ -0,0 +1,20 @@ +### Bug fixes + +* [#12151](https://github.com/rubocop/rubocop/issues/12151): Make `Layout/EmptyLineAfterGuardClause` allow `:nocov:` directive after guard clause. ([@koic][]) +* [#12195](https://github.com/rubocop/rubocop/issues/12195): Fix a false negative for `Layout/SpaceAfterNot` when a newline is present after `!`. ([@ymap][]) +* [#12192](https://github.com/rubocop/rubocop/issues/12192): Fix a false positive for `Layout/RedundantLineBreak` when using quoted symbols with a single newline. ([@ymap][]) +* [#12190](https://github.com/rubocop/rubocop/issues/12190): Fix a false positive for `Layout/SpaceAroundOperators` when aligning operators vertically. ([@koic][]) +* [#12171](https://github.com/rubocop/rubocop/issues/12171): Fix a false positive for `Style/ArrayIntersect` when using block argument for `Enumerable#any?`. ([@koic][]) +* [#12172](https://github.com/rubocop/rubocop/issues/12172): Fix a false positive for `Style/EmptyCaseCondition` when using `return`, `break`, `next` or method call before empty case condition. ([@koic][]) +* [#12162](https://github.com/rubocop/rubocop/issues/12162): Fix an error for `Bundler/DuplicatedGroup` when there's a duplicate set of groups and the `group` value contains a splat. ([@koic][]) +* [#12182](https://github.com/rubocop/rubocop/issues/12182): Fix an error for `Lint/UselessAssignment` when variables are assigned using chained assignment and remain unreferenced. ([@koic][]) +* [#12181](https://github.com/rubocop/rubocop/issues/12181): Fix an incorrect autocorrect for `Lint/UselessAssignment` when variables are assigned with sequential assignment using the comma operator and unreferenced. ([@koic][]) +* [#12187](https://github.com/rubocop/rubocop/issues/12187): Fix an incorrect autocorrect for `Style/SoleNestedConditional` when comment is in an empty nested `if` body. ([@ymap][]) +* [#12183](https://github.com/rubocop/rubocop/pull/12183): Fix an incorrect autocorrect for `Style/MultilineTernaryOperator` when returning a multiline ternary operator expression with safe navigation method call. ([@koic][]) +* [#12168](https://github.com/rubocop/rubocop/issues/12168): Fix bug in `Style/ArgumentsForwarding` when there are repeated send nodes. ([@owst][]) +* [#12185](https://github.com/rubocop/rubocop/pull/12185): Set target version for `Layout/HeredocIndentation`. ([@tagliala][]) + +[@koic]: https://github.com/koic +[@ymap]: https://github.com/ymap +[@owst]: https://github.com/owst +[@tagliala]: https://github.com/tagliala