根据数据流分析,报告始终违反为 null 性约定、可能抛出异常或只是冗余的代码结构。

示例:

if (array.length < index) {
  System.out.println(array[index]);
} // 数组索引始终超出界限

if (str == null) System.out.println("str is null");
System.out.println(str.trim());
// 最后一条语句可能会抛出 NPE

@NotNull
Integer square(@Nullable Integer input) {
    // 违反方法约定
    return input == null ? null : input * input;
}

检查行为可能由许多注解控制,例如为 null 性注解、@Contract 注解、@Range 注解等。

配置检查:

在 IntelliJ IDEA 2022.3 版本之前,此检查为“常量条件和异常”检查的一部分。 现在,它被拆分成两个检查:“常量值”和“为 null 性和数据流问题”。