fun <T> autoClose(wrapped: T, closeFunction: suspend (T) -> Unit): T
I get these 3 errors:
Copy code
> Task :failgood:lintKotlinMain FAILED
/Users/christoph/Projects/failgood/failgood/jvm/src/failgood/dsl/ResourcesDSL.kt:25:23: Lint error > [standard:function-signature] Newline expected after opening parenthesis
/Users/christoph/Projects/failgood/failgood/jvm/src/failgood/dsl/ResourcesDSL.kt:25:35: Lint error > [standard:function-signature] Parameter should start on a newline
/Users/christoph/Projects/failgood/failgood/jvm/src/failgood/dsl/ResourcesDSL.kt:25:69: Lint error > [standard:function-signature] Newline expected before closing parenthesis
the whole line is only 73 chars long.
p
Paul Dingemans
10/11/2023, 7:13 PM
In
ktlint-official
code style, the
function-signature
rules starts wrapping function signatures when the function contains 2 or more parameters regardless of line length. See documentation for configuration
c
christophsturm
10/12/2023, 12:53 PM
ok. one possible improvement would be that the error message could mention that it splits because of the number of parameters.
christophsturm
10/13/2023, 8:24 AM
does the idea formatter also do that or is it recommended in a style guide?
p
Paul Dingemans
10/13/2023, 8:35 AM
No and no.
ktlint_official
goes beyond the style guides and puts more emphasis on consistency of code. By formatting all function signatures in a consistent way, maintenance becomes easier in my opinion. IntelliJ IDEA allows all following in same class/file:
Copy code
fun foo1(a: String, b: String) = "foo"
fun foo2(
a: String, b: String
) = "foo"
fun foo3(
a: String,
b: String
) = "foo"
When working with multiple developers on the same project, or when maintain a long lived project, more and more variations of function signatures are introduced. This rules, restricts the number of variations by imposing stricter rules.
c
christophsturm
10/13/2023, 9:11 AM
i really want uniform formatting for calls but i only want it to wrap when the max line count is reached. how can i do that?