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

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

There is a newer version: 2.5
Show newest version

When the last statement of a switch-clause is not a break statement, the control flow "falls" into the next switch-clause. Whilst this is sometimes intentional, it is often a mistake which could lead to some unexpected behaviors. This rule doesn't apply to empty switch-clauses. Indeed those empty switch-clauses allow to specify the same behavior to a group of cases.

The following code snippet illustrates this rule:

switch (param) {
  case 0: // Compliant
  case 1: // Compliant
    break;
  case 2: // Compliant
    return;
  case 3: // Compliant
    throw new Error();
  case 4: // Non-Compliant
    doSomething();
  default: // Compliant
    doSomethingElse();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy