resources.report.rules.pmd.LogicInversion.html Maven / Gradle / Ivy
LogicInversion
LogicInversion
Use opposite operator instead of negating the whole expression with a logic complement operator.
//UnaryExpressionNotPlusMinus[@Image='!']/PrimaryExpression/PrimaryPrefix/Expression[EqualityExpression or RelationalExpression]
Example(s):
public boolean bar(int a, int b) {
if (!(a == b)) { // use !=
return false;
}
if (!(a < b)) { // use >=
return false;
}
return true;
}