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

Don't prohibit Hash[] syntax #69

Merged
merged 1 commit into from
Jan 13, 2022
Merged

Conversation

cllns
Copy link
Member

@cllns cllns commented Jul 1, 2021

This is in Rubocop v1.10 rubocop/rubocop#9478

It seems like the intention is to prevent Hash[ary] and to encourage ary.to_h instead. But this also sweeps up every use of Hash[]. We have had that Hash[] call in specs we generated for Hanami 1.3 apps. I'd like to see that continue when we do Hanami 2.0 generators.

I personally much prefer Hash[] particularly when it's in a block. The squiqqly braces mean two different things in Ruby: a hash literal or a block. By avoiding using them as hash literal, it make its clear that they're used for blocks most often. (I'm not a purist about this, I just think it's easier to read often. With nested hashes, I often resort to hash literals inside a Hash[] call.)

@cllns cllns requested a review from jodosha July 1, 2021 15:09
@jodosha jodosha merged commit 4463b12 into main Jan 13, 2022
@jodosha jodosha deleted the allow-hash-constructor-syntax branch January 13, 2022 21:43
@cllns
Copy link
Member Author

cllns commented Jan 13, 2022

I just this afternoon added this hanami/devtools Rubocop config (as inherit_from:) to a new project, so great timing @jodosha 😄

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

Successfully merging this pull request may close these issues.

2 participants