ReSharper
 
Get ReSharper
You are viewing the documentation for an earlier version of ReSharper.

Code Inspection: Expression is always 'true' or always 'false'

Last modified: 08 March 2021

This inspection is fairly obvious: ReSharper analyzes values and nullability of symbols and suggests to eliminate expressions that are always true or always false.

The only problem with this inspection is that sometimes it's not obvious how ReSharper has come to this conclusion. Because of this, you may be unwilling to accept the ReSharper’s suggestion to replace an expression with explicit true or false, or to remove a redundant check in an if statement. Below are some StackOverflow questions that illustrate this problem: