Description
Is your feature request related to a problem? Please describe.
I was trying to figure out why rubocop-rails wasn't picking up where(...).first
usage in our application (OpenStreetMap).
Eventually I found that the cop is restricted to models only, in the default configuration.
rubocop-rails/config/default.yml
Lines 461 to 469 in 34376e0
However I don't think this restriction is necessary, and I think it's actually unhelpful. I suspect that a large amount, perhaps the majority, of ActiveRecord .where
usage would be found in controllers, not in models. In our application, it also crops up repeatedly in our tests.
Describe the solution you'd like
I'd like to see the default configuration updated, to remove the Include: ['app/models/**/*.rb']
restriction, for the Rails/FindBy
and Rails/FindEach
cops.
Describe alternatives you've considered
The alternative is for everyone to override the configuration for these two cops in their own configuration, e.g.
Rails/FindBy:
Include:
- '**/*.rb'
Additional context
The Include
restriction was originally introduced alongside the initial cop (in rubocop) in 6188d755eefd94875bc155bbfe433f7752d0bd2b, but I can't find any related discussions.
Activity