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/Inquiry get triggered on variable/method with the name "inquiry" #319

Closed
fpietka opened this issue Aug 4, 2020 · 0 comments · Fixed by #321
Closed

Rails/Inquiry get triggered on variable/method with the name "inquiry" #319

fpietka opened this issue Aug 4, 2020 · 0 comments · Fixed by #321

Comments

@fpietka
Copy link

fpietka commented Aug 4, 2020

Hi,
I have an issue where Rails/Inquiry is triggered on an inquiry method of my class. Since I have a model call Inquiry, I also use a method to get an instance, with the same name.
It also happens a lot in the specs, since I use let to define an instance of Inquiry.

Expected behavior

Rails/Inquiry should not be triggered on variable/method calls, only on Array#inquiry and String#inquiry (which I believe are called with a dot prior to inquiry?)

Actual behavior

In my application I have a model called Inquiry. It makes false positives in two cases:

  • in a model, I have a method inquiry that trigger the cop.
  • in specs, when I use let (:inquiry) ..., and then use the variable, it triggers the cop also.

Steps to reproduce the problem

I think the easier way is to have a minimal class with a method inquiry and calling it.
Also have a spec with a let (:inquiry) ... used afterward.

RuboCop version

0.88.0 (using Parser 2.7.1.4, rubocop-ast 0.1.0, running on ruby 2.4.4 x86_64-linux)
koic added a commit to koic/rubocop-rails that referenced this issue Aug 6, 2020
Fixes rubocop#319.

This PR fixes an false positive for `Rails/Inquiry` when
`#inquiry`'s receiver is a variable.
It should only detect when receiver is an array literal and
a string literal.
koic added a commit to koic/rubocop-rails that referenced this issue Aug 9, 2020
Fixes rubocop#319.

This PR fixes a false positive for `Rails/Inquiry` when
`#inquiry`'s receiver is a variable.
It should only detect when receiver is an array literal and
a string literal.
koic added a commit to koic/rubocop-rails that referenced this issue Aug 9, 2020
Fixes rubocop#319.

This PR fixes a false positive for `Rails/Inquiry` when
`#inquiry`'s receiver is a variable.
It should only detect when receiver is an array literal and
a string literal.
@koic koic closed this as completed in #321 Aug 9, 2020
koic added a commit that referenced this issue Aug 9, 2020
[Fix #319] Fix a false positive for `Rails/Inquiry`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant