java/java-impl/resources/inspectionDescriptions/DataFlowIssue.html
Reports code constructs that always violate nullability contracts, may throw exceptions, or are just redundant, based on data flow analysis.
Examples:
if (array.length < index) {
System.out.println(array[index]);
} // Array index is always out of bounds
if (str == null) System.out.println("str is null");
System.out.println(str.trim());
// the last statement may throw an NPE
@NotNull
Integer square(@Nullable Integer input) {
// the method contract is violated
return input == null ? null : input * input;
}
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:
@Nullable annotation. You can also configure nullability annotations using the Configure Annotations button.null literal is passed.@Nullable, but always return non-null value. In this case, it's suggested that you change the annotation to @NotNull.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).MatchException at runtime due to null values in deconstruction patterns.Before IntelliJ IDEA 2022.3, this inspection was part of the "Constant Conditions & Exceptions" inspection. Now, it is split into two inspections: "Constant Values" and "Nullability and data flow problems".