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

Rails::FindBy should not flag where.first by default. Make it an option. #499

Closed
matthewhively opened this issue May 27, 2021 · 0 comments · Fixed by #502
Closed

Rails::FindBy should not flag where.first by default. Make it an option. #499

matthewhively opened this issue May 27, 2021 · 0 comments · Fixed by #502
Labels
enhancement New feature or request

Comments

@matthewhively
Copy link

I think it would be preferred to have a configuration toggle for whether FindBy should flag where.first or only where.take
Since the SQL generated by where.first is different than where.take these should not both be flagged by the same cop configuration. Developers should be able to utilize this cop without necessarily opting-in to potentially unsafe behavior.

The cop overview should also be revised to make note that updating where.first to find_by could be potentially unsafe.

@koic koic added the enhancement New feature or request label May 28, 2021
koic added a commit to koic/rubocop-rails that referenced this issue Jun 3, 2021
Fixes rubocop#499.

This PR add `IgnoreWhereFirst` option (`true` by default) to `Rails/FindBy` cop.
koic added a commit to koic/rubocop-rails that referenced this issue Jun 3, 2021
Fixes rubocop#499.

This PR add `IgnoreWhereFirst` option (`true` by default) to `Rails/FindBy` cop.
@koic koic closed this as completed in #502 Jun 5, 2021
koic added a commit that referenced this issue Jun 5, 2021
…ails_find_by

[Fix #499] Add `IgnoreWhereFirst` to `Rails/FindBy` cop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants