Skip to content

function-signature

Kotlinstyleno fixdefault: offkotlin/ktlint

Reports a function whose signature (everything up to the body) the formatter would lay out differently: the parameters on one line or one per line, the return type, and where the body starts.

A signature that is laid out the same way in the whole project is quick to scan, and when a parameter is added only one line changes.

To fix, run the formatter.

Reported
...
fun foo(a: Int, b: String, c: Long, d: Double, e: Float, f: Short, g: Byte, h: Char, i: Boolean, j: Unit): Int { return 1 }
fun baz() = run {
1
}
...
kotlin:
lint:
rules:
function-signature: warn # off (default), warn, error

Enabled by the presets: kotlin/ktlint.

Suppress one line with sudsy-disable-next-line function-signature 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 function-signature full