Skip to content

[1.3.0] Data class comments break indentation formatting #2689

@Bencodes

Description

@Bencodes

Expected Behavior

Formatting data classes with // comments should produce valid Kotlin code.

Observed Behavior

Auto fixing produces invalid Kotlin code that does not compile.

Steps to Reproduce

Run ktlint -f against the following Kotlin data class:

data class Foo(
    // Foo
    val foo: String,
    val bar: String,
)

Results in:

data class Foo(
    // Fooval foo: String, val bar: String,)

KtLint does not fail if you replace the // Foo comment with /* Foo */.

Your Environment

  • Version of ktlint used: 1.3.0
  • Relevant parts of the .editorconfig settings: An empty configuration reproduces this error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions