JetBrains Rider 2024.1 Help

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

Category

Redundancies in Code

ID

ConditionIsAlwaysTrueOrFalse

EditorConfig

resharper_condition_is_always_true_or_false_highlighting

Default severity

Warning

Language

C#, VB.NET

Requires SWA

No

This inspection is fairly obvious: JetBrains Rider analyzes values and nullability, integer arithmetics, and so on, and suggests eliminating expressions that are always true or always false based on its analysis results.

The only problem with this inspection is that sometimes it's not obvious how JetBrains Rider has come to this conclusion. Because of this, you may be unwilling to accept suggestions to replace expressions with explicit true or false, or to remove redundant checks in if statements. Below are some StackOverflow questions that illustrate this problem:

Last modified: 10 April 2024