-
-
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
Check indentation of method arguments spanning multiple lines #1144
Comments
@jonas054 Would you look into this? |
Sure. @bbatsov @bquorning What do you think the correct indentation should be? Some example code please. |
Perhaps: run(:foo, defaults.merge(
bar: 3
)
)
run(
:foo,
bar: 3
) |
Not sure, about the first case, but I'm pretty sure about the second one. |
There’s no doubt about the second example – I would indent it as @bbatsov does: run(
:foo,
bar: 3
) The first one is more tricky. I definitely don’t like the “hanging indentation” of the hash and closing parentheses. The problem is that two parentheses are opened on the same line, but closed on different lines. They should either be closed on the same line run(:foo, defaults.merge(
bar: 3
)) Or opened on different lines: run(:foo,
defaults.merge(
bar: 3
)
) Or one or both sets of parentheses just be on the same line: run(:foo,
defaults.merge(bar: 3)
)
run(:foo, defaults.merge(bar: 3)) Keeping both opening parentheses on one line and closing them on different lines, I cannot think of a style that looks pleasant: run(:foo, defaults.merge(
bar: 3
)
) # Nope
run(:foo, defaults.merge(
bar: 3
)
) # Nope
run(:foo, defaults.merge(
bar: 3
)
) # Nope |
Where the arguments are placed should be the focus of one cop and how the closing parens are placed should probably be the focus of a separate cop no? |
@jfelchner Yes! Because they follow different rules. |
Add a cop that checks the indentation of the first parameter in a method call. Part of solution for rubocop#1144.
Great work on the Would it be possible to check the ending parentheses, too? RuboCop still reports no offenses for this code: def foo
puts('x'
)
end
def bar
puts(
'y'
)
end |
It's possible, but it should be done by a dedicated cop IMO. On 23 February 2015 at 14:57, Benjamin Quorning [email protected]
Best Regards, |
Rubocop with default configuration detects no offenses on this code:
I do, however. All of the arguments to the
#run
calls are mis-indented.The text was updated successfully, but these errors were encountered: