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

Style/PreferredHashMethods false posive on object that is not a Hash #6359

Closed
jcoyne opened this issue Oct 4, 2018 · 4 comments · Fixed by #7051
Closed

Style/PreferredHashMethods false posive on object that is not a Hash #6359

jcoyne opened this issue Oct 4, 2018 · 4 comments · Fixed by #7051
Assignees

Comments

@jcoyne
Copy link

jcoyne commented Oct 4, 2018

I'm seeing this error:

app/presenters/blacklight/document_presenter.rb:16:40: C: Style/PreferredHashMethods: Use Hash#value? instead of Hash#has_value?.
        render_field?(field_config) && has_value?(field_config)
                                       ^^^^^^^^^^

but the method is not on a hash, it's on a DocumentPresenter.

@Darhazer
Copy link
Member

This cop should be marked unsafe, as it could not know whether the receiver is a hash

@Darhazer Darhazer self-assigned this Jan 27, 2019
@stale
Copy link

stale bot commented May 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

@stale stale bot added the stale Issues that haven't been active in a while label May 8, 2019
tejasbubane added a commit to tejasbubane/rubocop that referenced this issue May 15, 2019
@tejasbubane
Copy link
Contributor

@Darhazer Sent a PR to mark it as unsafe.

Apart from this, do you think we should handle the case of no receiver? Calling without receiver most probably means it is not a Hash (unless Hash class is opened).

@stale stale bot removed the stale Issues that haven't been active in a while label May 15, 2019
@Darhazer
Copy link
Member

yeah, I guess it doesn't make sense to flag on nil receiver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants