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

Check for or method in Rails/FindEach cop #995

Merged
merged 1 commit into from
May 2, 2023
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
1 change: 1 addition & 0 deletions changelog/change_check_for_or_method_in_rails_find_each.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#995](https://github.com/rubocop/rubocop-rails/pull/995): Check for `or` method in `Rails/FindEach` cop. ([@masato-bkn][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/find_each.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FindEach < Base
RESTRICT_ON_SEND = %i[each].freeze

SCOPE_METHODS = %i[
all eager_load includes joins left_joins left_outer_joins not preload
all eager_load includes joins left_joins left_outer_joins not or preload
references unscoped where
].freeze

Expand Down
1 change: 1 addition & 0 deletions spec/rubocop/cop/rails/find_each_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
it_behaves_like('register_offense', 'joins(:association_name)')
it_behaves_like('register_offense', 'left_joins(:association_name)')
it_behaves_like('register_offense', 'left_outer_joins(:association_name)')
it_behaves_like('register_offense', 'where(name: name).or(User.where(age: age))')
it_behaves_like('register_offense', 'preload(:association_name)')
it_behaves_like('register_offense', 'references(:association_name)')
it_behaves_like('register_offense', 'unscoped')
Expand Down