-
Notifications
You must be signed in to change notification settings - Fork 506
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
Fixes #620 by adding arguments to ParameterListWrappingRule. #786
Conversation
hey @AdamMc331, are you planning to finish this up or should we take over? |
Hey @romtsn Sorry for falling off on this again. I still have an issue formatting this if there's a argument list inside an annotation. I will clean up my git history and write a test to demonstrate the bug, but I'd definitely appreciate some help looking into it I'm at a loss. |
I made it work, but there's another corner case, which we probably should consider and I'm looking into it now: class NoVarRuleTest : Spek({
// this should not fail
}) |
👀 Exciting! Thanks for your help pushing this across the finish line. |
I am a bit hesitant to release this in the standard ruleset, as although the change is not significant code-wise, it kind of has a big impact even on ktlint's codebase.. maybe we should move it to the experimental ruleset for the next release? Thoughts @Tapchicoma @shashachu @AdamMc331? Otherwise, it's ready to be merged. |
I'm open to the experimental ruleset but that could also be the imposter syndrome talking. 😂 This is my first contribution to a ktlint ruleset and so I'm definitely not as familiar as the others tagged but I will support their opinion either way. If we go with the experimental ruleset, what is the process like for getting it moved out of experimental in the future? |
Although it may aggravate some people, I don't think it's a big deal to leave this in the standard ruleset, as its functionality is more consistent with the IndentRule, which is quite aggressive about adding newlines. |
@AdamMc331 does this PR also address #680? |
@shashachu nope, that problem is specific to indentation rule |
Thanks Adam! |
Thanks everyone! :) |
I’m seeing lots of results for Questionable. Fails with foo(bar.apply {
// stuff
}) Wrong? Fails json(
"""
{
"array": [
${function(arg1, arg2, arg3)}
]
}
""".trimIndent()
) |
Reference ticket #620 for details. This now considers anything that is
VALUE_ARGUMENT
in addition toVALUE_PARAMETER
for theParameterListWrappingRule
. This means function calls will get the same treatment as class definitions for their arguments being on separate lines (if necessary).Example
Before, ktlint considered this valid:
This is not clear, though, as multiple arguments on one line is confusing, if they're not all on one line. Now it will auto format them to be on separate lines:
One Concern
All of the tests pass, but the annotation one is a little confusing as for me it appears it wanted to format the annotation like this:
Some back and forth with @romtsn on the ticket right now though to see if that's an issue before we merge this.