-
Notifications
You must be signed in to change notification settings - Fork 213
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
Unexpected changes with named arguments in 1.6.0 from Style/HashSyntax #375
Comments
Agree, this seems heavy-handed in practice. It's a neat trick but it doesn't make sense to force terseness on people, especially when it's so new. (I say this as someone who routinely supports way-since-EOL'd Rubies in my new code, so this seems like something I'll be late-to-the-party to). @camilopayan, thoughts? |
It also causes problems if you are using a CI matrix of Ruby versions < 3.1 in CI. |
Spoke with @camilopayan who agrees this rule is an overreach. We will cut a release ASAP that turns it off |
also, for the record, I'm not going to enable the rule with |
Sounds great to me. I'm also fine not banning spiffy new things. You guys are awesome. Keep up the great work! |
Thanks for the fast turnaround 👍 |
Well, shit. We don't have that option. I hadn't realized this was a tack-on to the (otherwise very important) Paging @koic & @bbatsov for context here: I'd really wish for an option to say |
Yeah, of course we can add |
Thanks @bbatsov, I appreciate it! Please choose whatever name is more conventional, but |
Follow up to standardrb/standard#375 (comment). This PR supports `EnforcedShorthandSyntax: either` option for `Style/HashSyntax`. It accepts both shorthand and explicit use of hash literal value. ```ruby # good {foo: foo, bar: bar} # good {foo:, bar:} ``` I think that we can change the default enforced style in response to future feedback and discussion. Anyway at this point it only adds the new style.
Yeah, I've opened rubocop/rubocop#10351 to support the new option. |
Follow up to standardrb/standard#375 (comment). This PR supports `EnforcedShorthandSyntax: either` option for `Style/HashSyntax`. It accepts both shorthand and explicit use of hash literal value. ```ruby # good {foo: foo, bar: bar} # good {foo:, bar:} ``` I think that we can change the default enforced style in response to future feedback and discussion. Anyway at this point it only adds the new style.
@searls The new RuboCop release (1.25) that features |
Thank you @bbatsov! Just saw the release notification ❤️ |
You guys are sweet! |
RuboCop 1.35 added a new option - even better than |
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.
Looks like we have this new cop and I'm not a fan, so raising the issue here: Style/HashSyntax: Omit the hash value.
I'm getting code that looks like:
Changing to:
On the one hand, I learned that this works! Cool that I can still have things to learn! On the other hand, it was pretty unexpected to me.
Looks like
EnforcedShorthandSyntax: never
is what I'd vote for.The text was updated successfully, but these errors were encountered: