Skip to content

Rails/FindEach: false positive on ActiveModel::Errors on Rails 6.1 #551

Closed
@colinux

Description

rubocop-rails raises a false positive Rails/FindEach on ActiveModel errors slice from the new query interface introduced in Rails 6.1.

Model.new.errors.where(:title).each {   }
                               ^^^^ Use find_each instead of each

Expected behavior

Rails/FindEach should ignore ActiveModel::Errors class.

Actual behavior

Considers ActiveModel::Errors as an ActiveRecord model, triggering a false positive offense

Steps to reproduce the problem

See above minimal example on Rails 6.1.

RuboCop version

$  bundle exec rubocop -V
1.21.0 (using Parser 3.0.2.0, rubocop-ast 1.11.0, running on ruby 2.6.6 x86_64-darwin19)
  - rubocop-minitest 0.15.0
  - rubocop-performance 1.11.5
  - rubocop-rails 2.12.2
  - rubocop-rake 0.6.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions