CRR0012 - Logical OR expression has opposite operands
- 2 minutes to read
This analyzer detects expressions that contain logically opposite parts separated by the ‘||’ (OR) statement.
Such expressions can be simplified. Refer to the following chain of transformations.
str == null || (str != null && str == "");
(str == null || str != null) && (str == null || str == ""); // Distributive property
true && (str == null || str == ""); // (a || !a) == true
str == null || str == ""; // true && b == b
Thus, the str != null (str IsNot Nothing) expression is redundant and can be omitted.