KT.EXPRESSION_BODY_SYNTAX
Function only contains a return statement
Functions which only contain a return statement can be collapsed to an expression body. This shortens and cleans up the code.
Noncompliant Code
Copy
fun stuff(): Int {
return 5
}
Compliant Code
Copy
fun stuff() = 5
fun stuff() {
return
moreStuff()
.getStuff()
.stuffStuff()
}
Options
-
includeLineWrapping
(default:False
)include return statements with line wraps in it