Allow simple if conditions without curly braces

  • description of the Rule.
    Would it be possible to have (in JavaScript) a little lighter rule compared to the current rule “Control structures should use curly braces” (javascript:S121) which allows single line commands to keep the code simple?

  • snippet of Noncompliant Code
    if (condition) // Noncompliant
    executeSomething();

  • snippet of Compilant Code (fixing the above noncompliant code)
    Option 1 (new):
    if (condition) executeSomething();

Option 2 (as in current rule)
if (condition) {
executeSomething();
}

  • exceptions to the Noncompliant Code
    as in existing rule

  • type : Code Smell

  • Tags: pitfall