org.sonar.l10n.javascript.rules.javascript.S3973.html Maven / Gradle / Ivy
This rule is deprecated, and will eventually be removed.
Why is this an issue?
When the line immediately after a conditional has neither curly braces nor indentation, the intent of the code is unclear and perhaps not what is
executed. Additionally, such code is confusing to maintainers.
if (condition) // Noncompliant
doTheThing();
doTheOtherThing(); // Was the intent to call this function unconditionally?
It becomes even more confusing and bug-prone if lines get commented out.
if (condition) // Noncompliant
// doTheThing();
doTheOtherThing(); // Was the intent to call this function conditionally?
Indentation alone or together with curly braces makes the intent clear.
if (condition)
doTheThing();
doTheOtherThing(); // Clear intent to call this function unconditionally
// or
if (condition) {
doTheThing();
}
doTheOtherThing(); // Clear intent to call this function unconditionally
This rule raises an issue if the line controlled by a conditional has the same indentation as the conditional and is not enclosed in curly
braces.