ktlint
ktlint copied to clipboard
False positive: 'Missing newline after ","' for destructured lamba parameters with trailing commas
When destructured parameters in a lambda are put on separate lines with trailing commas turned on, the error Missing newline after "," (wrapping)
is issued just after the final trailing comma of the destructuring parenthesis, regardless of how many newlines are actually written.
Expected Behavior
False positive; expected no error.
Observed Behavior
The error Missing newline after "," (wrapping)
is issued after the trailing comma of the destructuring parenthesis, regardless of how many newlines are written.
Steps to Reproduce
- Enable trailing commas
- Write a lambda with destructured parmeters
- Put all destructured parameters on separate lines and format the file accordingly
- Run
ktlint
- See error
Demo.kt
:
fun foo(block: (Pair<Int, Int>) -> Unit) {}
fun main() {
foo {
(
a,
b,
), // error appears here, regardless of how many newlines are written
->
}
}
ktlint
output:
Demo.kt:8:15: Missing newline after "," (wrapping)
Your Environment
-
Version of ktlint used:
0.46.1
-
Relevant parts of the
.editorconfig
settings:ij_kotlin_allow_trailing_comma = true
-
Operating System and version: Linux Fedora 36