makandra / makandra-rubocop

makandra's default Rubocop configuration
MIT License
6 stars 1 forks source link

Loosen EnforcedShorthandSyntax for Style/HashSyntax #36

Closed foobear closed 2 years ago

foobear commented 2 years ago

Ruby 3.1 allows omitting hash values, if the hash key is the same as its value's variable name ({ foo: foo }{ foo: }). Rubocop's default is to enforce that style, if possible: https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/HashSyntax

I'm still uncomfortable with the new syntax and I'm not sure we want to adopt it as a default.

My suggestion is to allow both styles for the time being:

Style/HashSyntax:
  EnforcedShorthandSyntax: either

Vote: :+1: change to either :-1: keep default always :confused: change to never

kratob commented 2 years ago

This is super useful in JS, and I think we only find it weird because it looks a bit unaesthetic with the colon. I believe we'll get used to that.

Having said that, I'm not super invested. :smile:

foobear commented 2 years ago

I agree with @kratob that it is useful and that we probably will get used to it, even though it's syntactically not pretty.

For the time being it would create a lot of noise on projects which upgrade to Ruby 3.1. Those projects can still change that setting in their .rubocop.yml (as I've done) which is why I was unsure what we should pick as a default now. :smile:

kratob commented 2 years ago

I think our default should be what we want in new projects, not what is most compatible for existing ones.

foobear commented 2 years ago

True. I did not express myself clearly. I'm trying to learn what the desired default is. :grimacing:

So far, votes are leaning towards allowing both styles -- which sounds reasonable if we want to adopt it step by step even in new code bases.

I'm not at all against changing to always later.

brunosedler commented 2 years ago

Based on the current votes, EnforcedShorthandSyntax has been changed to either in https://github.com/makandra/makandra-rubocop/commit/063a4be834e3f1bcf82269f29103202a9092dc6a and released with version 9.1.0.