Code Inspection: Expression is always 'true' or always 'false'
This inspection is fairly obvious: ReSharper
analyzes values and nullability of symbols and suggests to
eliminate expressions that are always
true or always
The only problem with this inspection is that sometimes
it's not obvious how ReSharper has come to this conclusion,
and hence the unwillingness to accept its suggestion to replace an expression with explicit
false, or remove a redundant check in an
Below are some StackOverflow questions that illustrate this problem:
- Why does ReSharper tell me this expression is always true?
- How Does Resharper Know “Expression is always true”?
- Resharper bug? Incorrect “expression is always true”
- ReSharper claims that my expression is always true? Is it correct or is it a bug?
- Resharper says this expression is always true. Why?
- Trying to understand why resharper told me expression is always false
- Why I getting an “Expression always true” warning?