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/HashSyntax defaulting to Hash Rockets #9891
Comments
The default is already 1.9. Maybe a configuration file somewhere in your stack is overriding this? |
I checked, and it isn't. |
Oh wow....
Why would RuboCop generate this for 3 offenses found? |
If I remember correctly, during The generated config is saying that there are 3 offenses based on wanting hash rockets, so 3 places where ruby19 syntax is used. I'm willing to venture a guess that your project happens to have a "high" usage of hash rockets already so ruby19 syntax was deemed as going against your project's standards. How many offenses are reported if you update the config to Style/HashSyntax:
EnforcedStyle: ruby19 I'm willing to guess that there are at least 4 offense (usage of hash rockets) that is causing the opposite config to be chosen. This functionality makes sense for a lot of cops that have an inverse config. It also made sense back when code bases were closer to Ruby 1.9 and it was more common to find mixed syntax or projects that wanted to maintain hash rockets. This functionality doesn't make a whole lot of sense anymore since by this point, the ruby19 syntax should be considered the default syntax |
No, only those 3 were reported. |
Looks like a bug. The algorithm for generating |
[Fix #9891] Fix --auto-gen-config bug for Style/HashSyntax
Expected behavior
I expect the
Style/HashSyntax
to default to the Ruby 1.9 notation for hashes, using{ a: 'something' }
as the default setting.Actual behavior
The Cop is recommending the hash rockets syntax by default.
Steps to reproduce the problem
Project with existing code, and add RuboCop, latest version
RuboCop version
The text was updated successfully, but these errors were encountered: