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/Presence wrongly corrects hash access #132

Closed
Aqualon opened this issue Sep 27, 2019 · 2 comments
Closed

Rails/Presence wrongly corrects hash access #132

Aqualon opened this issue Sep 27, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@Aqualon
Copy link

Aqualon commented Sep 27, 2019

Expected behavior

Rails/Presence should not replace hash access with method call

Actual behavior

Rails/Presence cop replaces hash access with method call

Steps to reproduce the problem

if object.blank?
  some_hash['bar']
else
  object
end

gets replaced with

object.presence || some_hash('bar')

While the object.presence is fine, some_hash is a hash, not a method, so the code breaks.

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:

0.74.0 (using Parser 2.6.4.1, running on ruby 2.6.3 x86_64-darwin18)
@koic koic added the bug Something isn't working label Sep 27, 2019
@koic
Copy link
Member

koic commented Sep 27, 2019

Thanks for the feedback. PR #131 has been opened to solve this one.

@koic
Copy link
Member

koic commented Oct 17, 2019

#131 has been merged.

@koic koic closed this as completed Oct 17, 2019
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