All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.javascript.rules.javascript.UnreachableCode.html Maven / Gradle / Ivy

Jump statements (return, break and continue) and throw expressions move control flow out of the current code block. Typically, any statements in a block that come after a jump or throw are simply wasted keystrokes lying in wait to confuse the unwary.

Noncompliant Code Example

fun(a) {
  var i = 10;
  return i + a;       // Noncompliant 
  i++;             // this is never executed
}

Compliant Solution

int fun(int a) {
  int i = 10;
  return i + a;
}

See

  • MISRA C++:2008, 0-1-9 - There shall be no dead code
  • MISRA C:2012, 2.2 - There shall be no dead code
  • MITRE, CWE-561 - Dead Code
  • CERT, MSC12-C - Detect and remove code that has no effect or is never executed
  • CERT, MSC12-CPP - Detect and remove code that has no effect




© 2015 - 2025 Weber Informatics LLC | Privacy Policy