Skip to content

trailing-comma-on-declaration-site

Kotlinstyleno fixdefault: offkotlin/ktlint

Reports the last parameter of a multi-line declaration that has a trailing comma the formatter would add or remove.

With a trailing comma, adding a parameter at the end changes one line instead of two, and reordering parameters does not need the comma moved.

To fix, run the formatter.

Reported
...
val b: Int) {
...
...
fun bar(
a: Int,
b: Int
) = a + b
fun ok(a: Int) = a
...
kotlin:
lint:
rules:
trailing-comma-on-declaration-site: warn # off (default), warn, error

Enabled by the presets: kotlin/ktlint.

Suppress one line with sudsy-disable-next-line trailing-comma-on-declaration-site in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
ktlint trailing-comma-on-declaration-site full