Since: PMD 5.0
Avoid using if statements without using curly braces.
//IfStatement[@Else = "false" and not(child::Scope)]
// Ok
if (foo) {
x++;
}
// Bad
if (foo)
x++;
Since: PMD 5.0
Avoid using if..else statements without using curly braces.
//ExpressionStatement[parent::IfStatement[@Else = "true"]]
[not(child::Scope)]
[not(child::IfStatement)]
// Ok
if (foo) {
x++;
} else {
y++;
}
// Bad
if (foo)
x++;
else
y++;