pinterest / ktlint

An anti-bikeshedding Kotlin linter with built-in formatter
https://pinterest.github.io/ktlint/
MIT License
6.19k stars 505 forks source link

False (confusing?) positive: Expected a newline before comment (standard:enum-wrapping) #2510

Closed scottkennedy closed 8 months ago

scottkennedy commented 8 months ago

Expected Behavior

There is a newline before every comment, so either this is a false positive, or it's giving the wrong error.

Observed Behavior

Sample.kt:1:36 Expected a newline before comment (standard:enum-wrapping)

Steps to Reproduce

enum class Sample(val key: String) {

    // https://docs.google.com/...

    // Foo
    Foo("bar"),
}

Running the ktlint formatter removes the first blank line in the file (between enum class and the first comment), but it still fails the check with the same error.

Your Environment

paul-dingemans commented 8 months ago

Tnx for reporting. This is indeed a bug. It seems to be caused by the blank line between the two EOL-comments. Without that blank line no violation is reported.