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

Update documentation value-argument-comment #2513

Closed paul-dingemans closed 8 months ago

paul-dingemans commented 8 months ago

Ktlint documentation refers to this comment to explain why EOL comments on the same line as a value argument can result in problems.

However, the same problem occurs when the comments are placed on separate lines.

Before the refactoring:

data class Foo(val someParam1: Int, val someParam2: Int, val someParam3: List<String>)

val foo = Foo(
    // some comment here about why 1
    someParam1 = 10_000,
    // some comment here about why 2
    someParam2 = 100,
    // some comment here about why 3
    someParam3 = emptyList(),
)

After the "Change signature" refactoring:

data class Foo(val someParam1: Int, val someParam3: List<String>, val someParam2: Int)

val foo = Foo(
    // some comment here about why 1
    someParam1 = 10_000,
    // some comment here about why 2
    someParam3 = emptyList(),
    // some comment here about why 3
    someParam2 = 100,
)

Originally posted by @YSakhno in https://github.com/pinterest/ktlint/issues/2445#issuecomment-1911159672