-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Rails/FindBy doesn't check for where
in the method chain
#504
Comments
#502 has not been release yet. I'm spending some time working for the next release. Thank you for your patience. |
Got it, thanks! |
RuboCop Rails 2.11 is out! Thank you for waiting! |
Hey @koic, thanks for releasing the version
And the test # spec/rubocop/cop/rails/find_by_spec.rb
it 'wrongly expects offence for a regular array' do
expect_offense(<<~RUBY)
array = Array.new(1) { rand }
array.compact.take
^^^^^^^^^^^^ Use `find_by` instead of `where.take`.
RUBY
end Still passes, but it should fail instead. We don't want to have an offence with regular ruby arrays. There is no Am I missing something? Thanks! ❤️ |
Here is an example of the fix I meant - #506 |
…triggering-on-regular-arrays [Fix #504] Rails/FindBy being wrongly triggered on non Active Record methods
Most likely bug was introduced here - #502 by removing the
:where_first?
matchercc: @koic
Expected behavior
Rails/FindBy
cop should only look for.where().take
orwhere().first
callsActual behavior
Rails/FindBy
just looks for any.take
or.first
callsSteps to reproduce the problem
The following test should fail but it passes with a misleading suggestion:
RuboCop version
The text was updated successfully, but these errors were encountered: