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
False positive for "Style/HashSyntax" when using a variable as a hash key #10401
Comments
This is not a false positive because it is an expected behavior of |
@koic hash value omission is only possible when key is a Symbol, otherwise it just breaks the code like in the example above. |
I've updated the examples with comments reflecting the result of running the code |
Ah, you are right. It's my oversight. |
Fixes rubocop#10401. This PR fixes a false positive for `Style/HashSyntax` when local variable hash key and hash value are the same.
…sh_syntax [Fix #10401] Fix a false positive for `Style/HashSyntax`
If you use the same variable as both a hash key and its value, then ruboсop wants to omit the value. The proposed autocorrection breaks the semantics of the code.
Expected behavior
No offences for the following code:
Actual behavior
The code after autocorrection:
Steps to reproduce the problem
See above
RuboCop version
The text was updated successfully, but these errors were encountered: