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

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

There is a newer version: 2.5
Show newest version

switch statements are useful when there are many different cases depending on the value of the same expression. For just one or two cases however, the code will be more readable with if statements.

Noncompliant Code Example

switch (variable) {
  case 0:
    doSomething();
    break;
  default:
    doSomethingElse();
    break;
}

Compliant Solution

if (variable == 0) {
  doSomething();
} else {
  doSomethingElse();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy