Download User's Guide

Transcript
ModifyInCondition.rule
Items Enforced
ModifyInCondition.rule
Do not use operator ++ or -- in the
conditional part of if, while, or switch
This rule checks whether you use operator ++ or -- in the conditional
part of if, while, or switch.
Reason for rule: Using the operator ++ or -- in the conditional part of
if, while, or switch can make code difficult-to-read and error-prone .
Example
int Foo (int iVar)
{
if (iVar-- && iVar<10) { // hit
iVar += 10;
} else {
iVar -= 10;
}
return iVar;
}
274