When I have statements like those:
myStatement(parameter1, parameter2, parameter3)
myOtherStatement(parameter1, lambda = {
otherStatement
})
I expect the linter to report nothing
I get a bunch of:
Missing newline after "("
Missing newline after ","
Missing newline before ")"
With ktlint up to 0.36.0 no problems. I believe it's something with the new indentation rule promoted from experimental. Is it possible to keep the "old" behaviour? I find it excessive to have very short statements split on multiple lines only for a ktlint rule.
Hi, yes the formerly-experimental-now-standard rule is more aggressive with inserting newlines, and I understand IDEA also accepts the formatting you've shown in the issue. We'll discuss internally whether any changes need to be made.
After some discussion we decided to split indentation rule into more granular rules, that could be disabled via .editorconfig. Default behaviour would be as observed one.
@Tapchicoma what's the correct rule to be disabled in this case? Is it indent or is there any more specific rule I can disable?
For clarity here's an example (this is accepted by Android Studio auto-format):
.subscribe({
doSomenthing()
}, {
error()
})
is formatted by the formatKotlin task into this:
.subscribe(
{
doSomenthing()
},
{
error()
}
)
Thanks
Yes, it is the entire indent rule at the moment
I think that indent rule is too comprehensive.
How about add specific rule aggressive-inserting-newlines to disable issue's example only?
Yes, please, this currently stops us from upgrading to 0.37 or later, otherwise we'd face thousands of lines of reformatting :(
same here, we don't want the curly braces to be placed in new lines!
Any news about this?
Most helpful comment
same here, we don't want the curly braces to be placed in new lines!