Files
2026Technology-Competition/data/demo-pmd/reports/DesignErrorProne-review.md
T

83 KiB
Raw Blame History

代码审查报告

文件: data\demo-pmd\src\com\demo\designep\DesignErrorProne.java 语言: java 耗时: 195.1s 分析工具: pmd


总计: 771 | 错误: 166 | 警告: 598 | 建议: 7

静态分析 · 762 个问题

  • 🔴 pmd:AbstractClassWithoutAnyMethod L30 抽象类没有抽象方法,abstract 可能只是用来阻止实例化 建议: 如果目的是阻止实例化,应使用私有或 protected 构造函数而非 abstract。
  • 🔴 pmd:SystemPrintln L39 使用了 System.out/err 输出 建议: 改用 SLF4J/Log4j 等日志框架记录输出。
  • 🔴 pmd:AvoidThrowingNullPointerException L75 避免手动抛出 NullPointerException 建议: 应通过参数校验、Objects.requireNonNull 等方式处理,而不是直接 new NullPointerException。
  • 🔴 pmd:AvoidThrowingRawExceptionTypes L82 避免抛出原始异常类型 RuntimeException 建议: 抛出自定义异常或更具体的异常类型,并携带业务上下文。
  • 🔴 pmd:ClassWithOnlyPrivateConstructorsShouldBeFinal L93 只有私有构造函数,应声明为 final 建议: 给类添加 final 修饰符,防止通过反射或内部类扩展。
  • 🔴 pmd:SystemPrintln L103 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L140 Usage of System.out/err
  • 🔴 pmd:FieldNamingConventions L149 字段命名不符合约定 建议: 按 Java 命名规范:常量用 UPPER_SNAKE,普通字段用 lowerCamel。
  • 🔴 pmd:SystemPrintln L155 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L158 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L161 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L164 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L167 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L170 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L173 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L176 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L179 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L182 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L185 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L188 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L191 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L194 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L197 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L200 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L203 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L206 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L209 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L212 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L215 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L218 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L221 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L224 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L227 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L230 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L233 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L236 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L239 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L242 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L245 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L248 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L251 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L254 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L257 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L260 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L263 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L266 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L269 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L272 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L275 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L278 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L281 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L284 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L287 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L290 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L293 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L296 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L299 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L302 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L422 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L423 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L424 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L425 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L426 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L427 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L428 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L429 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L430 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L431 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L432 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L433 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L436 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L437 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L438 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L439 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L440 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L441 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L442 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L443 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L444 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L445 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L446 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L447 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L450 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L451 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L452 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L453 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L454 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L455 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L456 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L457 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L458 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L459 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L460 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L461 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L464 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L495 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L496 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L497 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L498 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L501 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L502 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L503 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L504 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L507 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L508 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L509 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L510 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L513 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L514 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L515 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L516 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L528 Usage of System.out/err
  • 🔴 pmd:AvoidReassigningParameters L538 避免重新为参数赋值 建议: 使用新的局部变量保存修改后的值。
  • 🔴 pmd:SystemPrintln L539 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L577 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L578 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L586 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L597 Usage of System.out/err
  • 🔴 pmd:ConstructorCallsOverridableMethod L693 构造函数中调用了可重写方法 建议: 避免在构造期间调用非 final/method,或将该方法设为 final/private。
  • 🔴 pmd:DoNotCallGarbageCollectionExplicitly L702 不要显式触发垃圾回收 建议: 删除 System.gc(),交由 JVM 自动管理内存。
  • 🔴 pmd:AvoidThrowingRawExceptionTypes L728 Avoid throwing raw exception type RuntimeException.
  • 🔴 pmd:EqualsNull L758 避免使用 equals() 与 null 比较 建议: 使用 o == null 判空,而不是 o.equals(null)。
  • 🔴 pmd:AvoidReassigningParameters L766 Avoid reassigning parameters such as 's'
  • 🔴 pmd:SystemPrintln L768 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L788 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L790 Usage of System.out/err
  • 🔴 pmd:MethodNamingConventions L816 方法命名不符合约定 建议: 使用 lowerCamelCase 命名方法,如 sameName()。
  • 🔴 pmd:ClassWithOnlyPrivateConstructorsShouldBeFinal L829 This class has only private constructors and may be final
  • 🔴 pmd:MoreThanOneLogger L835 类中包含多个 logger 建议: 统一使用一个 logger 实例,避免日志输出混乱。
  • 🔴 pmd:SystemPrintln L843 Usage of System.out/err
  • 🔴 pmd:ReturnEmptyCollectionRatherThanNull L882 应返回空集合而不是 null 建议: 返回 Collections.emptyList() 或 List.of()。
  • 🔴 pmd:SuspiciousEqualsMethodName L909 方法名与 equals(Object) 高度相似,容易误导 建议: 重命名方法,或改为真正重写 equals(Object)。
  • 🔴 pmd:SystemPrintln L928 Usage of System.out/err
  • 🔴 pmd:FieldNamingConventions L996 The field name 'TypeName' doesn't match '[a-z][a-zA-Z0-9]*'
  • 🔴 pmd:SingleMethodSingleton L1029 类包含多个 getInstance 方法,单例模式混乱 建议: 只保留一个无参 getInstance(),移除重载方法。
  • 🔴 pmd:ClassWithOnlyPrivateConstructorsShouldBeFinal L1029 This class has only private constructors and may be final
  • 🔴 pmd:SingletonClassReturningNewInstance L1039 getInstance 总是创建新对象,不符合单例行为 建议: getInstance 应返回缓存的唯一实例,而不是新建对象。
  • 🔴 pmd:SystemPrintln L1070 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L1078 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L1089 Usage of System.out/err
  • 🔴 pmd:FieldNamingConventions L1096 The constant name '_LOG' doesn't match '[A-Z][A-Z_0-9]*'
  • 🔴 pmd:GuardLogStatement L1101 日志调用应使用日志级别守卫包裹 建议: 添加 if (LOGGER.isDebugEnabled()) 等守卫,或使用占位符避免字符串拼接。
  • 🔴 pmd:SystemPrintln L1134 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L1178 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L1208 Usage of System.out/err
  • 🔴 pmd:SystemPrintln L1218 Usage of System.out/err
  • 🔴 pmd:AvoidBranchingStatementAsLastInLoop L1222 避免在循环末尾使用 break/continue 作为最后一条语句 建议: 调整循环结构,使正常退出条件更明确。
  • 🔴 pmd:AvoidMultipleUnaryOperators L1230 多个一元运算符叠用可能造成误解或 bug 建议: 简化表达式,只保留一个运算符或使用括号明确语义。
  • 🔴 pmd:AvoidMultipleUnaryOperators L1231 Using multiple unary operators may be a bug, and/or is confusing.
  • 🔴 pmd:SystemPrintln L1232 Usage of System.out/err
  • 🔴 pmd:BrokenNullCheck L1239 null 检查逻辑有误,可能导致 NullPointerException 或逻辑错误 建议: 检查短路语义:判空应使用 && 或 || 正确组合,并在空值分支避免解引用。
  • 🔴 pmd:BrokenNullCheck L1242 Dereferencing the qualifier of this expression will throw a NullPointerException
  • 🔴 pmd:ProperCloneImplementation L1254 clone() 应通过 super.clone() 实现 建议: 使用 super.clone() 并强制转换返回类型,而不是 new 新对象。
  • 🔴 pmd:ProperCloneImplementation L1286 Object clone() should be implemented with super.clone()
  • 🔴 pmd:FieldNamingConventions L1339 The field name 'LOG' doesn't match '[a-z][a-zA-Z0-9]*'
  • 🔴 pmd:FieldNamingConventions L1344 The constant name '_LOG' doesn't match '[A-Z][A-Z_0-9]*'
  • 🔴 pmd:ClassWithOnlyPrivateConstructorsShouldBeFinal L1372 This class has only private constructors and may be final
  • 🔴 pmd:FieldNamingConventions L1373 The static field name 'INSTANCE' doesn't match '[a-z][a-zA-Z0-9]*'
  • 🔴 pmd:ClassWithOnlyPrivateConstructorsShouldBeFinal L1384 This class has only private constructors and may be final
  • 🔴 pmd:FieldNamingConventions L1385 The static field name 'INSTANCE' doesn't match '[a-z][a-zA-Z0-9]*'
  • 🔴 pmd:SystemPrintln L1400 Usage of System.out/err
  • 🟡 pmd:AtLeastOneConstructor L30 每个类应至少声明一个构造函数(适用于所有命中项) 建议: 为没有构造函数的类添加显式构造函数;若类不应被实例化,则改为私有构造。
  • 🟡 pmd:AbstractClassWithoutAbstractMethod L30 该抽象类没有任何抽象方法 建议: 删除 abstract 关键字,或为类增加抽象方法。
  • 🟡 pmd:AtLeastOneConstructor L34 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L35 缺少默认访问修饰符的注释(方法/字段/类) 建议: 为包级私有成员添加 /* default */ 注释,或显式声明 private/protected/public。
  • 🟡 pmd:MethodArgumentCouldBeFinal L35 参数未被赋值,可以声明为 final(适用于所有命中项) 建议: 在方法参数前添加 final 修饰符,避免无意中重新赋值。
  • 🟡 pmd:MethodArgumentCouldBeFinal L35 Parameter 'b' is not assigned and could be declared final
  • 🟡 pmd:MethodArgumentCouldBeFinal L35 Parameter 'c' is not assigned and could be declared final
  • 🟡 pmd:CollapsibleIfStatements L37 该 if 语句可以与父级 if 合并 建议: 使用 && 或 || 将嵌套条件合并,减少嵌套层级。
  • 🟡 pmd:AvoidDeeplyNestedIfStmts L38 if 嵌套过深,难以阅读 建议: 使用卫语句、提前返回或提取方法降低嵌套深度。
  • 🟡 pmd:CollapsibleIfStatements L38 This if statement could be combined with its parent
  • 🟡 pmd:AtLeastOneConstructor L47 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L48 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:AvoidRethrowingException L51 捕获异常后仅重新抛出,应避免 建议: 不要捕获该异常,直接在方法签名中声明抛出;若必须捕获,请加入实际处理逻辑。
  • 🟡 pmd:CommentDefaultAccessModifier L55 Missing commented default access modifier on method 'doWork()'
  • 🟡 pmd:AtLeastOneConstructor L60 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L61 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:CommentDefaultAccessModifier L68 Missing commented default access modifier on method 'doWork()'
  • 🟡 pmd:AtLeastOneConstructor L73 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L74 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:AtLeastOneConstructor L80 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L81 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:AtLeastOneConstructor L87 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L88 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:AvoidUncheckedExceptionsInSignatures L88 方法/构造函数不应显式声明非受检异常 RuntimeException 建议: 从 throws 子句中删除非受检异常。
  • 🟡 pmd:MissingStaticMethodInNonInstantiatableClass L93 类无法实例化,且没有提供任何静态方法或字段 建议: 添加 public static 方法/工厂方法,或将类声明为 final 并仅作工具类使用。
  • 🟡 pmd:AtLeastOneConstructor L99 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L100 Missing commented default access modifier on method 'bad(int, int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L100 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:MethodArgumentCouldBeFinal L100 Parameter 'b' is not assigned and could be declared final
  • 🟡 pmd:CollapsibleIfStatements L102 This if statement could be combined with its parent
  • 🟡 pmd:AtLeastOneConstructor L110 Each class should declare at least one constructor
  • 🟡 pmd:DataClass L110 类疑似数据类(只包含 getter/setter) 建议: 将数据与行为封装在一起,增加业务方法,避免仅作为数据容器。
  • 🟡 pmd:PublicMemberInNonPublicType L113 非公共类型中声明了公共成员 建议: 将类改为 public,或将该成员的访问级别降为 package 私有。
  • 🟡 pmd:PublicMemberInNonPublicType L116 Public member 'setName' declared in a non-public type
  • 🟡 pmd:MethodArgumentCouldBeFinal L116 Parameter 'name' is not assigned and could be declared final
  • 🟡 pmd:PublicMemberInNonPublicType L119 Public member 'getAge' declared in a non-public type
  • 🟡 pmd:PublicMemberInNonPublicType L122 Public member 'setAge' declared in a non-public type
  • 🟡 pmd:MethodArgumentCouldBeFinal L122 Parameter 'age' is not assigned and could be declared final
  • 🟡 pmd:MissingSerialVersionUID L128 实现 Serializable 的类应定义 serialVersionUID 建议: 添加 private static final long serialVersionUID = 1L;
  • 🟡 pmd:AtLeastOneConstructor L128 Each class should declare at least one constructor
  • 🟡 pmd:DoNotExtendJavaLangError L128 异常不应继承 java.lang.Error 建议: 应继承 Exception/RuntimeExceptionError 留给 JVM 内部严重错误。
  • 🟡 pmd:AtLeastOneConstructor L132 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L133 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:UnusedAssignment L134 变量的初始值从未被使用 建议: 删除初始赋值,或直接使用最终需要的值初始化。
  • 🟡 pmd:CommentDefaultAccessModifier L142 Missing commented default access modifier on method 'check()'
  • 🟡 pmd:AtLeastOneConstructor L148 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L149 Missing commented default access modifier on field 'CONST'
  • 🟡 pmd:FinalFieldCouldBeStatic L149 final 字段可以声明为 static 建议: 若字段是编译时常量,请声明为 static final。
  • 🟡 pmd:AtLeastOneConstructor L153 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L154 Missing commented default access modifier on method 'm1(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L154 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L157 Missing commented default access modifier on method 'm2(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L157 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L160 Missing commented default access modifier on method 'm3(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L160 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L163 Missing commented default access modifier on method 'm4(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L163 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L166 Missing commented default access modifier on method 'm5(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L166 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L169 Missing commented default access modifier on method 'm6(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L169 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L172 Missing commented default access modifier on method 'm7(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L172 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L175 Missing commented default access modifier on method 'm8(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L175 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L178 Missing commented default access modifier on method 'm9(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L178 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L181 Missing commented default access modifier on method 'm10(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L181 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L184 Missing commented default access modifier on method 'm11(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L184 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L187 Missing commented default access modifier on method 'm12(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L187 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L190 Missing commented default access modifier on method 'm13(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L190 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L193 Missing commented default access modifier on method 'm14(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L193 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L196 Missing commented default access modifier on method 'm15(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L196 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L199 Missing commented default access modifier on method 'm16(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L199 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L202 Missing commented default access modifier on method 'm17(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L202 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L205 Missing commented default access modifier on method 'm18(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L205 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L208 Missing commented default access modifier on method 'm19(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L208 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L211 Missing commented default access modifier on method 'm20(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L211 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L214 Missing commented default access modifier on method 'm21(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L214 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L217 Missing commented default access modifier on method 'm22(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L217 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L220 Missing commented default access modifier on method 'm23(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L220 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L223 Missing commented default access modifier on method 'm24(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L223 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L226 Missing commented default access modifier on method 'm25(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L226 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L229 Missing commented default access modifier on method 'm26(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L229 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L232 Missing commented default access modifier on method 'm27(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L232 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L235 Missing commented default access modifier on method 'm28(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L235 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L238 Missing commented default access modifier on method 'm29(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L238 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L241 Missing commented default access modifier on method 'm30(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L241 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L244 Missing commented default access modifier on method 'm31(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L244 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L247 Missing commented default access modifier on method 'm32(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L247 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L250 Missing commented default access modifier on method 'm33(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L250 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L253 Missing commented default access modifier on method 'm34(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L253 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L256 Missing commented default access modifier on method 'm35(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L256 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L259 Missing commented default access modifier on method 'm36(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L259 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L262 Missing commented default access modifier on method 'm37(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L262 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L265 Missing commented default access modifier on method 'm38(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L265 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L268 Missing commented default access modifier on method 'm39(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L268 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L271 Missing commented default access modifier on method 'm40(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L271 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L274 Missing commented default access modifier on method 'm41(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L274 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L277 Missing commented default access modifier on method 'm42(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L277 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L280 Missing commented default access modifier on method 'm43(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L280 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L283 Missing commented default access modifier on method 'm44(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L283 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L286 Missing commented default access modifier on method 'm45(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L286 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L289 Missing commented default access modifier on method 'm46(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L289 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L292 Missing commented default access modifier on method 'm47(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L292 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L295 Missing commented default access modifier on method 'm48(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L295 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L298 Missing commented default access modifier on method 'm49(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L298 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:CommentDefaultAccessModifier L301 Missing commented default access modifier on method 'm50(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L301 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:UnusedPrivateField L308 存在未使用的私有字段 建议: 删除该字段,或确认其确实被需要后补充使用。
  • 🟡 pmd:ImmutableField L308 字段可以声明为 final 建议: 初始化后不再变更的字段应添加 final 修饰符。
  • 🟡 pmd:UnnecessaryConstructor L310 构造函数不必要,编译器会生成默认构造 建议: 删除空的、无实际逻辑的构造函数。
  • 🟡 pmd:CommentDefaultAccessModifier L310 Missing commented default access modifier on constructor 'Immut()'
  • 🟡 pmd:AtLeastOneConstructor L315 Each class should declare at least one constructor
  • 🟡 pmd:PublicMemberInNonPublicType L317 Public member 'getname' declared in a non-public type
  • 🟡 pmd:PublicMemberInNonPublicType L320 Public member 'setname' declared in a non-public type
  • 🟡 pmd:MethodArgumentCouldBeFinal L320 Parameter 'n' is not assigned and could be declared final
  • 🟡 pmd:AtLeastOneConstructor L326 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L327 Missing commented default access modifier on method 'bad(A)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L327 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:LawOfDemeter L328 Call to getB on foreign value a (degree 1)
  • 🟡 pmd:AtLeastOneConstructor L330 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L330 Missing commented default access modifier on nested class 'A'
  • 🟡 pmd:CommentDefaultAccessModifier L331 Missing commented default access modifier on method 'getB()'
  • 🟡 pmd:AtLeastOneConstructor L335 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L335 Missing commented default access modifier on nested class 'B'
  • 🟡 pmd:CommentDefaultAccessModifier L336 Missing commented default access modifier on method 'getC()'
  • 🟡 pmd:AtLeastOneConstructor L340 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L340 Missing commented default access modifier on nested class 'C'
  • 🟡 pmd:CommentDefaultAccessModifier L341 Missing commented default access modifier on method 'doIt()'
  • 🟡 pmd:AtLeastOneConstructor L347 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L348 Missing commented default access modifier on method 'bad(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L348 Parameter 'x' is not assigned and could be declared final
  • 🟡 pmd:SimplifyBooleanReturns L349 该 if 语句可被替换为返回条件表达式 建议: 例如 if (x) return true; else return false 应改为 return x;
  • 🟡 pmd:LogicInversion L349 Use opposite operator instead of the logic complement operator.
  • 🟡 pmd:OnlyOneReturn L350 方法应只有唯一出口,且应在最后一条语句 建议: 将多个 return 改为单出口风格,或使用表达式结果返回。
  • 🟡 pmd:UseUtilityClass L359 所有成员都是静态的,应添加私有构造防止实例化 建议: 为工具类添加 private 无参构造函数,并将类声明为 final。
  • 🟡 pmd:MutableStaticState L360 不要使用非 final 非私有的静态字段 建议: 改为 private static final,或通过 getter/setter 控制访问。
  • 🟡 pmd:CommentDefaultAccessModifier L360 Missing commented default access modifier on field 'counter'
  • 🟡 pmd:AtLeastOneConstructor L364 Each class should declare at least one constructor
  • 🟡 pmd:PublicMemberInNonPublicType L365 Public member 'x' declared in a non-public type
  • 🟡 pmd:AtLeastOneConstructor L369 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L370 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:SignatureDeclareThrowsException L370 方法/构造函数不应显式抛出 java.lang.Exception 建议: 抛出具体异常类型,避免宽泛的 Exception。
  • 🟡 pmd:AtLeastOneConstructor L375 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L376 Missing commented default access modifier on method 'bad(boolean)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L376 Parameter 'x' is not assigned and could be declared final
  • 🟡 pmd:SimplifiedTernary L377 三元表达式可以简化 建议: 例如 return x ? true : false 应改为 return x。
  • 🟡 pmd:AtLeastOneConstructor L382 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L383 Missing commented default access modifier on method 'bad(boolean)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L383 Parameter 'x' is not assigned and could be declared final
  • 🟡 pmd:SimplifyBooleanExpressions L384 布尔表达式包含不必要的比较 建议: 例如 return x == true 应改为 return x。
  • 🟡 pmd:AtLeastOneConstructor L389 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L390 Missing commented default access modifier on method 'bad(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L390 Parameter 'x' is not assigned and could be declared final
  • 🟡 pmd:SimplifyBooleanReturns L391 This if statement can be replaced by return {condition};
  • 🟡 pmd:OnlyOneReturn L392 A method should have only one exit point, and that should be the last statement in the method
  • 🟡 pmd:AtLeastOneConstructor L400 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L401 Missing commented default access modifier on method 'bar(Object)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L401 Parameter 'x' is not assigned and could be declared final
  • 🟡 pmd:EmptyControlStatement L402 存在空的控制语句(if/for/while 等) 建议: 补充逻辑或删除空语句块。
  • 🟡 pmd:SimplifyConditional L402 instanceof 前不需要检查 null 建议: 删除 x != null &&,因为 x instanceof List 已覆盖 null 情况。
  • 🟡 pmd:AtLeastOneConstructor L408 Each class should declare at least one constructor
  • 🟡 pmd:SingularField L409 字段可能应改为局部变量 建议: 如果字段只在一个方法中使用,请改为方法内局部变量。
  • 🟡 pmd:PublicMemberInNonPublicType L411 Public member 'foo' declared in a non-public type
  • 🟡 pmd:MethodArgumentCouldBeFinal L411 Parameter 'y' is not assigned and could be declared final
  • 🟡 pmd:AtLeastOneConstructor L418 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L419 Missing commented default access modifier on method 'bad(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L419 Parameter 'x' is not assigned and could be declared final
  • 🟡 pmd:SwitchDensity L420 switch 中语句与分支比例过高 建议: 将每个 case 的逻辑抽取为独立方法,或使用多态/映射表重构。
  • 🟡 pmd:AtLeastOneConstructor L471 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L472 Missing commented default access modifier on method 'm()'
  • 🟡 pmd:AtLeastOneConstructor L475 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L477 Missing commented default access modifier on method 'm()'
  • 🟡 pmd:UselessOverridingMethod L477 重写方法仅调用 super,无实际用途 建议: 删除该重写方法,让父类方法直接生效。
  • 🟡 pmd:UseUtilityClass L483 All members are static. Consider adding a private no-args constructor to prevent instantiation.
  • 🟡 pmd:CommentDefaultAccessModifier L484 Missing commented default access modifier on method 'helper()'
  • 🟡 pmd:AtLeastOneConstructor L491 Each class should declare at least one constructor
  • 🟡 pmd:PublicMemberInNonPublicType L492 Public member 'bar' declared in a non-public type
  • 🟡 pmd:MethodArgumentCouldBeFinal L492 Parameter 'x' is not assigned and could be declared final
  • 🟡 pmd:AtLeastOneConstructor L525 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L526 Missing commented default access modifier on method 'bar(Object, String)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L526 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:MethodArgumentCouldBeFinal L526 Parameter 'baz' is not assigned and could be declared final
  • 🟡 pmd:MisplacedNullCheck L527 null 检查位置错误,可能引发 NullPointerException 建议: 先判空再调用方法,例如 a != null && a.equals(baz)。
  • 🟡 pmd:AtLeastOneConstructor L536 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L537 Missing commented default access modifier on method 'bad(int)'
  • 🟡 pmd:AssignmentInOperand L538 避免在操作数中赋值 建议: 将赋值移到表达式外,单独一行,再参与判断。
  • 🟡 pmd:UseUtilityClass L545 All members are static. Consider adding a private no-args constructor to prevent instantiation.
  • 🟡 pmd:MutableStaticState L546 Do not use non-final non-private static fields
  • 🟡 pmd:CommentDefaultAccessModifier L546 Missing commented default access modifier on field 'counter'
  • 🟡 pmd:CommentDefaultAccessModifier L548 Missing commented default access modifier on constructor 'AssignStatic()'
  • 🟡 pmd:AssignmentToNonFinalStatic L549 构造函数中给非 final 静态字段赋值可能不安全 建议: 使用实例字段,或通过 static final/初始化块管理静态状态。
  • 🟡 pmd:AtLeastOneConstructor L554 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L555 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:SignatureDeclareThrowsException L555 A method/constructor should not explicitly throw java.lang.Exception
  • 🟡 pmd:LocalVariableCouldBeFinal L556 局部变量可声明为 final 建议: 为只赋值一次的局部变量添加 final 修饰符。
  • 🟡 pmd:AvoidAccessibilityAlteration L557 不应使用 setAccessible(true) 修改可见性 建议: 避免反射破坏封装;若必须,应评估安全风险并限制调用权限。
  • 🟡 pmd:AtLeastOneConstructor L562 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L563 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:LocalVariableCouldBeFinal L564 Local variable 'o' could be declared final
  • 🟡 pmd:AvoidCallingFinalize L565 避免显式调用 finalize() 方法 建议: 删除显式调用,改用 try-with-resources 或 Cleaner 管理资源。
  • 🟡 pmd:AtLeastOneConstructor L570 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L571 Missing commented default access modifier on field 'd'
  • 🟡 pmd:AvoidDecimalLiteralsInBigDecimalConstructor L571 避免用浮点字面量构造 BigDecimal,可能产生精度问题 建议: 使用字符串构造:new BigDecimal("0.1")。
  • 🟡 pmd:AtLeastOneConstructor L575 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L576 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:AtLeastOneConstructor L583 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L584 Missing commented default access modifier on method 'bad(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L584 Parameter 'x' is not assigned and could be declared final
  • 🟡 pmd:AvoidLiteralsInIfCondition L585 if 条件中避免使用魔术数字/字面量 建议: 将 42、5 等常量提取为命名常量。
  • 🟡 pmd:AtLeastOneConstructor L592 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L593 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:AssignmentInOperand L596 Avoid assignment to x in operand
  • 🟡 pmd:AtLeastOneConstructor L602 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L603 Missing commented default access modifier on field 'x'
  • 🟡 pmd:AvoidUsingOctalValues L603 避免使用八进制字面量 建议: 去掉前导 0,或明确使用 0x/0b 前缀。
  • 🟡 pmd:AtLeastOneConstructor L607 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L608 Missing commented default access modifier on method 'bad(Object, Object)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L608 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:MethodArgumentCouldBeFinal L608 Parameter 'b' is not assigned and could be declared final
  • 🟡 pmd:EmptyControlStatement L609 Empty if statement
  • 🟡 pmd:AtLeastOneConstructor L615 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L616 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:UselessPureMethodCall L618 调用了纯方法但未使用结果 建议: 删除该调用,或将结果赋给变量并使用。
  • 🟡 pmd:CommentDefaultAccessModifier L620 Missing commented default access modifier on method 'doSomething()'
  • 🟡 pmd:AtLeastOneConstructor L625 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L626 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:UselessPureMethodCall L627 Do not call pure method toString if the result is not used.
  • 🟡 pmd:CommentDefaultAccessModifier L630 Missing commented default access modifier on method 'doSomething()'
  • 🟡 pmd:AtLeastOneConstructor L635 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L636 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:CloseResource L637 资源使用后应关闭 建议: 使用 try-with-resources 自动关闭 InputStream 等资源。
  • 🟡 pmd:LocalVariableCouldBeFinal L637 Local variable 'in' could be declared final
  • 🟡 pmd:CheckSkipResult L638 应检查 InputStream.skip() 的返回值 建议: 将 skip 返回值赋给变量,并判断是否满足所需跳过字节数。
  • 🟡 pmd:AtLeastOneConstructor L643 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L644 Missing commented default access modifier on method 'bad(Collection)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L644 Parameter 'c' is not assigned and could be declared final
  • 🟡 pmd:UnusedLocalVariable L645 存在未使用的局部变量 建议: 删除未使用的局部变量,或补全其使用逻辑。
  • 🟡 pmd:ClassCastExceptionWithToArray L645 Collection.toArray() 的使用会抛出 ClassCastException 建议: 使用 c.toArray(new String[0]) 传入类型化数组。
  • 🟡 pmd:AtLeastOneConstructor L650 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L651 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:LocalVariableCouldBeFinal L652 Local variable 'in' could be declared final
  • 🟡 pmd:AtLeastOneConstructor L658 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L659 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:UnusedLocalVariable L660 Avoid unused local variables such as 'l'.
  • 🟡 pmd:UnusedLocalVariable L661 Avoid unused local variables such as 'o'.
  • 🟡 pmd:PrimitiveWrapperInstantiation L661 不要使用 new Integer(...),应使用 Integer.valueOf(...) 建议: 使用装箱缓存或 Integer.valueOf 替代 new Integer。
  • 🟡 pmd:UnnecessaryBoxing L661 存在不必要的显式装箱 建议: 直接使用基本类型或依赖自动装箱。
  • 🟡 pmd:AtLeastOneConstructor L666 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L667 Missing commented default access modifier on method 'bad(String, String)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L667 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:MethodArgumentCouldBeFinal L667 Parameter 'b' is not assigned and could be declared final
  • 🟡 pmd:EmptyControlStatement L668 Empty if statement
  • 🟡 pmd:CompareObjectsWithEquals L668 比较对象引用应使用 equals() 而不是 == 建议: 对非基本类型对象比较使用 equals()。
  • 🟡 pmd:UseEqualsToCompareStrings L668 比较字符串应使用 equals() 而不是 == 建议: 使用 a.equals(b),并按需调用 equalsIgnoreCase。
  • 🟡 pmd:AtLeastOneConstructor L674 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L675 Missing commented default access modifier on method 'bad(double)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L675 Parameter 'x' is not assigned and could be declared final
  • 🟡 pmd:EmptyControlStatement L676 Empty if statement
  • 🟡 pmd:ComparisonWithNaN L676 与 NaN 比较恒为 false 建议: 使用 Double.isNaN(x) 判断 NaN。
  • 🟡 pmd:AtLeastOneConstructor L682 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L683 Missing commented default access modifier on method 'call()'
  • 🟡 pmd:CommentDefaultAccessModifier L686 Missing commented default access modifier on method 'accept(String[])'
  • 🟡 pmd:CommentDefaultAccessModifier L692 Missing commented default access modifier on constructor 'CtorCall()'
  • 🟡 pmd:CommentDefaultAccessModifier L695 Missing commented default access modifier on method 'overridable()'
  • 🟡 pmd:AtLeastOneConstructor L700 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L701 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:MissingSerialVersionUID L707 Classes implementing Serializable should set a serialVersionUID
  • 🟡 pmd:AtLeastOneConstructor L707 Each class should declare at least one constructor
  • 🟡 pmd:DoNotExtendJavaLangThrowable L707 异常不应直接继承 java.lang.Throwable 建议: 应继承 Exception 或 RuntimeException。
  • 🟡 pmd:AtLeastOneConstructor L711 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L712 Missing commented default access modifier on field 'path'
  • 🟡 pmd:DoNotHardCodeSDCard L712 不要硬编码 /sdcard 路径 建议: 使用环境变量或上下文 API 获取存储路径。
  • 🟡 pmd:AtLeastOneConstructor L716 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L717 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:DoNotTerminateVM L718 不应调用 System.exit() 终止 JVM 建议: 通过受控方式结束应用,或抛出异常交给上层处理。
  • 🟡 pmd:AtLeastOneConstructor L723 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L724 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:CommentDefaultAccessModifier L731 Missing commented default access modifier on method 'doWork()'
  • 🟡 pmd:AtLeastOneConstructor L736 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L737 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:DontUseFloatTypeForLoopIndices L738 不要使用浮点类型作为循环索引,浮点精度可能导致循环异常 建议: 改用 int/long 循环变量,或使用 double 并明确终止条件。
  • 🟡 pmd:EmptyControlStatement L738 Empty for statement
  • 🟡 pmd:AtLeastOneConstructor L744 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L745 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:EmptyCatchBlock L748 避免空 catch 块 建议: 至少记录日志或做降级处理,不要静默吞掉异常。
  • 🟡 pmd:AvoidCatchingGenericException L748 避免捕获泛化 Exception 建议: 捕获具体异常类型,如 IOException、IllegalArgumentException。
  • 🟡 pmd:CommentDefaultAccessModifier L751 Missing commented default access modifier on method 'doWork()'
  • 🟡 pmd:AtLeastOneConstructor L756 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L757 Missing commented default access modifier on method 'bad(Object)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L757 Parameter 'o' is not assigned and could be declared final
  • 🟡 pmd:EmptyControlStatement L758 Empty if statement
  • 🟡 pmd:AtLeastOneConstructor L764 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L765 Missing commented default access modifier on method 'bad(String)'
  • 🟡 pmd:AtLeastOneConstructor L773 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L774 Missing commented default access modifier on method 'bad(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L774 Parameter 'x' is not assigned and could be declared final
  • 🟡 pmd:IdenticalConditionalBranches L775 条件分支完全相同,条件判断无意义 建议: 删除 if/else,直接返回相同结果或提取公共逻辑。
  • 🟡 pmd:OnlyOneReturn L776 A method should have only one exit point, and that should be the last statement in the method
  • 🟡 pmd:AtLeastOneConstructor L784 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L785 Missing commented default access modifier on method 'bad(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L785 Parameter 'x' is not assigned and could be declared final
  • 🟡 pmd:ImplicitSwitchFallThrough L789 switch 分支存在隐式 fall-through 建议: 在 case 末尾补上 break/return,或添加注释明确故意 fall-through。
  • 🟡 pmd:AtLeastOneConstructor L799 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L800 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:UnusedLocalVariable L801 Avoid unused local variables such as 'c'.
  • 🟡 pmd:PrimitiveWrapperInstantiation L801 Do not use new Integer(...), prefer Integer.valueOf(...)
  • 🟡 pmd:AtLeastOneConstructor L806 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L807 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:ForLoopVariableCount L808 for 循环中控制变量过多 建议: 拆分循环或将额外变量移到循环外,保持循环头简洁。
  • 🟡 pmd:AvoidReassigningLoopVariables L809 避免修改循环控制变量 建议: 不要在循环体内或内层循环更新外层循环变量,使用独立变量。
  • 🟡 pmd:AtLeastOneConstructor L815 Each class should declare at least one constructor
  • 🟡 pmd:MethodWithSameNameAsEnclosingClass L816 方法与包含它的类同名(可能误当构造函数) 建议: 重命名方法,避免与类名混淆。
  • 🟡 pmd:CommentDefaultAccessModifier L816 Missing commented default access modifier on method 'SameName()'
  • 🟡 pmd:AtLeastOneConstructor L821 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L822 Missing commented default access modifier on method 'bad(String)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L822 Parameter 's' is not assigned and could be declared final
  • 🟡 pmd:EmptyControlStatement L823 Empty if statement
  • 🟡 pmd:MissingStaticMethodInNonInstantiatableClass L829 Class cannot be instantiated and does not provide any static methods or fields
  • 🟡 pmd:UnusedPrivateField L836 Avoid unused private fields such as 'LOG1'.
  • 🟡 pmd:UnusedPrivateField L837 Avoid unused private fields such as 'LOG2'.
  • 🟡 pmd:AtLeastOneConstructor L841 Each class should declare at least one constructor
  • 🟡 pmd:NonStaticInitializer L842 非静态初始化器令人困惑 建议: 将初始化逻辑移到构造函数或工厂方法中。
  • 🟡 pmd:AtLeastOneConstructor L848 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L849 Missing commented default access modifier on field 's'
  • 🟡 pmd:CommentDefaultAccessModifier L850 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:NullAssignment L851 将对象赋值为 null 是代码坏味道 建议: 用 Optional 或空集合/空对象模式替代 null 赋值。
  • 🟡 pmd:AtLeastOneConstructor L856 Each class should declare at least one constructor
  • 🟡 pmd:OverrideBothEqualsAndHashcode L857 重写 equals() 时应同时重写 hashCode() 建议: 为相等的对象保证 hashCode 一致,避免集合类行为异常。
  • 🟡 pmd:MissingOverride L857 重写方法缺少 @Override 注解 建议: 在继承或实现的方法上添加 @Override 注解。
  • 🟡 pmd:AtLeastOneConstructor L863 Each class should declare at least one constructor
  • 🟡 pmd:MissingOverride L864 The method 'compareTo(CmpOnly)' is missing an @Override annotation.
  • 🟡 pmd:OverrideBothEqualsAndHashCodeOnComparable L864 实现 Comparable 时应同时重写 equals() 和 hashCode() 建议: 保持 compareTo、equals、hashCode 三者语义一致。
  • 🟡 pmd:AtLeastOneConstructor L870 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L871 Missing commented default access modifier on field 'c'
  • 🟡 pmd:ReplaceJavaUtilCalendar L871 应使用 java.time 替代 java.util.Calendar 建议: 使用 LocalDate/LocalDateTime/ZonedDateTime 等新时间 API。
  • 🟡 pmd:AtLeastOneConstructor L875 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L876 Missing commented default access modifier on field 'd'
  • 🟡 pmd:ReplaceJavaUtilDate L876 应使用 java.time 替代 java.util.Date 建议: 使用 Instant/LocalDateTime 并配合 DateTimeFormatter 处理格式。
  • 🟡 pmd:ReplaceJavaUtilDate L876 Usage of java.util.Date should be replaced with classes from java.time
  • 🟡 pmd:AtLeastOneConstructor L880 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L881 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:AtLeastOneConstructor L887 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L888 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:OnlyOneReturn L890 A method should have only one exit point, and that should be the last statement in the method
  • 🟡 pmd:ReturnFromFinallyBlock L892 避免在 finally 块中返回值 建议: 从 try/catch 中返回结果,finally 只做资源清理。
  • 🟡 pmd:AtLeastOneConstructor L898 Each class should declare at least one constructor
  • 🟡 pmd:AvoidFieldNameMatchingTypeName L899 字段名与类名相同容易混淆 建议: 重命名字段,例如 sdf 改为 dateFormat。
  • 🟡 pmd:CommentDefaultAccessModifier L899 Missing commented default access modifier on field 'sdf'
  • 🟡 pmd:SimpleDateFormatNeedsLocale L899 SimpleDateFormat 实例化时应指定 Locale 建议: new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT)。
  • 🟡 pmd:AtLeastOneConstructor L903 Each class should declare at least one constructor
  • 🟡 pmd:AvoidStringBufferField L904 StringBuffer 字段可能造成内存问题 建议: 优先使用 StringBuilder,并避免在长生命周期对象中持有大缓冲区。
  • 🟡 pmd:CommentDefaultAccessModifier L904 Missing commented default access modifier on field 'sb'
  • 🟡 pmd:AtLeastOneConstructor L908 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L909 Missing commented default access modifier on method 'equals(String)'
  • 🟡 pmd:AtLeastOneConstructor L914 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L915 Missing commented default access modifier on method 'hashcode()'
  • 🟡 pmd:AtLeastOneConstructor L920 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L921 Missing commented default access modifier on field 's'
  • 🟡 pmd:AtLeastOneConstructor L925 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L926 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:UnconditionalIfStatement L927 不要使用恒真/恒假的 if 语句 建议: 删除无条件 if,直接执行其中的代码或删除整个语句块。
  • 🟡 pmd:AtLeastOneConstructor L934 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L935 Missing commented default access modifier on method 'bad(String)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L935 Parameter 's' is not assigned and could be declared final
  • 🟡 pmd:EmptyControlStatement L936 Empty if statement
  • 🟡 pmd:AtLeastOneConstructor L942 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L943 Missing commented default access modifier on method 'bad(int)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L943 Parameter 'x' is not assigned and could be declared final
  • 🟡 pmd:UnusedLocalVariable L944 Avoid unused local variables such as 's'.
  • 🟡 pmd:UnnecessaryConversionTemporary L944 避免不必要的临时转换对象 建议: 使用 String.valueOf(x) 替代 new Integer(x).toString()。
  • 🟡 pmd:PrimitiveWrapperInstantiation L944 Do not use new Integer(...), prefer Integer.valueOf(...)
  • 🟡 pmd:AtLeastOneConstructor L949 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L950 Missing commented default access modifier on field 's'
  • 🟡 pmd:OverrideBothEqualsAndHashcode L951 Ensure you override both equals() and hashCode()
  • 🟡 pmd:MissingOverride L951 The method 'equals(Object)' is missing an @Override annotation.
  • 🟡 pmd:MethodArgumentCouldBeFinal L951 Parameter 'o' is not assigned and could be declared final
  • 🟡 pmd:EmptyControlStatement L952 Empty if statement
  • 🟡 pmd:AtLeastOneConstructor L959 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L960 Missing commented default access modifier on method 'bad(String, String)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L960 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:MethodArgumentCouldBeFinal L960 Parameter 'b' is not assigned and could be declared final
  • 🟡 pmd:CompareObjectsWithEquals L961 Use equals() to compare object references.
  • 🟡 pmd:UseEqualsToCompareStrings L961 Use equals() to compare strings instead of '==' or '!='
  • 🟡 pmd:AtLeastOneConstructor L966 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L967 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:UselessPureMethodCall L968 Do not call pure method length if the result is not used.
  • 🟡 pmd:AtLeastOneConstructor L973 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L974 Missing commented default access modifier on method 'bad(String)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L974 Parameter 's' is not assigned and could be declared final
  • 🟡 pmd:UselessPureMethodCall L975 Do not call pure method toUpperCase if the result is not used.
  • 🟡 pmd:UseLocaleWithCaseConversions L975 toUpperCase()/toLowerCase() 应指定 Locale 建议: 使用 s.toUpperCase(Locale.ROOT) 或指定业务 locale。
  • 🟡 pmd:AtLeastOneConstructor L980 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L981 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:UnusedLocalVariable L982 Avoid unused local variables such as 'cl'.
  • 🟡 pmd:UseProperClassLoader L982 getClassLoader() 在 J2EE 中可能不符合预期 建议: 使用 Thread.currentThread().getContextClassLoader()。
  • 🟡 pmd:AtLeastOneConstructor L987 Each class should declare at least one constructor
  • 🟡 pmd:AvoidFieldNameMatchingMethodName L988 字段名与同名方法容易混淆 建议: 重命名字段或方法,避免同名歧义。
  • 🟡 pmd:CommentDefaultAccessModifier L988 Missing commented default access modifier on field 'value'
  • 🟡 pmd:CommentDefaultAccessModifier L990 Missing commented default access modifier on method 'value()'
  • 🟡 pmd:AtLeastOneConstructor L995 Each class should declare at least one constructor
  • 🟡 pmd:AvoidFieldNameMatchingTypeName L996 It is somewhat confusing to have a field name matching the declaring class name
  • 🟡 pmd:CommentDefaultAccessModifier L996 Missing commented default access modifier on field 'TypeName'
  • 🟡 pmd:AtLeastOneConstructor L1000 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1001 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:AvoidCatchingGenericException L1004 Avoid catching Exception in try-catch block
  • 🟡 pmd:EmptyControlStatement L1005 Empty if statement
  • 🟡 pmd:AvoidInstanceofChecksInCatchClause L1005 catch 块中不应使用 instanceof 判断异常类型 建议: 为每种异常类型增加独立的 catch 子句。
  • 🟡 pmd:CommentDefaultAccessModifier L1009 Missing commented default access modifier on method 'doWork()'
  • 🟡 pmd:AtLeastOneConstructor L1014 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1015 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:LocalVariableCouldBeFinal L1016 Local variable 'x' could be declared final
  • 🟡 pmd:TooFewBranchesForSwitch L1017 switch 分支少于三个,使用 if 更高效 建议: 将 switch 改为 if/else if 判断。
  • 🟡 pmd:NonExhaustiveSwitch L1017 switch 不完整,应包含 default 或所有枚举分支 建议: 补充 default 分支处理未知情况。
  • 🟡 pmd:NonCaseLabelInSwitch L1020 switch 中出现了非 case 标签 建议: 移除标签,或重构 switch 逻辑。
  • 🟡 pmd:UnusedLabel L1020 存在未使用的标签 建议: 删除未引用标签,避免误导。
  • 🟡 pmd:PublicMemberInNonPublicType L1035 Public member 'getInstance' declared in a non-public type
  • 🟡 pmd:PublicMemberInNonPublicType L1039 Public member 'getInstance' declared in a non-public type
  • 🟡 pmd:MethodArgumentCouldBeFinal L1039 Parameter 'obj' is not assigned and could be declared final
  • 🟡 pmd:VariableCanBeInlined L1040 局部变量可以内联,不需要额外存储 建议: 直接返回值或表达式,减少中间变量。
  • 🟡 pmd:LocalVariableCouldBeFinal L1040 Local variable 's' could be declared final
  • 🟡 pmd:SignatureDeclareThrowsException L1047 A method/constructor should not explicitly throw java.lang.Exception
  • 🟡 pmd:UnsupportedJdkApiUsage L1048 使用了不受支持的 JDK API(如 sun.misc.Unsafe 建议: 改用标准 JDK API,例如 VarHandle/Atomic 类或通过受支持方式获取 Unsafe。
  • 🟡 pmd:AtLeastOneConstructor L1053 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1054 Missing commented default access modifier on method 'bar()'
  • 🟡 pmd:IdempotentOperations L1056 存在幂等操作(如变量赋值给自身/重复转换) 建议: 删除重复或自我赋值,保留一次有效操作。
  • 🟡 pmd:UnusedAssignment L1056 The value assigned to variable 'x' is never used
  • 🟡 pmd:AtLeastOneConstructor L1061 Each class should declare at least one constructor
  • 🟡 pmd:PublicMemberInNonPublicType L1062 Public member 'hashcode' declared in a non-public type
  • 🟡 pmd:SuspiciousHashcodeMethodName L1062 方法名与 hashCode() 高度相似,但签名不符 建议: 重命名为 hashcode -> hashCode,并返回 int 且加上 @Override。
  • 🟡 pmd:AtLeastOneConstructor L1068 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1069 Missing commented default access modifier on method 'foo()'
  • 🟡 pmd:SuspiciousOctalEscape L1070 字符串中的八进制转义后紧跟数字字符很可疑 建议: 将转义拆分或改用 Unicode 转义,避免歧义。
  • 🟡 pmd:AtLeastOneConstructor L1075 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1076 Missing commented default access modifier on method 'bad(String)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L1076 Parameter 'buz' is not assigned and could be declared final
  • 🟡 pmd:LocalVariableCouldBeFinal L1077 Local variable 'answer' could be declared final
  • 🟡 pmd:LiteralsFirstInComparisons L1077 字符串比较时应将字面量放在前面 建议: 使用 "BAZ".equals(buz) 避免 NPE。
  • 🟡 pmd:UnnecessaryCaseChange L1077 使用 toUpperCase/toLowerCase().equals() 不如 equalsIgnoreCase 清晰 建议: 改为 s1.equalsIgnoreCase(s2)。
  • 🟡 pmd:UseLocaleWithCaseConversions L1077 When doing a String.toLowerCase()/toUpperCase() call, use a Locale
  • 🟡 pmd:AtLeastOneConstructor L1083 Each class should declare at least one constructor
  • 🟡 pmd:PublicMemberInNonPublicType L1084 Public member 'method1' declared in a non-public type
  • 🟡 pmd:PublicMemberInNonPublicType L1087 Public member 'method' declared in a non-public type
  • 🟡 pmd:MethodArgumentCouldBeFinal L1087 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:UnusedNullCheckInEquals L1088 equals() 中的 null 检查未被使用或位置不当 建议: 直接调用非空对象.equals(),或先用 Objects.equals() 统一判空。
  • 🟡 pmd:AtLeastOneConstructor L1095 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1097 Missing commented default access modifier on method 'bar()'
  • 🟡 pmd:AvoidCatchingGenericException L1100 Avoid catching Exception in try-catch block
  • 🟡 pmd:CommentDefaultAccessModifier L1104 Missing commented default access modifier on method 'doWork()'
  • 🟡 pmd:AtLeastOneConstructor L1109 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1111 Missing commented default access modifier on method 'bar()'
  • 🟡 pmd:AtLeastOneConstructor L1118 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1119 Missing commented default access modifier on method 'bar()'
  • 🟡 pmd:AvoidDuplicateLiterals L1120 字符串字面量重复出现多次 建议: 提取为常量,避免重复字符串字面量。
  • 🟡 pmd:CommentDefaultAccessModifier L1125 Missing commented default access modifier on method 'buz(String)'
  • 🟡 pmd:AtLeastOneConstructor L1130 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1131 Missing commented default access modifier on method 'foo()'
  • 🟡 pmd:JumbledIncrementer L1133 内层循环修改了外层循环的递增变量,循环逻辑混乱 建议: 确保内层循环更新自己的控制变量,不要更新外层循环变量。
  • 🟡 pmd:LocalVariableCouldBeFinal L1133 Local variable 'k' could be declared final
  • 🟡 pmd:AvoidReassigningLoopVariables L1133 Avoid reassigning the loop control variable 'i'
  • 🟡 pmd:AtLeastOneConstructor L1141 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1142 Missing commented default access modifier on method 'foo()'
  • 🟡 pmd:AvoidLiteralsInIfCondition L1144 Avoid using literals such as 5 in if statements
  • 🟡 pmd:AtLeastOneConstructor L1152 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1153 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:LocalVariableCouldBeFinal L1154 Local variable 'numbers' could be declared final
  • 🟡 pmd:CollectionTypeMismatch L1155 集合操作使用了与泛型类型不匹配的对象 建议: 确保存入/取出/删除的元素类型与泛型一致,例如用 Integer 而不是 String。
  • 🟡 pmd:UseConcurrentHashMap L1156 并发访问场景应使用 ConcurrentHashMap 建议: 将 HashMap 改为 ConcurrentHashMap,或同步访问。
  • 🟡 pmd:LocalVariableCouldBeFinal L1156 Local variable 'map' could be declared final
  • 🟡 pmd:UselessPureMethodCall L1157 Do not call pure method get if the result is not used.
  • 🟡 pmd:CollectionTypeMismatch L1157 Object of type 'int' cannot be in collection expecting 'java.lang.String'
  • 🟡 pmd:LocalVariableCouldBeFinal L1158 Local variable 'names' could be declared final
  • 🟡 pmd:UselessPureMethodCall L1159 Do not call pure method contains if the result is not used.
  • 🟡 pmd:CollectionTypeMismatch L1159 Object of type 'int' cannot be in collection expecting 'java.lang.String'
  • 🟡 pmd:AtLeastOneConstructor L1164 Each class should declare at least one constructor
  • 🟡 pmd:AtLeastOneConstructor L1165 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1165 Missing commented default access modifier on nested class 'C'
  • 🟡 pmd:CommentDefaultAccessModifier L1166 Missing commented default access modifier on method 'varargs(Object[])'
  • 🟡 pmd:CommentDefaultAccessModifier L1167 Missing commented default access modifier on method 'call()'
  • 🟡 pmd:ConfusingArgumentToVarargsMethod L1168 可变参数调用意图不清晰 建议: 显式转换为 Object 或 Object[],或直接展开参数,避免歧义。
  • 🟡 pmd:ConfusingArgumentToVarargsMethod L1169 Unclear if a varargs or non-varargs call is intended. Cast to Object or Object[] to clarify intent.
  • 🟡 pmd:AtLeastOneConstructor L1175 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1176 Missing commented default access modifier on method 'bar(Object, String)'
  • 🟡 pmd:MethodArgumentCouldBeFinal L1176 Parameter 'a' is not assigned and could be declared final
  • 🟡 pmd:MethodArgumentCouldBeFinal L1176 Parameter 'baz' is not assigned and could be declared final
  • 🟡 pmd:AtLeastOneConstructor L1184 Each class should declare at least one constructor
  • 🟡 pmd:UnusedPrivateField L1186 Avoid unused private fields such as 'stream'.
  • 🟡 pmd:NonSerializableClass L1186 可序列化类包含不可序列化的字段 建议: 将该字段标记为 transient,或改为可序列化类型。
  • 🟡 pmd:AtLeastOneConstructor L1190 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1191 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:CommentDefaultAccessModifier L1198 Missing commented default access modifier on method 'doWork()'
  • 🟡 pmd:AtLeastOneConstructor L1204 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1205 Missing commented default access modifier on method 'bad()'
  • 🟡 pmd:AtLeastOneConstructor L1215 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1216 Missing commented default access modifier on method 'foo()'
  • 🟡 pmd:AvoidLiteralsInIfCondition L1219 Avoid using literals such as 25 in if statements
  • 🟡 pmd:AtLeastOneConstructor L1228 Each class should declare at least one constructor
  • 🟡 pmd:CommentDefaultAccessModifier L1229 Missing commented default access modifier on method 'foo()'
  • 🟡 pmd:LocalVariableCouldBeFinal L1230 Local variable 'i' could be declared final
  • 🟡 pmd:LocalVariableCouldBeFinal L1231 Local variable 'b' could be declared final
  • 🟡 pmd:AtLeastOneConstructor L1237 Each class should declare at least one constructor
  • 🟡 pmd:PublicMemberInNonPublicType L1238 Public member 'bar' declared in a non-public type
  • 🟡 pmd:MethodArgumentCouldBeFinal L1238 Parameter 'string' is not assigned and could be declared final
  • 🟡 pmd:LiteralsFirstInComparisons L1239 Position literals first in String comparisons
  • 🟡 pmd:OnlyOneReturn L1240 A method should have only one exit point, and that should be the last statement in the method
  • 🟡 pmd:LiteralsFirstInComparisons L1242 Position literals first in String comparisons
  • 🟡 pmd:OnlyOneReturn L1243 A method should have only one exit point, and that should be the last statement in the method
  • 🟡 pmd:AtLeastOneConstructor L1252 Each class should declare at least one constructor
  • 🟡 pmd:PublicMemberInNonPublicType L1254 Public member 'clone' declared in a non-public type
  • 🟡 pmd:CloneMethodReturnTypeMustMatchClassName L1254 clone() 返回类型必须与类名一致 建议: 将 clone() 返回类型改为当前类名。
  • 🟡 pmd:CloneMethodMustImplementCloneable L1254 只有实现 Cloneable 接口才应实现 clone() 方法 建议: 要么移除 clone() 方法,要么让类实现 Cloneable。
  • 🟡 pmd:AtLeastOneConstructor L1260 Each class should declare at least one constructor
  • 🟡 pmd:CloneMethodReturnTypeMustMatchClassName L1262 The return type of the clone() method must be the class name when implements Cloneable
  • 🟡 pmd:CloneMethodMustBePublic L1262 实现 Cloneable 时 clone() 方法必须为 public 建议: 将 protected clone() 改为 public CloneableType clone()。
  • 🟡 pmd:OnlyOneReturn L1264 A method should have only one exit point, and that should be the last statement in the method
  • 🟡 pmd:AtLeastOneConstructor L1272 Each class should declare at least one constructor
  • 🟡 pmd:PublicMemberInNonPublicType L1274 Public member 'clone' declared in a non-public type
  • 🟡 pmd:CloneMethodReturnTypeMustMatchClassName L1274 The return type of the clone() method must be the class name when implements Cloneable
  • 🟡 pmd:OnlyOneReturn L1276 A method should have only one exit point, and that should be the last statement in the method
  • 🟡 pmd:AtLeastOneConstructor L1284 Each class should declare at least one constructor
  • 🟡 pmd:PublicMemberInNonPublicType L1286 Public member 'clone' declared in a non-public type
  • 🟡 pmd:CloneMethodReturnTypeMustMatchClassName L1286 The return type of the clone() method must be the class name when implements Cloneable
  • 🟡 pmd:AtLeastOneConstructor L1294 Each class should declare at least one constructor
  • 🟡 pmd:EmptyFinalizer L1296 finalize() 方法为空,没有实际作用 建议: 删除空 finalize 方法,或使用 Cleaner 清理资源。
  • 🟡 pmd:AtLeastOneConstructor L1301 Each class should declare at least one constructor
  • 🟡 pmd:FinalizeDoesNotCallSuperFinalize L1304 finalize() 方法应最后调用 super.finalize() 建议: 在 finalize() 末尾添加 super.finalize()。
  • 🟡 pmd:CommentDefaultAccessModifier L1306 Missing commented default access modifier on method 'cleanup()'
  • 🟡 pmd:AtLeastOneConstructor L1311 Each class should declare at least one constructor
  • 🟡 pmd:FinalizeOnlyCallsSuperFinalize L1313 finalize() 只调用 super.finalize(),没有实际清理逻辑 建议: 删除无意义的 finalize,或在其中加入真正的资源清理逻辑。
  • 🟡 pmd:AtLeastOneConstructor L1319 Each class should declare at least one constructor
  • 🟡 pmd:FinalizeOnlyCallsSuperFinalize L1320 Finalize should do something besides just calling super.finalize()
  • 🟡 pmd:MissingOverride L1320 The method 'finalize()' is missing an @Override annotation.
  • 🟡 pmd:FinalizeOverloaded L1323 finalize 方法不应被重载 建议: 删除重载的 finalize(int) 方法。
  • 🟡 pmd:AtLeastOneConstructor L1328 Each class should declare at least one constructor
  • 🟡 pmd:FinalizeOnlyCallsSuperFinalize L1330 Finalize should do something besides just calling super.finalize()
  • 🟡 pmd:FinalizeShouldBeProtected L1330 finalize() 应声明为 protected 建议: 将 public finalize() 改为 protected finalize()。
  • 🟡 pmd:PublicMemberInNonPublicType L1330 Public member 'finalize' declared in a non-public type
  • 🟡 pmd:AtLeastOneConstructor L1338 Each class should declare at least one constructor
  • 🟡 pmd:ProperLogger L1339 logger 应定义为 private static final,并持有正确的类 建议: 改为 private static final Logger LOG = LoggerFactory.getLogger(Class.class);
  • 🟡 pmd:AtLeastOneConstructor L1343 Each class should declare at least one constructor
  • 🟡 pmd:ProperLogger L1344 Logger should be defined private static final and have the correct class
  • 🟡 pmd:CommentDefaultAccessModifier L1345 Missing commented default access modifier on method 'bar()'
  • 🟡 pmd:AvoidCatchingGenericException L1348 Avoid catching Exception in try-catch block
  • 🟡 pmd:CommentDefaultAccessModifier L1352 Missing commented default access modifier on method 'doWork()'
  • 🟡 pmd:MissingSerialVersionUID L1359 Classes implementing Serializable should set a serialVersionUID
  • 🟡 pmd:AtLeastOneConstructor L1359 Each class should declare at least one constructor
  • 🟡 pmd:UnusedPrivateField L1360 Avoid unused private fields such as 'value'.
  • 🟡 pmd:AtLeastOneConstructor L1364 Each class should declare at least one constructor
  • 🟡 pmd:UnusedPrivateField L1366 Avoid unused private fields such as 'nonSerializableField'.
  • 🟡 pmd:ImmutableField L1366 Field 'nonSerializableField' may be declared final
  • 🟡 pmd:PublicMemberInNonPublicType L1378 Public member 'getInstance' declared in a non-public type
  • 🟡 pmd:PublicMemberInNonPublicType L1390 Public member 'getInstance' declared in a non-public type
  • 🟡 pmd:NonThreadSafeSingleton L1391 单例实现不是线程安全的 建议: 使用 enum 单例、静态持有者(holder)或双重检查加 volatile。
  • 🔵 pmd:UnnecessaryFullyQualifiedName L402 不必要使用全限定名 建议: 使用已导入的简单类名代替全限定名。
  • 🔵 pmd:DoNotThrowExceptionInFinally L727 在 finally 块中抛出异常会使控制流难以理解 建议: 不要在 finally 中抛出异常,先记录或吞掉 finally 中的异常。
  • 🔵 pmd:InstantiationToGetClass L801 不要仅为获取 Class 对象而实例化 建议: 使用 Integer.class 而不是 new Integer(1).getClass()。
  • 🔵 pmd:StringBufferInstantiationWithChar L904 new StringBuffer(char) 会把 char 隐式转为 int 容量 建议: 使用 new StringBuffer() 或 new StringBuffer("c") 明确意图。
  • 🔵 pmd:InvalidLogMessageFormat L1112 日志消息格式参数数量不匹配 建议: 修正占位符数量:一个 {} 对应一个参数。
  • 🔵 pmd:InvalidLogMessageFormat L1113 Too many arguments, expected 1 argument but found 2
  • 🔵 pmd:UnnecessaryFullyQualifiedName L1184 Unnecessary qualifier 'java.io': 'Serializable' is already in scope because it is imported in this file

AI 审查 · 9 条建议

  • 🔴 [AI] [bug] rethrow-missing-throws L48 捕获 IOException 后重新抛出但方法未声明 throws IOException,编译失败 ReThrow.bad() 中 catch (IOException e) 后直接 throw e,但 bad() 没有 throws IOException,无法编译。 建议: 在方法签名上增加 throws IOException,或者更简单:不要捕获该异常,直接让 doWork() 的异常向外传播。
  • 🔴 [AI] [bug] wrap-same-missing-throws L61 包装 IOException 抛出但方法未声明 throws IOException,编译失败 WrapSame.bad() 中 catch 后 throw new IOException(...),但 bad() 未声明 throws IOException,代码无法编译。 建议: 为 bad() 增加 throws IOException,或捕获后改为抛出一个非受检异常。
  • 🔴 [AI] [bug] finalize-protected-inaccessible L565 显式调用 Object.finalize() 违反访问控制,无法编译 CallFinalize.bad() 中通过 Object 引用调用 o.finalize(),但 Object.finalize() 是 protected 方法,不在同包且不是通过子类引用访问,编译不通过。 建议: 删除该调用;如果需要清理资源,使用 AutoCloseable/Cleaner。
  • 🔴 [AI] [bug] null-inputstream-skip-npe L637 InputStream 初始化为 null 后直接调用 skip(),必现 NPE CheckSkip.bad() 中 InputStream in = null,随后调用 in.skip(10),运行时必然抛出 NullPointerException。 建议: 初始化真实流,并用 try-with-resources 管理生命周期,同时检查 skip 返回值。
  • 🔴 [AI] [performance] infinite-loop-inner-increment L1133 内层循环误递增外层变量 i,且 k 永不变,导致无限循环 JumbledInc.foo() 的内层循环 for (int k = 0; k < 20; i++) 更新的是 i 而不是 k,k 恒为 0,内层循环永不退出,程序将挂起。 建议: 内层循环应递增自己的控制变量 k。
  • 🟡 [AI] [design] bean-getter-setter-naming L317 getter/setter 未遵循 JavaBean 命名规范,影响框架绑定 BadBean 中 getname/setname 不符合 JavaBean 规范,应为 getName/setName,否则很多序列化/绑定框架无法识别。 建议: 将 getter 改为 getName()setter 改为 setName(String name)。
  • 🟡 [AI] [security] singleton-cast-classcastexception L1039 重载 getInstance(Object) 中无类型检查直接强转,会抛 ClassCastException SingletonDemo.getInstance(Object obj) 直接 (SingletonDemo) obj,传入非 SingletonDemo 对象时抛出 ClassCastException,且该重载破坏了单例语义。 建议: 删除该重载方法;如果确需接收对象,应先 instanceof 校验后再处理。
  • 🟡 [AI] [bug] log-exception-as-string L1101 日志只输出异常的 toString,丢失堆栈信息 CorrectLog.bar() 中 _LOG.error(String.valueOf(e)) 只记录异常字符串,无法看到堆栈;应把异常对象作为最后一个参数传给日志 API。 建议: 使用 _LOG.error("doWork failed", e),保留异常堆栈。
  • 🟡 [AI] [bug] loop-break-on-first-iteration L1222 循环第一次迭代就 break,后续逻辑成为死代码 BranchLastInLoop.foo() 中 if (i > 25) 永远不成立(i 最大为 9),而循环体末尾的 break 无条件执行,导致循环只执行一次。 建议: 检查循环终止条件,删除多余的 break,或把 break 放入有意义的条件判断中。