Skip to main content

CRR0025 - Unreachable conditional code block (the inversed condition is already satisfied)

This analyzer detects conditional statements that always evaluate to false because of a conditional statement above. A possible example is shown in the code snippet below.

if(condition) {
    if(!condition) { // CRR0025
        DoSomething();
    }
}

In the example given above, the DoSomething() method will never be executed. To check this, apply the Combine/Split Conditional(s) refactoring to one of the if statements. The combined conditional expression condition && !condition will always be false, which means that the body of the conditional statement will never be executed.