The requested page is not available for the requested platform. You are viewing the content for Default platform.

CRR0015 - Logical OR expression redundancy

This analyzer detects logical expressions that contain the same logical variable on both sides of the logical OR expression. For instance, consider the following conditional expression.

if (a || a && b){ // CRR0015
    // ...
}

Such expressions may appear by mistake. Refer to the truth table of the conditional expression from the example above.

a b a && b a || (a && b)
True True True True
True False False True
False True False False
False False False False

As you can see, the last column is similar to the a column, which means that the expression equals the a variable value. Since the value of the b variable is not considered in this expression, it probably contains a mistake. You can fix it manually according to the desired logic or use the Simplify Expression refactoring to automatically shorten this expression.

if (a){
    // ...
}