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

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

There is a newer version: 10.17.0.28100
Show newest version

Any statement or block of statements can be identified by a label, but those labels should be used only on while, do-while, for and switch statements. Using labels in any other context leads to unstructured, confusing code.

Noncompliant Code Example

myLabel: if (i % 2 == 0) {  // Noncompliant
  if (i == 12) {
    console.log("12");
    break myLabel;
  }
  console.log("Even number, but not 12");
}

Compliant Solution

myLabel: for (i = 0; i < 10; i++) {   // Compliant
  console.log("Loop");
  break myLabel;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy