cortinico / ktfmt-gradle

A Gradle plugin to apply ktfmt to your builds, and reformat you Kotlin source code like a glimpse 🧹🐘
MIT License
158 stars 19 forks source link

*Style helpers reset the config #362

Open christophsturm opened 2 months ago

christophsturm commented 2 months ago

if i want kotlin style but not managed commas, this works:

ktfmt {
    kotlinLangStyle()
    manageTrailingCommas = false
}

but this does not:

ktfmt {
    manageTrailingCommas = false
    kotlinLangStyle()
}

if kotlinLangStyle always needs to be first, which is totally fine, the second version should produce an error message.

cortinico commented 2 months ago

the second version should produce an error message.

This could be hard to implement as those functions such as kotlinLangStyle() are effectively calling a collection of setters.

simonhauck commented 2 months ago

Maybe it would be possible if the kotlinLangStyle method would not set the values directly and instead would invoke the convention method. Then the user could still overwrite the parameters by explicitly specifing them