Should we expect `function-expression-body` to ha...
# ktlint
p
Should we expect
function-expression-body
to have detected the following:
Copy code
fun foo(): Any {
    return bar { return@bar null }
}
as it could be written as
Copy code
fun foo(): Any = bar { return@bar null }
?
p
It seems to be caused by the existence of the
return
keyword twice in the body of the function. The rule does not apply when it founds that keyword more than once in the body.
Copy code
block
            .takeIf { it.containingOnly(RETURN) }
            ?.takeUnless { it.countReturnKeywords() > 1 }
I cannot recall why I added that last line. When I remove it, no unit tests breaks... Please create an issue for it and I will have a look at a later time.