From afd7bab95b0e175cb448d676277f4d7b5e5caa35 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sun, 19 Nov 2023 17:28:26 +0900 Subject: [PATCH] Cut 2.22.2 --- CHANGELOG.md | 2 ++ docs/antora.yml | 2 +- docs/modules/ROOT/pages/cops_rails.adoc | 15 +++++++++++---- lib/rubocop/rails/version.rb | 2 +- relnotes/v2.22.2.md | 12 ++++++++++++ 5 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 relnotes/v2.22.2.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d7db3aeda..dd9b028422 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ ## master (unreleased) +## 2.22.2 (2023-11-19) + ### Bug fixes * [#1172](https://github.com/rubocop/rubocop-rails/issues/1172): Fix an error for `Rails/UnknownEnv` when using Rails 7.1. ([@koic][]) diff --git a/docs/antora.yml b/docs/antora.yml index 9e0ff48acb..aaeffb2967 100644 --- a/docs/antora.yml +++ b/docs/antora.yml @@ -2,6 +2,6 @@ name: rubocop-rails title: RuboCop Rails # We always provide version without patch here (e.g. 1.1), # as patch versions should not appear in the docs. -version: ~ +version: '2.22' nav: - modules/ROOT/nav.adoc diff --git a/docs/modules/ROOT/pages/cops_rails.adoc b/docs/modules/ROOT/pages/cops_rails.adoc index 73d6e0a1b1..035c6485c7 100644 --- a/docs/modules/ROOT/pages/cops_rails.adoc +++ b/docs/modules/ROOT/pages/cops_rails.adoc @@ -240,10 +240,10 @@ This cop is unsafe because custom `update_attributes` method call was changed to [source,ruby] ---- -#bad +# bad book.update_attributes!(author: 'Alice') -#good +# good book.update!(author: 'Alice') ---- @@ -1841,10 +1841,10 @@ when no output would be produced anyway. [source,ruby] ---- -#bad +# bad Rails.logger.debug "The time is #{Time.zone.now}." -#good +# good Rails.logger.debug { "The time is #{Time.zone.now}." } ---- @@ -4346,6 +4346,13 @@ end Detect redundant `all` used as a receiver for Active Record query methods. +NOTE: For the methods `delete_all` and `destroy_all`, +this cop will only check cases where the receiver is a model. +It will ignore cases where the receiver is an association (e.g., `user.articles.all.delete_all`). +This is because omitting `all` from an association changes the methods +from `ActiveRecord::Relation` to `ActiveRecord::Associations::CollectionProxy`, +which can affect their behavior. + === Safety This cop is unsafe for autocorrection if the receiver for `all` is not an Active Record object. diff --git a/lib/rubocop/rails/version.rb b/lib/rubocop/rails/version.rb index ee4f88597e..efb8304adc 100644 --- a/lib/rubocop/rails/version.rb +++ b/lib/rubocop/rails/version.rb @@ -4,7 +4,7 @@ module RuboCop module Rails # This module holds the RuboCop Rails version information. module Version - STRING = '2.22.1' + STRING = '2.22.2' def self.document_version STRING.match('\d+\.\d+').to_s diff --git a/relnotes/v2.22.2.md b/relnotes/v2.22.2.md new file mode 100644 index 0000000000..c222a9c07a --- /dev/null +++ b/relnotes/v2.22.2.md @@ -0,0 +1,12 @@ +### Bug fixes + +* [#1172](https://github.com/rubocop/rubocop-rails/issues/1172): Fix an error for `Rails/UnknownEnv` when using Rails 7.1. ([@koic][]) +* [#1173](https://github.com/rubocop/rubocop-rails/issues/1173): Fix an error for `Rails/RedundantActiveRecordAllMethod` cop when used with RuboCop 1.51 or lower. ([@koic][]) + +### Changes + +* [#1171](https://github.com/rubocop/rubocop-rails/pull/1171): Change `Rails/RedundantActiveRecordAllMethod` to ignore `delete_all` and `destroy_all` when receiver is an association. ([@masato-bkn][]) +* [#1178](https://github.com/rubocop/rubocop-rails/pull/1178): Require RuboCop AST 1.30.0+. ([@koic][]) + +[@koic]: https://github.com/koic +[@masato-bkn]: https://github.com/masato-bkn