Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KDoc: @param and @property sorted by type, not by position #431

Closed
no-preserve-root opened this issue Oct 31, 2023 · 0 comments
Closed

KDoc: @param and @property sorted by type, not by position #431

no-preserve-root opened this issue Oct 31, 2023 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@no-preserve-root
Copy link
Contributor

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()
}
@hick209 hick209 added enhancement New feature or request good first issue Good for newcomers labels Mar 26, 2024
no-preserve-root added a commit to no-preserve-root/ktfmt that referenced this issue Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants