Skip to content

redundant-return-type

all languagesstylefix: safedefault: off

Removes a return type that the language gives every function with a block body anyway (fun f(): Unit { } in Kotlin; the types come from the option redundant_return_types). The functions are those with a block body, the type is the one after the colon that follows the parameters. The rule works in the formatter, which applies it when it is on (Kotlin has it on); sudsy lint makes no report for it.

The type says nothing the reader does not already know, and it makes the signature longer. Unit is what a block body returns when it has no return of a value.

To fix, delete the colon and the type; the formatter does it.

lint:
rules:
redundant-return-type: warn # off (default), warn, error

Suppress one line with sudsy-disable-next-line redundant-return-type in a comment of the file’s language.