Skip to content
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

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

Closed
mfederczuk opened this issue Aug 9, 2022 · 0 comments · Fixed by #1582

Comments

@mfederczuk
Copy link
Contributor

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

@paul-dingemans paul-dingemans added this to the 0.47.0 milestone Aug 13, 2022
paul-dingemans added a commit to paul-dingemans/ktlint that referenced this issue Aug 14, 2022
…ameter is a destructuring declaration followed by a trailing comma

Closes pinterest#1578
Goooler pushed a commit to Goooler/ktlint that referenced this issue Aug 15, 2022
…ameter is a destructuring declaration followed by a trailing comma (pinterest#1582)

Closes pinterest#1578
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants