-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Trailing Comma needs to learn a 'only when at line end' style #1075
Comments
I think we should be checking for a missing trailing comma only when there is one element per line and there's no closing paren on that line. The current implementation took a shortcut (my fault, since I recall suggesting to @jonas054 to simplify the implementation, without considering some implications). I guess we'll need to revisit this. |
@bbatsov there's no way to catch all the edge cases on something like this. :) |
[Fix #1075] More strict limits on when to require trailing comma
@jonas054 I completely forgot to gittip you. That's now been resolved. 😄 Once again, you rock. |
@jonas054 unfortunately this is still registering an offense even when I have the config set like so: TrailingComma:
EnforcedStyleForMultiline: 'comma' False positive: scout.throttle!(status: 'realtime',
over_limit: true) Any ideas? |
@jonas054 I may be wrong, but it seems like params to a method call may need to be handled differently to just a regular hash since: scout.throttle! status: 'realtime',
over_limit: true Cannot have a trailing |
Here's the failing spec to help you out: context 'when EnforcedStyleForMultiline is comma' do
it 'accepts a method call with Hash as last parameter split on multiple lines' do
inspect_source(cop, ['some_method(a: "b",',
' c: "d")'])
expect(cop.offenses).to be_empty
end
end |
@jfelchner I think it'd be best if you opened a separate ticket for this. |
np |
I love using trailing commas, but there's a big difference between using trailing commas on code like this:
And code like this:
I'm not going to "waste" a line on every method call that breaks multiple lines for the closing parenthesis, but in my mind, having the closing paren of the Hash line up makes more sense (and happens less frequently).
I'd love to see an option to
TrailingComma
which specifies that trailing commas are required only if they would be the last thing on the line.The text was updated successfully, but these errors were encountered: