Avoid returning from within a finally
block, as this can prevent normal exception handling control flow from executing.
Reports all return statements in finally blocks. Using return statements in finally blocks can discard and hide exceptions that are thrown in the try block. Furthermore, this rule reports values from finally blocks, if the corresponding try is used as an expression.
fun foo() {
try {
throw MyException()
} finally {
return // prevents MyException from being propagated
}
}
Remove return statements from finally blocks.