You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This doesn't seem right to me? It's a nuanced difference, but I don't consider this multi-lined arguments—the argument actually starts on the same line as the parentheses. The argument itself is multi-lined for readability, but the arguments aren't multi-lined. This is what I think multi-lined arguments look like:
The text was updated successfully, but these errors were encountered:
brandonweiss
changed the title
Style/TrailingCommaInArguments false positive
Style/TrailingCommaInArguments false positive with interpretation of multi-lined arguments?
Oct 7, 2016
I agree. The purpose of the trailing comma cops is to make it possible to enforce a style that minimizes the diff when another element is added at the end. And the comma in your example is useless for that purpose.
In this code from lib/rubocop/cop/mixin/trailing_comma.rb, we see that the intentions are correct, but the implementation is wrong.
# Returns true if the round/square/curly brackets of the given node are# on different lines, and each item within is on its own line, and the# closing bracket is on its own line.defmultiline?(node)
The closing bracket, ) in your case, is not on its own line.
I noted BTW that you also need the following configuration to reproduce the problem:
The method TrailingComma#multiline? should not return true
for a single argument (possibly spanning multiple lines)
followed by a closing bracket that's not on its own line.
If I set this configuration:
Then it enforces this code should have a comma like this:
This doesn't seem right to me? It's a nuanced difference, but I don't consider this multi-lined arguments—the argument actually starts on the same line as the parentheses. The argument itself is multi-lined for readability, but the arguments aren't multi-lined. This is what I think multi-lined arguments look like:
Or in the context of a hash:
Thoughts?
The text was updated successfully, but these errors were encountered: