-
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
Thought: Enable trailing commas in Hash Literals (per Ruby 3.1 addition of implicit hash values) #611
Comments
Hey Nathaniel, thanks for the kind note. I appreciate your perspective and see where you're coming from. Personally, seeing Ultimately, I'm still 👎 on this, for these reasons:
Thanks again for submitting this. Will leave it open for others who want to comment |
Yes. And everywhere else. Please! Quoting @zacheryph from rubocop/ruby-style-guide#273:
I'm really frustrated about this after months of adopting Standard Ruby. |
Someone will always be frustrated by some stylistic decision. That's pretty much unavoidable. |
I would argue that with this rule standard makes me type more: if I want to add a line I duplicate an interesting line ( Similarly for macros or multicursor edits the last item missing a comma prevents automatically repeated operations (e.g In short, regularity makes one type less. The last item being irregular is painful, not just for "personal taste" reasons but for technical automation reasons. |
First off, I love this project, and it's brought significant joy to my life and the lives of my team.
Truly - thank you for the significant amount of hard work, and hard decisions, you all have had to make.
I'm aware that this issue (for other reasons) has been talked about before.
My goal with this issue isn't to bike-shed, or cause stress. I just wanted to make a suggestion here, given some (somewhat) recent changes with what's possible in Ruby, and how I feel the current trailing commas rule causes some visual friction when writing/reviewing code.
This is just my opinion here, and I'm in no way saying everyone should have it - but I feel like others may find it valid.
My premise: enforcing "avoiding comma after last item of a hash" (as opposed to the opposite), hurts code readability with implicit hash values.
Here's a example below:
Say we have some class that builds up a hash value, and it just so happens that:
To my eyes, when scanning this code, it looks like
favorite_color
is missing its value (particularly if I don't know - due to the size of the file, etc, that thefavorite_color
method exists). I can't help but think that there's a problem with the file/code when reading it.Whereas the opposite:
My eyes see the
,
and my brain automatically assumes that we're implicitly referencing a method/variable somewhere - and can continue reviewing the file without my brain hitting the breaks.Additionally, here's an example diff from a PR in a project:
I'm unsure if this resonates with everyone, and if you all disagree — I completely understand. I just thought I'd mention it, as it has come up for me multiple times as a code writer and reviewer.
The text was updated successfully, but these errors were encountered: