no-unit-return
What it does
Section titled “What it does”Reports a function with a block body that declares : Unit as its return type.
Why it matters
Section titled “Why it matters”Unit is what a function returns by default, so writing it repeats the language and distracts a reader who looks for a type that matters.
To fix, delete : Unit.
Example
Section titled “Example”fun a(): Unit {}fun b(x: Int = 1): Unit { return }fun c(): Int { return 1 }fun d(): Unit = Unitfun Unit.e() {}fun f() { fun g(): Unit {}}Configuration
Section titled “Configuration”kotlin: lint: rules: no-unit-return: warn # off, warn (default), errorEnabled by the presets: kotlin/ktlint.
Suppress one line with sudsy-disable-next-line no-unit-return in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| ktlint | no-unit-return |
full |