The Braces Ruleset contains a collection of braces rules.
Since: PMD 5.0
Priority: 3
Avoid using if statements without using curly braces.
//IfStatement[@Else = "false" and not(child::Scope)]
Example(s):
// Ok if (foo) { x++; } // Bad if (foo) x++;
Since: PMD 5.0
Priority: 3
Avoid using if..else statements without using curly braces.
//ExpressionStatement[parent::IfStatement[@Else = "true"]] [not(child::Scope)] [not(child::IfStatement)]
Example(s):
// Ok if (foo) { x++; } else { y++; } // Bad if (foo) x++; else y++;