Skip to content

Files

Latest commit

 

History

History
26 lines (19 loc) · 600 Bytes

ReturnFromFinallyBlock.md

File metadata and controls

26 lines (19 loc) · 600 Bytes

Pattern: Return from finally block

Issue: -

Description

Checks for a return from within a finally block. Returning from a finally block is confusing and can hide the original exception.

Here is an example of code that produces a violation:

int someMethod() {
    try {
        doSomething()
        return 0
    } catch(Exception e) {
        return -1
    } finally {
        return 99               // violation
    }
}

Further Reading