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
Disable TrailingComma* cops #453
Conversation
Also: I'm not very good with the rubocop codebase, but I wonder if it would be worth improving the upstream Cop so that it doesn't generate this kind of contraptions (I may try my hand at it). |
These cops used to be configured with `EnforcedStyleForMultiline: consistent_comma` but it was changed in standardrb@a7156b1 because it can cause some weird contortions, see: standardrb#133 I totally agree that this cop resulting in such horrible contorsion is broken, but I don't understand why that would justify to switch to a different style rather than to just disable the cop. Trailing comma in multiline hashes & co have the major advantage of reducing diff noise when adding or removing an element.
0013d78
to
c915889
Compare
Hi @casperisfine, thank you for the contribution. The context on why we chose to ditch trailing commas is broader than the issue linked above. Here's the issue that we tracked the changed to and the discussion in rubyfmt that initiated the conversation. In truth, I only adopted trailing commas when I first published standard at @penelopezone's insistence and after a year or two of living with them, my frustration with them did not alleviate, so I was relieved by her reversal on that stance. There are two reasons why I prefer
The reason we switched the rule instead of disabling it is because this is a major decision point that affects code readability pretty significantly and I felt it was important that Standard make a call one way or another. When you read the full I realize a lot of this is subjective and being on the other side of the argument makes anything I say feel arbitrary. I think this is one issue is at least partly motivated by taste and aesthetics. |
No worries, and thank you for the extra context I missed. I off course totally disagree for various reason, but as you said: taste and aesthetics 😄 |
Thanks. A word I didn't use in my description above was "consistency". One of my two internal mottos with Standard is "be nothing if not consistent", and that meant that once trailing commas started causing some real headaches for rubyfmt around parameter lists and some head-scratchers for data literals in Standard, the fact that no-trailing-commas could be confidently applied safely 100% of the time, it became appealing because it was the only bulletproof consistent rule we could apply in all cases. |
fwiw rubyfmt has some objectively horrible syntax choices because it's the only way to be consistent. We chose this path and are sticking to it |
We've just started using Standard Ruby, but this is definitely a reason to ditch it. Probably one of the most important cases for a linter is to enforce trailing commas to keep the Git history clean. I strongly disagree with the aesthetics argument, this is code, not art. |
I assure you we thought about git diffs at the time and decided it wasn't important enough to override this decision :) |
These cops used to be configured with
EnforcedStyleForMultiline: consistent_comma
but it was changed in a7156b1 because it can cause some weird contortions, see: #133I totally agree that this cop resulting in such horrible contorsion is broken, but I don't understand why that would justify to switch to a different style rather than to just disable the cop.
Trailing comma in multiline hashes & co have the major advantage of reducing diff noise when adding or removing an element.
NB: I'm not too sure if it's ok to open PRs to argue about style, but since this used to be the preferable style and was changed for a technicality, I hope it's ok.