Examples:
// always true
// root cause: || is used instead of &&
if (x > 0 || x < 10) {}
System.out.println(str.trim());
// always false
// root cause: variable was dereferenced before null-check
if (str == null) {}
The inspection behavior may be controlled by a number of annotations, such as
nullability annotations,
@Contract
annotation,
@Range
annotation and so on.
Configure the inspection:
if (alwaysFalseCondition) throw new IllegalArgumentException();
.assert
statements. By default, the option
is disabled, which means that the assertions are assumed to be executed (-ea mode). If the option is enabled, the assertions will be completely ignored
(-da mode).Before IntelliJ IDEA 2022.3, this inspection was part of "Constant Conditions & Exceptions" inspection. Now, it split into two inspections: "Constant Values" and "Nullability and data flow problems".