Skip to content

Commit

Permalink
Support some Rails 7.1's new querying methods for `Rails/RedundantAct…
Browse files Browse the repository at this point in the history
…iveRecordAllMethod`

Follow up rails/rails#44446, rails/rails#37944,
rails/rails#46503, and rails/rails#47010.

This PR supports some Rails 7.1's new querying methods for `Rails/RedundantActiveRecordAllMethod`.
  • Loading branch information
koic committed Oct 14, 2023
1 parent 3629fc9 commit fbca0c4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#1158](https://github.com/rubocop/rubocop-rails/pull/1158): Support some Rails 7.1's new querying methods for `Rails/RedundantActiveRecordAllMethod`. ([@koic][])
12 changes: 11 additions & 1 deletion lib/rubocop/cop/rails/redundant_active_record_all_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,19 @@ class RedundantActiveRecordAllMethod < Base

RESTRICT_ON_SEND = [:all].freeze

# Defined methods in `ActiveRecord::Querying::QUERYING_METHODS` on activerecord 7.0.5.
# Defined methods in `ActiveRecord::Querying::QUERYING_METHODS` on activerecord 7.1.0.
QUERYING_METHODS = %i[
and
annotate
any?
async_average
async_count
async_ids
async_maximum
async_minimum
async_pick
async_pluck
async_sum
average
calculate
count
Expand Down Expand Up @@ -109,6 +117,7 @@ class RedundantActiveRecordAllMethod < Base
preload
readonly
references
regroup
reorder
reselect
rewhere
Expand All @@ -130,6 +139,7 @@ class RedundantActiveRecordAllMethod < Base
unscope
update_all
where
with
without
].to_set.freeze

Expand Down
10 changes: 10 additions & 0 deletions spec/rubocop/cop/rails/redundant_active_record_all_method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
and
annotate
any?
async_average
async_count
async_ids
async_maximum
async_minimum
async_pick
async_pluck
async_sum
average
calculate
count
Expand Down Expand Up @@ -77,6 +85,7 @@
preload
readonly
references
regroup
reorder
reselect
rewhere
Expand All @@ -98,6 +107,7 @@
unscope
update_all
where
with
without
].to_set
)
Expand Down

0 comments on commit fbca0c4

Please sign in to comment.