-
-
Notifications
You must be signed in to change notification settings - Fork 270
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
[Fix #319] Fix a false positive for Rails/Inquiry
#321
Conversation
@@ -26,7 +26,11 @@ class Inquiry < Cop | |||
MSG = "Prefer Ruby's comparison operators over Active Support's `inquiry`." | |||
|
|||
def on_send(node) | |||
add_offense(node, location: :selector) if node.method?(:inquiry) && node.arguments.empty? | |||
return unless node.method?(:inquiry) && node.arguments.empty? | |||
return unless (receiver = node.receiver) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding a test that covers inquiry
with no receiver, since that's what this line is for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I added the test.
CHANGELOG.md
Outdated
@@ -12,6 +12,7 @@ | |||
|
|||
* [#315](https://github.com/rubocop-hq/rubocop-rails/pull/315): Allow to use frozen scope for `Rails/UniqueValidationWithoutIndex`. ([@krim][]) | |||
* [#313](https://github.com/rubocop-hq/rubocop-rails/pull/313): Fix `Rails/ActiveRecordCallbacksOrder` to preserve the original callback execution order. ([@eugeneius][]) | |||
* [#319](https://github.com/rubocop-hq/rubocop-rails/issues/319): Fix an false positive for `Rails/Inquiry` when `#inquiry`'s receiver is a variable. ([@koic][]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* [#319](https://github.com/rubocop-hq/rubocop-rails/issues/319): Fix an false positive for `Rails/Inquiry` when `#inquiry`'s receiver is a variable. ([@koic][]) | |
* [#319](https://github.com/rubocop-hq/rubocop-rails/issues/319): Fix a false positive for `Rails/Inquiry` when `#inquiry`'s receiver is a variable. ([@koic][]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! Thank you!
bcf9efe
to
fbcda86
Compare
Rails/Inquiry
Rails/Inquiry
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.
fbcda86
to
a36dc5b
Compare
Fixes #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.
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).and description in grammatically correct, complete sentences.
bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.