Skip to main content

CRR0005 - Expression value is always the same

This analyzer detects invariant conditions. Such conditions evaluate to the same value regardless of variables they include. For instance, consider the following example.

if (condition && !condition) { // CRR0005
    // ...
}

To make it clear, look at the truth table of this expression.

condition !condition condition && !condition
True False False
False True False

As you see, the last column has the same value in each row, which means variables in this expression do not affect the result. You need to modify such expressions or change your code to avoid the condition.

In the example above, the code inside the condition will never be executed, so this block can be completely removed.