Avoid-Jumping-In-Finally¶
Sourcery rule id: avoid-jumping-in-finally¶
Description¶
Avoid the use of jump statements in finally blocks.
Match¶
try {
stuff();
} finally {
for (thing of things) {
return;
}
}
Explanation¶
Returning results or throwing exceptions in finally blocks (of try..catch..finally) suppresses propagation of unhandled exceptions.
The return, break, throw, and continue statements should therefore not be used within a finally block.