Skip to content

Commit

Permalink
Merge pull request #995 from masato-bkn/improve_rails_find_each
Browse files Browse the repository at this point in the history
Check for `or` method in `Rails/FindEach` cop
  • Loading branch information
koic authored May 2, 2023
2 parents 8611336 + bf38577 commit 585ddf1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
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

0 comments on commit 585ddf1

Please sign in to comment.