Rule Definition
Using return, break, throw, and continue from a finally block overwrites similar statements from the suspended try and catch blocks. This create an issue when a jump statement (break, continue, return and throw) would force control flow to leave a finally block.
Remediation
Avoid using jump statements in finally block. If used, it will swallow the exception raised but not handled in above try catch block.
Violation Code Sample
>>> function experiment () {
>>> try {
>>> throw new RuntimeException();
>>> } finally {
>>> console.log("Finally Block");
>>> return;
>>> }}
Fixed Code Sample
>>> function experiment(){
>>> try {
>>> throw new RuntimeException();
>>> } finally {
>>> console.log ("Finally Block")
>>> }} #Return should not be used inside finally
Reference
CISQ : ASCSM-CWE-835
Related Technologies
Technical Criterion
CWE-1075 - Unconditional Control Flow Transfer outside of Switch Block
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.