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/HashSyntax EnforcedShorthandSyntax setting #393

Closed
ojgarcia opened this issue May 20, 2022 · 1 comment
Closed

Style/HashSyntax EnforcedShorthandSyntax setting #393

ojgarcia opened this issue May 20, 2022 · 1 comment

Comments

@ojgarcia
Copy link

Rubocop will always enforce ruby's 3.1 hash key shorthand syntax by default. Do we want to change the default behavior?

The Hash Literal Values says this is good.
For what its worth, Standard is set to either.

Weak opinion: My preference would be to set it to either. Allow its use but not require it.

Screen Shot 2022-05-20 at 2 27 28 PM

@sambostock
Copy link
Contributor

sambostock commented May 21, 2022

We have already set it to either in #365 👍

Style/HashSyntax:
EnforcedShorthandSyntax: either

mctofu pushed a commit to jeffwidman/dependabot-core that referenced this issue Oct 7, 2022
Ruby 3.1 added some syntax sugar for omitting hash values in certain
cases. This results in more terse code, at the expense of readability.

Like any good style change, this is obviously bikeshed worthy, and has
generated a lot of controversy around the community:
* https://batsov.com/articles/2022/01/20/bad-ruby-hash-value-omission/
* standardrb/standard#375
* Shopify/ruby-style-guide#393
* https://github.com/rubocop/ruby-style-guide#hash-literal-values

Personally, I can see places where it's useful, but also places where it
just makes the Ruby a bit more inscrutable.

So set the Rubocop value to `either` to allow, but not require it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants