Kotlin

Kotlin

Made by DeepSource

Functions with only the return statement should be rewritten with expression body syntax KT-W1051

Anti-pattern
Minor

Functions which only contain a return statement can be collapsed to an expression body. This shortens the code and makes it more readable.

Bad Practice

fun stuff(): Int {
    return 5
}

Recommended

Prefer using the expression body syntax.

fun stuff() = 5

References