Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support some Rails 7.1's new querying methods for Rails/RedundantActiveRecordAllMethod #1157

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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