ktlint icon indicating copy to clipboard operation
ktlint copied to clipboard

False positive: 'Missing newline after ","' for destructured lamba parameters with trailing commas

Open mfederczuk opened this issue 2 years ago • 0 comments

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

  1. Enable trailing commas
  2. Write a lambda with destructured parmeters
  3. Put all destructured parameters on separate lines and format the file accordingly
  4. Run ktlint
  5. 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

mfederczuk avatar Aug 09 '22 10:08 mfederczuk