-
Notifications
You must be signed in to change notification settings - Fork 1
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
Enforce ~consistent~ either hash syntax #309
Conversation
`EnforcedShorthandSyntax: always` is the default setting in Rubocop even though Bozhidar himself [doesn't like the option](https://batsov.com/articles/2022/01/20/bad-ruby-hash-value-omission/). I suggest to change the default option to `consistent` because I can see the advantage of the shorthand syntax when passing on options to deeper levels. But in any other context I found myself to be confused by it. This change allows hashes to be in shorthand syntax only if the whole hash uses it consistently. See rubocop/rubocop#10776.
After reading this, I think I'd even vote to disallow it completely. But consistent style is probably enough. |
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.
+1, this is also what I use in my project
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.
Can somebody explain to me the difference between consistent
and either
? Because I enabled the second one on vista.
EnforcedShorthandSyntax: consistent
EnforcedShorthandSyntax: either
|
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.
I tried to run it with consistent on vista currently and I get the following for example:
C: [Correctable] Style/HashSyntax: Omit the hash value.
let(:section_instance) { section.new(card_request: card_request) }
I don't want to be forced to write let(:section_instance) { section.new(card_request: card_request) }
.
At the same time it does not complain about some_method(:hello, :b, card_request:, logger:)
.
As of now, I'd prefer either
to consistent
I found also an old discussion we had. Maybe irrelevant now: https://renuo.slack.com/archives/C013FEGN4D7/p1650550992375259 |
standardrb/standard#375 |
Switching to |
EnforcedShorthandSyntax: always
is the default setting in Rubocop even though Bozhidar himself doesn't like the option.I suggest to change the default option toconsistent
because I can see the advantage of the shorthand syntax when passing on options to deeper levels. But in any other context I found myself to be confused by it.This change allows hashes to be in shorthand syntax only if the whole hash uses it consistently. See rubocop/rubocop#10776.Update:
I changed my mind. Let's follow standardrb. Be consistent yourselves if you see fit.