-
-
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
False positive for Style/TrailingComma cop #1955
Comments
I made a pull request with a possible fix. Here's what I think is going on (although I might be wrong). Basically the cop interpreted the expression, correctly, as a method call. As can be seen in the code, because the last argument, the I simply added a check to not report an offense if the first argument of the function is an empty hash, as can be seen here. My only concern, as mentioned on the pull request is that my solution would create false negatives. For example, it would not report an offense for Thoughts? Let me know if there are any changes I can make to make it better! |
The error message says:
IMHO, it should only apply to multiline method calls. For example: Foo.new(
"first arg",
"second arg",
) |
Hmm so maybe the problem is that |
@philoserf This is not the default. I am overwriting the default, as I say in the first line of the description with the configuration:
This is just a bug. 🐛 Not a bloody nose. 🚫 💉 👃 |
My miss. Comment retracted. |
I updated my pull request off of @sferik's observation that this method should not have been labelled |
My setup is exactly like @sferik and I'm also getting this problem. |
I’m running into the same exact issue. Here’s another case where the cop gives incorrect output: Foo.new(
'blah blah',
{ owner: 'me', author: 'myself' },
'more blah',
) RuboCop reports:
This is the RuboCop configuration: TrailingComma:
EnforcedStyleForMultiline: comma |
We're locking rubocop at 0.31.0 until a trailing comma issue is resolved rubocop/rubocop#1955
In RuboCop version 0.32.0, given the following configuration:
And the following code:
RuboCop generates the following offense:
With autocorrect enabled, the code is changed to:
Something is clearly wrong. This was not a problem in earlier versions of RuboCop.
The text was updated successfully, but these errors were encountered: