ktfmt
ktfmt copied to clipboard
KDoc: `@param` and `@property` sorted by type, not by position
When formatting the KDoc of a class, the @param and @property tags can be used to describe parameters. @param should be used for parameters that are not (visibly) stored (e.g. foo or private val foo), while property should be used for parameters that become visible properties (e.g. val foo). This is e.g. enforced by detekt's OutdatedDocumentation rule.
Detekt requires these tags to be in the order of the primary constructor. Ktfmt insists on ordering these tags as @param (in constructor order), then @property (in constructor order). At the moment, it is impossible to satisfy both ktfmt and detekt.
Expected by detekt
/**
* @property foo …
* @param bar …
* @property baz …
*/
fun test(val foo: String, bar: String, val baz: String) {
TODO()
}
Formatted by ktfmt
/**
* @param bar …
* @property foo …
* @property baz …
*/
fun test(val foo: String, bar: String, val baz: String) {
TODO()
}