ktfmt icon indicating copy to clipboard operation
ktfmt copied to clipboard

Annotation location on properties

Open liutikas opened this issue 2 years ago • 1 comments

Let me start with I don't know if this is a bug or intentional behavior, but I would like to understand the reasoning behind this behavior.

Assume input:

@get:Rule
val benchmarkRule = BenchmarkRule()

this turns into when using --kotlinlang-style:

@get:Rule val benchmarkRule = BenchmarkRule()

What is the reasoning behind annotations being on the same line?

I see similar behavior on data classes

@Entity
data class EntityWithEnum(
    @PrimaryKey
    val id: Long,
    val fruit: Fruit
)

becomes

@Entity data class EntityWithEnum(@PrimaryKey val id: Long, val fruit: Fruit)

and it seems that putting the annotation on the same line makes it harder to read.

liutikas avatar Jul 07 '23 20:07 liutikas

This kind of formatting sometimes bugs me too... However, I don't expect changes anytime soon, see #226 and #395 for further reference. There is a workaround including comments - kind of ugly, but can help readability in some cases.

All that said, I think having consistent formatting outweighs the cost of the occasional style decision I personally don't agree with :)

greyhairredbear avatar Jul 26 '23 16:07 greyhairredbear