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
7492 Add Style/TrailingCommaInBlockArgs #7637
7492 Add Style/TrailingCommaInBlockArgs #7637
Conversation
There are the following differences: % ruby -wve "{foo: 1, bar: 2, baz: 3}.each {|key,| p key }"
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin17]
:foo
:bar
:baz % ruby -wve "{foo: 1, bar: 2, baz: 3}.each {|key| p key }"
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin17]
[:foo, 1]
[:bar, 2]
[:baz, 3] So, some are my thoughts.
|
This is a lot of feedback to take in. Let me see if I can go back and make the required changes, or if not, pass along to someone who knows better than I. |
87804f0
to
f45dd42
Compare
I didn't change this yet, but can do so if necessary.
This shouldn't touch trailing commas that are required (for instance a trailing comma after a single argument), so it should preserve syntax in both cases.
I disabled by default. |
f45dd42
to
ce03289
Compare
I think we need a better name for this cop, as right now it's too generic. Unfortunately I can't think of something that's not very long like |
This can potentially get a style guide entry as well. |
Just noticed as I was looking for some naming convention that a |
ce03289
to
aea4a7b
Compare
d1a470e
to
a1335b4
Compare
@pawptart Yeah, I think that's a good idea. It seems also you'll have to do some rebasing looking at the list of merge conflicts. :-) |
cef08d1
to
44442c1
Compare
Taken care of :) |
Thanks! |
Fixes #7492. This PR adds new cop
Style/TrailingCommaInBlockArgs
for blocks with multiple arguments. Trailing commas are only required in blocks with one argument, else a trailing comma should be omitted.Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.