if/else/for/while/do statements should always use curly braces

  • squid : S00121

Not using curly braces could be error-prone in some cases. For instance in the following example, the two statements seems to be attached to the if statement whereas this is the case only for the first one:

if (condition) // Non-Compliant
  executeSomething();
  checkSomething();

if (condition) { // Compliant
  executeSomething();
}
checkSomething();
Close