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: wrong autocorrect when #order is in the chain #508

Closed
maximeg opened this issue Jun 22, 2021 · 1 comment
Closed

Rails/FindBy: wrong autocorrect when #order is in the chain #508

maximeg opened this issue Jun 22, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@maximeg
Copy link

maximeg commented Jun 22, 2021

Given this code:

MyModel.where(foo: :bar).order(:baz).take

and the cop Rails/FindBy

Expected behavior

No autocorrect.

Or autocorrect to:

MyModel.order(:baz).find_by(foo: :bar)

Actual behavior

Said C: [Corrected] Rails/FindBy: Use find_by instead of where.take.

And autocorrected to:

MyModel.where(foo: :bar).find_by(:baz)

Steps to reproduce the problem

be rubocop -A or be rubocop -a

RuboCop version

1.17.0 (using Parser 3.0.1.1, rubocop-ast 1.7.0, running on ruby 3.0.1 arm64-darwin20)
  - rubocop-performance 1.11.3
  - rubocop-rails 2.11.0
  - rubocop-rspec 2.4.0
@koic koic added the bug Something isn't working label Jun 23, 2021
@koic
Copy link
Member

koic commented Jun 23, 2021

This issue resolved by #504. Thank you for feedback!

@koic koic closed this as completed Jun 23, 2021
koic added a commit that referenced this issue Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants