83 KiB
83 KiB
代码审查报告
文件: data\demo-pmd\src\com\demo\designep\DesignErrorProne.java
语言: java
耗时: 195.1s
分析工具: pmd
总计: 771 | 错误: 166 | 警告: 598 | 建议: 7
静态分析 · 762 个问题
- 🔴
pmd:AbstractClassWithoutAnyMethodL30 抽象类没有抽象方法,abstract 可能只是用来阻止实例化 建议: 如果目的是阻止实例化,应使用私有或 protected 构造函数而非 abstract。 - 🔴
pmd:SystemPrintlnL39 使用了 System.out/err 输出 建议: 改用 SLF4J/Log4j 等日志框架记录输出。 - 🔴
pmd:AvoidThrowingNullPointerExceptionL75 避免手动抛出 NullPointerException 建议: 应通过参数校验、Objects.requireNonNull 等方式处理,而不是直接 new NullPointerException。 - 🔴
pmd:AvoidThrowingRawExceptionTypesL82 避免抛出原始异常类型 RuntimeException 建议: 抛出自定义异常或更具体的异常类型,并携带业务上下文。 - 🔴
pmd:ClassWithOnlyPrivateConstructorsShouldBeFinalL93 只有私有构造函数,应声明为 final 建议: 给类添加 final 修饰符,防止通过反射或内部类扩展。 - 🔴
pmd:SystemPrintlnL103 Usage of System.out/err - 🔴
pmd:SystemPrintlnL140 Usage of System.out/err - 🔴
pmd:FieldNamingConventionsL149 字段命名不符合约定 建议: 按 Java 命名规范:常量用 UPPER_SNAKE,普通字段用 lowerCamel。 - 🔴
pmd:SystemPrintlnL155 Usage of System.out/err - 🔴
pmd:SystemPrintlnL158 Usage of System.out/err - 🔴
pmd:SystemPrintlnL161 Usage of System.out/err - 🔴
pmd:SystemPrintlnL164 Usage of System.out/err - 🔴
pmd:SystemPrintlnL167 Usage of System.out/err - 🔴
pmd:SystemPrintlnL170 Usage of System.out/err - 🔴
pmd:SystemPrintlnL173 Usage of System.out/err - 🔴
pmd:SystemPrintlnL176 Usage of System.out/err - 🔴
pmd:SystemPrintlnL179 Usage of System.out/err - 🔴
pmd:SystemPrintlnL182 Usage of System.out/err - 🔴
pmd:SystemPrintlnL185 Usage of System.out/err - 🔴
pmd:SystemPrintlnL188 Usage of System.out/err - 🔴
pmd:SystemPrintlnL191 Usage of System.out/err - 🔴
pmd:SystemPrintlnL194 Usage of System.out/err - 🔴
pmd:SystemPrintlnL197 Usage of System.out/err - 🔴
pmd:SystemPrintlnL200 Usage of System.out/err - 🔴
pmd:SystemPrintlnL203 Usage of System.out/err - 🔴
pmd:SystemPrintlnL206 Usage of System.out/err - 🔴
pmd:SystemPrintlnL209 Usage of System.out/err - 🔴
pmd:SystemPrintlnL212 Usage of System.out/err - 🔴
pmd:SystemPrintlnL215 Usage of System.out/err - 🔴
pmd:SystemPrintlnL218 Usage of System.out/err - 🔴
pmd:SystemPrintlnL221 Usage of System.out/err - 🔴
pmd:SystemPrintlnL224 Usage of System.out/err - 🔴
pmd:SystemPrintlnL227 Usage of System.out/err - 🔴
pmd:SystemPrintlnL230 Usage of System.out/err - 🔴
pmd:SystemPrintlnL233 Usage of System.out/err - 🔴
pmd:SystemPrintlnL236 Usage of System.out/err - 🔴
pmd:SystemPrintlnL239 Usage of System.out/err - 🔴
pmd:SystemPrintlnL242 Usage of System.out/err - 🔴
pmd:SystemPrintlnL245 Usage of System.out/err - 🔴
pmd:SystemPrintlnL248 Usage of System.out/err - 🔴
pmd:SystemPrintlnL251 Usage of System.out/err - 🔴
pmd:SystemPrintlnL254 Usage of System.out/err - 🔴
pmd:SystemPrintlnL257 Usage of System.out/err - 🔴
pmd:SystemPrintlnL260 Usage of System.out/err - 🔴
pmd:SystemPrintlnL263 Usage of System.out/err - 🔴
pmd:SystemPrintlnL266 Usage of System.out/err - 🔴
pmd:SystemPrintlnL269 Usage of System.out/err - 🔴
pmd:SystemPrintlnL272 Usage of System.out/err - 🔴
pmd:SystemPrintlnL275 Usage of System.out/err - 🔴
pmd:SystemPrintlnL278 Usage of System.out/err - 🔴
pmd:SystemPrintlnL281 Usage of System.out/err - 🔴
pmd:SystemPrintlnL284 Usage of System.out/err - 🔴
pmd:SystemPrintlnL287 Usage of System.out/err - 🔴
pmd:SystemPrintlnL290 Usage of System.out/err - 🔴
pmd:SystemPrintlnL293 Usage of System.out/err - 🔴
pmd:SystemPrintlnL296 Usage of System.out/err - 🔴
pmd:SystemPrintlnL299 Usage of System.out/err - 🔴
pmd:SystemPrintlnL302 Usage of System.out/err - 🔴
pmd:SystemPrintlnL422 Usage of System.out/err - 🔴
pmd:SystemPrintlnL423 Usage of System.out/err - 🔴
pmd:SystemPrintlnL424 Usage of System.out/err - 🔴
pmd:SystemPrintlnL425 Usage of System.out/err - 🔴
pmd:SystemPrintlnL426 Usage of System.out/err - 🔴
pmd:SystemPrintlnL427 Usage of System.out/err - 🔴
pmd:SystemPrintlnL428 Usage of System.out/err - 🔴
pmd:SystemPrintlnL429 Usage of System.out/err - 🔴
pmd:SystemPrintlnL430 Usage of System.out/err - 🔴
pmd:SystemPrintlnL431 Usage of System.out/err - 🔴
pmd:SystemPrintlnL432 Usage of System.out/err - 🔴
pmd:SystemPrintlnL433 Usage of System.out/err - 🔴
pmd:SystemPrintlnL436 Usage of System.out/err - 🔴
pmd:SystemPrintlnL437 Usage of System.out/err - 🔴
pmd:SystemPrintlnL438 Usage of System.out/err - 🔴
pmd:SystemPrintlnL439 Usage of System.out/err - 🔴
pmd:SystemPrintlnL440 Usage of System.out/err - 🔴
pmd:SystemPrintlnL441 Usage of System.out/err - 🔴
pmd:SystemPrintlnL442 Usage of System.out/err - 🔴
pmd:SystemPrintlnL443 Usage of System.out/err - 🔴
pmd:SystemPrintlnL444 Usage of System.out/err - 🔴
pmd:SystemPrintlnL445 Usage of System.out/err - 🔴
pmd:SystemPrintlnL446 Usage of System.out/err - 🔴
pmd:SystemPrintlnL447 Usage of System.out/err - 🔴
pmd:SystemPrintlnL450 Usage of System.out/err - 🔴
pmd:SystemPrintlnL451 Usage of System.out/err - 🔴
pmd:SystemPrintlnL452 Usage of System.out/err - 🔴
pmd:SystemPrintlnL453 Usage of System.out/err - 🔴
pmd:SystemPrintlnL454 Usage of System.out/err - 🔴
pmd:SystemPrintlnL455 Usage of System.out/err - 🔴
pmd:SystemPrintlnL456 Usage of System.out/err - 🔴
pmd:SystemPrintlnL457 Usage of System.out/err - 🔴
pmd:SystemPrintlnL458 Usage of System.out/err - 🔴
pmd:SystemPrintlnL459 Usage of System.out/err - 🔴
pmd:SystemPrintlnL460 Usage of System.out/err - 🔴
pmd:SystemPrintlnL461 Usage of System.out/err - 🔴
pmd:SystemPrintlnL464 Usage of System.out/err - 🔴
pmd:SystemPrintlnL495 Usage of System.out/err - 🔴
pmd:SystemPrintlnL496 Usage of System.out/err - 🔴
pmd:SystemPrintlnL497 Usage of System.out/err - 🔴
pmd:SystemPrintlnL498 Usage of System.out/err - 🔴
pmd:SystemPrintlnL501 Usage of System.out/err - 🔴
pmd:SystemPrintlnL502 Usage of System.out/err - 🔴
pmd:SystemPrintlnL503 Usage of System.out/err - 🔴
pmd:SystemPrintlnL504 Usage of System.out/err - 🔴
pmd:SystemPrintlnL507 Usage of System.out/err - 🔴
pmd:SystemPrintlnL508 Usage of System.out/err - 🔴
pmd:SystemPrintlnL509 Usage of System.out/err - 🔴
pmd:SystemPrintlnL510 Usage of System.out/err - 🔴
pmd:SystemPrintlnL513 Usage of System.out/err - 🔴
pmd:SystemPrintlnL514 Usage of System.out/err - 🔴
pmd:SystemPrintlnL515 Usage of System.out/err - 🔴
pmd:SystemPrintlnL516 Usage of System.out/err - 🔴
pmd:SystemPrintlnL528 Usage of System.out/err - 🔴
pmd:AvoidReassigningParametersL538 避免重新为参数赋值 建议: 使用新的局部变量保存修改后的值。 - 🔴
pmd:SystemPrintlnL539 Usage of System.out/err - 🔴
pmd:SystemPrintlnL577 Usage of System.out/err - 🔴
pmd:SystemPrintlnL578 Usage of System.out/err - 🔴
pmd:SystemPrintlnL586 Usage of System.out/err - 🔴
pmd:SystemPrintlnL597 Usage of System.out/err - 🔴
pmd:ConstructorCallsOverridableMethodL693 构造函数中调用了可重写方法 建议: 避免在构造期间调用非 final/method,或将该方法设为 final/private。 - 🔴
pmd:DoNotCallGarbageCollectionExplicitlyL702 不要显式触发垃圾回收 建议: 删除 System.gc(),交由 JVM 自动管理内存。 - 🔴
pmd:AvoidThrowingRawExceptionTypesL728 Avoid throwing raw exception type RuntimeException. - 🔴
pmd:EqualsNullL758 避免使用 equals() 与 null 比较 建议: 使用 o == null 判空,而不是 o.equals(null)。 - 🔴
pmd:AvoidReassigningParametersL766 Avoid reassigning parameters such as 's' - 🔴
pmd:SystemPrintlnL768 Usage of System.out/err - 🔴
pmd:SystemPrintlnL788 Usage of System.out/err - 🔴
pmd:SystemPrintlnL790 Usage of System.out/err - 🔴
pmd:MethodNamingConventionsL816 方法命名不符合约定 建议: 使用 lowerCamelCase 命名方法,如 sameName()。 - 🔴
pmd:ClassWithOnlyPrivateConstructorsShouldBeFinalL829 This class has only private constructors and may be final - 🔴
pmd:MoreThanOneLoggerL835 类中包含多个 logger 建议: 统一使用一个 logger 实例,避免日志输出混乱。 - 🔴
pmd:SystemPrintlnL843 Usage of System.out/err - 🔴
pmd:ReturnEmptyCollectionRatherThanNullL882 应返回空集合而不是 null 建议: 返回 Collections.emptyList() 或 List.of()。 - 🔴
pmd:SuspiciousEqualsMethodNameL909 方法名与 equals(Object) 高度相似,容易误导 建议: 重命名方法,或改为真正重写 equals(Object)。 - 🔴
pmd:SystemPrintlnL928 Usage of System.out/err - 🔴
pmd:FieldNamingConventionsL996 The field name 'TypeName' doesn't match '[a-z][a-zA-Z0-9]*' - 🔴
pmd:SingleMethodSingletonL1029 类包含多个 getInstance 方法,单例模式混乱 建议: 只保留一个无参 getInstance(),移除重载方法。 - 🔴
pmd:ClassWithOnlyPrivateConstructorsShouldBeFinalL1029 This class has only private constructors and may be final - 🔴
pmd:SingletonClassReturningNewInstanceL1039 getInstance 总是创建新对象,不符合单例行为 建议: getInstance 应返回缓存的唯一实例,而不是新建对象。 - 🔴
pmd:SystemPrintlnL1070 Usage of System.out/err - 🔴
pmd:SystemPrintlnL1078 Usage of System.out/err - 🔴
pmd:SystemPrintlnL1089 Usage of System.out/err - 🔴
pmd:FieldNamingConventionsL1096 The constant name '_LOG' doesn't match '[A-Z][A-Z_0-9]*' - 🔴
pmd:GuardLogStatementL1101 日志调用应使用日志级别守卫包裹 建议: 添加 if (LOGGER.isDebugEnabled()) 等守卫,或使用占位符避免字符串拼接。 - 🔴
pmd:SystemPrintlnL1134 Usage of System.out/err - 🔴
pmd:SystemPrintlnL1178 Usage of System.out/err - 🔴
pmd:SystemPrintlnL1208 Usage of System.out/err - 🔴
pmd:SystemPrintlnL1218 Usage of System.out/err - 🔴
pmd:AvoidBranchingStatementAsLastInLoopL1222 避免在循环末尾使用 break/continue 作为最后一条语句 建议: 调整循环结构,使正常退出条件更明确。 - 🔴
pmd:AvoidMultipleUnaryOperatorsL1230 多个一元运算符叠用可能造成误解或 bug 建议: 简化表达式,只保留一个运算符或使用括号明确语义。 - 🔴
pmd:AvoidMultipleUnaryOperatorsL1231 Using multiple unary operators may be a bug, and/or is confusing. - 🔴
pmd:SystemPrintlnL1232 Usage of System.out/err - 🔴
pmd:BrokenNullCheckL1239 null 检查逻辑有误,可能导致 NullPointerException 或逻辑错误 建议: 检查短路语义:判空应使用 && 或 || 正确组合,并在空值分支避免解引用。 - 🔴
pmd:BrokenNullCheckL1242 Dereferencing the qualifier of this expression will throw a NullPointerException - 🔴
pmd:ProperCloneImplementationL1254 clone() 应通过 super.clone() 实现 建议: 使用 super.clone() 并强制转换返回类型,而不是 new 新对象。 - 🔴
pmd:ProperCloneImplementationL1286 Object clone() should be implemented with super.clone() - 🔴
pmd:FieldNamingConventionsL1339 The field name 'LOG' doesn't match '[a-z][a-zA-Z0-9]*' - 🔴
pmd:FieldNamingConventionsL1344 The constant name '_LOG' doesn't match '[A-Z][A-Z_0-9]*' - 🔴
pmd:ClassWithOnlyPrivateConstructorsShouldBeFinalL1372 This class has only private constructors and may be final - 🔴
pmd:FieldNamingConventionsL1373 The static field name 'INSTANCE' doesn't match '[a-z][a-zA-Z0-9]*' - 🔴
pmd:ClassWithOnlyPrivateConstructorsShouldBeFinalL1384 This class has only private constructors and may be final - 🔴
pmd:FieldNamingConventionsL1385 The static field name 'INSTANCE' doesn't match '[a-z][a-zA-Z0-9]*' - 🔴
pmd:SystemPrintlnL1400 Usage of System.out/err - 🟡
pmd:AtLeastOneConstructorL30 每个类应至少声明一个构造函数(适用于所有命中项) 建议: 为没有构造函数的类添加显式构造函数;若类不应被实例化,则改为私有构造。 - 🟡
pmd:AbstractClassWithoutAbstractMethodL30 该抽象类没有任何抽象方法 建议: 删除 abstract 关键字,或为类增加抽象方法。 - 🟡
pmd:AtLeastOneConstructorL34 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL35 缺少默认访问修饰符的注释(方法/字段/类) 建议: 为包级私有成员添加 /* default */ 注释,或显式声明 private/protected/public。 - 🟡
pmd:MethodArgumentCouldBeFinalL35 参数未被赋值,可以声明为 final(适用于所有命中项) 建议: 在方法参数前添加 final 修饰符,避免无意中重新赋值。 - 🟡
pmd:MethodArgumentCouldBeFinalL35 Parameter 'b' is not assigned and could be declared final - 🟡
pmd:MethodArgumentCouldBeFinalL35 Parameter 'c' is not assigned and could be declared final - 🟡
pmd:CollapsibleIfStatementsL37 该 if 语句可以与父级 if 合并 建议: 使用 && 或 || 将嵌套条件合并,减少嵌套层级。 - 🟡
pmd:AvoidDeeplyNestedIfStmtsL38 if 嵌套过深,难以阅读 建议: 使用卫语句、提前返回或提取方法降低嵌套深度。 - 🟡
pmd:CollapsibleIfStatementsL38 This if statement could be combined with its parent - 🟡
pmd:AtLeastOneConstructorL47 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL48 Missing commented default access modifier on method 'bad()' - 🟡
pmd:AvoidRethrowingExceptionL51 捕获异常后仅重新抛出,应避免 建议: 不要捕获该异常,直接在方法签名中声明抛出;若必须捕获,请加入实际处理逻辑。 - 🟡
pmd:CommentDefaultAccessModifierL55 Missing commented default access modifier on method 'doWork()' - 🟡
pmd:AtLeastOneConstructorL60 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL61 Missing commented default access modifier on method 'bad()' - 🟡
pmd:CommentDefaultAccessModifierL68 Missing commented default access modifier on method 'doWork()' - 🟡
pmd:AtLeastOneConstructorL73 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL74 Missing commented default access modifier on method 'bad()' - 🟡
pmd:AtLeastOneConstructorL80 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL81 Missing commented default access modifier on method 'bad()' - 🟡
pmd:AtLeastOneConstructorL87 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL88 Missing commented default access modifier on method 'bad()' - 🟡
pmd:AvoidUncheckedExceptionsInSignaturesL88 方法/构造函数不应显式声明非受检异常 RuntimeException 建议: 从 throws 子句中删除非受检异常。 - 🟡
pmd:MissingStaticMethodInNonInstantiatableClassL93 类无法实例化,且没有提供任何静态方法或字段 建议: 添加 public static 方法/工厂方法,或将类声明为 final 并仅作工具类使用。 - 🟡
pmd:AtLeastOneConstructorL99 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL100 Missing commented default access modifier on method 'bad(int, int)' - 🟡
pmd:MethodArgumentCouldBeFinalL100 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:MethodArgumentCouldBeFinalL100 Parameter 'b' is not assigned and could be declared final - 🟡
pmd:CollapsibleIfStatementsL102 This if statement could be combined with its parent - 🟡
pmd:AtLeastOneConstructorL110 Each class should declare at least one constructor - 🟡
pmd:DataClassL110 类疑似数据类(只包含 getter/setter) 建议: 将数据与行为封装在一起,增加业务方法,避免仅作为数据容器。 - 🟡
pmd:PublicMemberInNonPublicTypeL113 非公共类型中声明了公共成员 建议: 将类改为 public,或将该成员的访问级别降为 package 私有。 - 🟡
pmd:PublicMemberInNonPublicTypeL116 Public member 'setName' declared in a non-public type - 🟡
pmd:MethodArgumentCouldBeFinalL116 Parameter 'name' is not assigned and could be declared final - 🟡
pmd:PublicMemberInNonPublicTypeL119 Public member 'getAge' declared in a non-public type - 🟡
pmd:PublicMemberInNonPublicTypeL122 Public member 'setAge' declared in a non-public type - 🟡
pmd:MethodArgumentCouldBeFinalL122 Parameter 'age' is not assigned and could be declared final - 🟡
pmd:MissingSerialVersionUIDL128 实现 Serializable 的类应定义 serialVersionUID 建议: 添加 private static final long serialVersionUID = 1L; - 🟡
pmd:AtLeastOneConstructorL128 Each class should declare at least one constructor - 🟡
pmd:DoNotExtendJavaLangErrorL128 异常不应继承 java.lang.Error 建议: 应继承 Exception/RuntimeException,Error 留给 JVM 内部严重错误。 - 🟡
pmd:AtLeastOneConstructorL132 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL133 Missing commented default access modifier on method 'bad()' - 🟡
pmd:UnusedAssignmentL134 变量的初始值从未被使用 建议: 删除初始赋值,或直接使用最终需要的值初始化。 - 🟡
pmd:CommentDefaultAccessModifierL142 Missing commented default access modifier on method 'check()' - 🟡
pmd:AtLeastOneConstructorL148 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL149 Missing commented default access modifier on field 'CONST' - 🟡
pmd:FinalFieldCouldBeStaticL149 final 字段可以声明为 static 建议: 若字段是编译时常量,请声明为 static final。 - 🟡
pmd:AtLeastOneConstructorL153 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL154 Missing commented default access modifier on method 'm1(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL154 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL157 Missing commented default access modifier on method 'm2(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL157 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL160 Missing commented default access modifier on method 'm3(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL160 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL163 Missing commented default access modifier on method 'm4(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL163 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL166 Missing commented default access modifier on method 'm5(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL166 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL169 Missing commented default access modifier on method 'm6(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL169 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL172 Missing commented default access modifier on method 'm7(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL172 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL175 Missing commented default access modifier on method 'm8(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL175 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL178 Missing commented default access modifier on method 'm9(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL178 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL181 Missing commented default access modifier on method 'm10(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL181 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL184 Missing commented default access modifier on method 'm11(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL184 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL187 Missing commented default access modifier on method 'm12(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL187 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL190 Missing commented default access modifier on method 'm13(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL190 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL193 Missing commented default access modifier on method 'm14(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL193 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL196 Missing commented default access modifier on method 'm15(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL196 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL199 Missing commented default access modifier on method 'm16(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL199 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL202 Missing commented default access modifier on method 'm17(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL202 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL205 Missing commented default access modifier on method 'm18(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL205 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL208 Missing commented default access modifier on method 'm19(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL208 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL211 Missing commented default access modifier on method 'm20(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL211 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL214 Missing commented default access modifier on method 'm21(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL214 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL217 Missing commented default access modifier on method 'm22(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL217 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL220 Missing commented default access modifier on method 'm23(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL220 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL223 Missing commented default access modifier on method 'm24(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL223 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL226 Missing commented default access modifier on method 'm25(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL226 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL229 Missing commented default access modifier on method 'm26(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL229 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL232 Missing commented default access modifier on method 'm27(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL232 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL235 Missing commented default access modifier on method 'm28(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL235 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL238 Missing commented default access modifier on method 'm29(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL238 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL241 Missing commented default access modifier on method 'm30(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL241 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL244 Missing commented default access modifier on method 'm31(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL244 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL247 Missing commented default access modifier on method 'm32(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL247 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL250 Missing commented default access modifier on method 'm33(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL250 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL253 Missing commented default access modifier on method 'm34(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL253 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL256 Missing commented default access modifier on method 'm35(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL256 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL259 Missing commented default access modifier on method 'm36(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL259 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL262 Missing commented default access modifier on method 'm37(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL262 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL265 Missing commented default access modifier on method 'm38(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL265 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL268 Missing commented default access modifier on method 'm39(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL268 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL271 Missing commented default access modifier on method 'm40(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL271 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL274 Missing commented default access modifier on method 'm41(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL274 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL277 Missing commented default access modifier on method 'm42(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL277 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL280 Missing commented default access modifier on method 'm43(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL280 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL283 Missing commented default access modifier on method 'm44(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL283 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL286 Missing commented default access modifier on method 'm45(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL286 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL289 Missing commented default access modifier on method 'm46(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL289 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL292 Missing commented default access modifier on method 'm47(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL292 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL295 Missing commented default access modifier on method 'm48(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL295 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL298 Missing commented default access modifier on method 'm49(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL298 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:CommentDefaultAccessModifierL301 Missing commented default access modifier on method 'm50(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL301 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:UnusedPrivateFieldL308 存在未使用的私有字段 建议: 删除该字段,或确认其确实被需要后补充使用。 - 🟡
pmd:ImmutableFieldL308 字段可以声明为 final 建议: 初始化后不再变更的字段应添加 final 修饰符。 - 🟡
pmd:UnnecessaryConstructorL310 构造函数不必要,编译器会生成默认构造 建议: 删除空的、无实际逻辑的构造函数。 - 🟡
pmd:CommentDefaultAccessModifierL310 Missing commented default access modifier on constructor 'Immut()' - 🟡
pmd:AtLeastOneConstructorL315 Each class should declare at least one constructor - 🟡
pmd:PublicMemberInNonPublicTypeL317 Public member 'getname' declared in a non-public type - 🟡
pmd:PublicMemberInNonPublicTypeL320 Public member 'setname' declared in a non-public type - 🟡
pmd:MethodArgumentCouldBeFinalL320 Parameter 'n' is not assigned and could be declared final - 🟡
pmd:AtLeastOneConstructorL326 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL327 Missing commented default access modifier on method 'bad(A)' - 🟡
pmd:MethodArgumentCouldBeFinalL327 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:LawOfDemeterL328 Call togetBon foreign valuea(degree 1) - 🟡
pmd:AtLeastOneConstructorL330 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL330 Missing commented default access modifier on nested class 'A' - 🟡
pmd:CommentDefaultAccessModifierL331 Missing commented default access modifier on method 'getB()' - 🟡
pmd:AtLeastOneConstructorL335 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL335 Missing commented default access modifier on nested class 'B' - 🟡
pmd:CommentDefaultAccessModifierL336 Missing commented default access modifier on method 'getC()' - 🟡
pmd:AtLeastOneConstructorL340 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL340 Missing commented default access modifier on nested class 'C' - 🟡
pmd:CommentDefaultAccessModifierL341 Missing commented default access modifier on method 'doIt()' - 🟡
pmd:AtLeastOneConstructorL347 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL348 Missing commented default access modifier on method 'bad(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL348 Parameter 'x' is not assigned and could be declared final - 🟡
pmd:SimplifyBooleanReturnsL349 该 if 语句可被替换为返回条件表达式 建议: 例如 if (x) return true; else return false 应改为 return x; - 🟡
pmd:LogicInversionL349 Use opposite operator instead of the logic complement operator. - 🟡
pmd:OnlyOneReturnL350 方法应只有唯一出口,且应在最后一条语句 建议: 将多个 return 改为单出口风格,或使用表达式结果返回。 - 🟡
pmd:UseUtilityClassL359 所有成员都是静态的,应添加私有构造防止实例化 建议: 为工具类添加 private 无参构造函数,并将类声明为 final。 - 🟡
pmd:MutableStaticStateL360 不要使用非 final 非私有的静态字段 建议: 改为 private static final,或通过 getter/setter 控制访问。 - 🟡
pmd:CommentDefaultAccessModifierL360 Missing commented default access modifier on field 'counter' - 🟡
pmd:AtLeastOneConstructorL364 Each class should declare at least one constructor - 🟡
pmd:PublicMemberInNonPublicTypeL365 Public member 'x' declared in a non-public type - 🟡
pmd:AtLeastOneConstructorL369 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL370 Missing commented default access modifier on method 'bad()' - 🟡
pmd:SignatureDeclareThrowsExceptionL370 方法/构造函数不应显式抛出 java.lang.Exception 建议: 抛出具体异常类型,避免宽泛的 Exception。 - 🟡
pmd:AtLeastOneConstructorL375 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL376 Missing commented default access modifier on method 'bad(boolean)' - 🟡
pmd:MethodArgumentCouldBeFinalL376 Parameter 'x' is not assigned and could be declared final - 🟡
pmd:SimplifiedTernaryL377 三元表达式可以简化 建议: 例如 return x ? true : false 应改为 return x。 - 🟡
pmd:AtLeastOneConstructorL382 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL383 Missing commented default access modifier on method 'bad(boolean)' - 🟡
pmd:MethodArgumentCouldBeFinalL383 Parameter 'x' is not assigned and could be declared final - 🟡
pmd:SimplifyBooleanExpressionsL384 布尔表达式包含不必要的比较 建议: 例如 return x == true 应改为 return x。 - 🟡
pmd:AtLeastOneConstructorL389 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL390 Missing commented default access modifier on method 'bad(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL390 Parameter 'x' is not assigned and could be declared final - 🟡
pmd:SimplifyBooleanReturnsL391 This if statement can be replaced byreturn {condition}; - 🟡
pmd:OnlyOneReturnL392 A method should have only one exit point, and that should be the last statement in the method - 🟡
pmd:AtLeastOneConstructorL400 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL401 Missing commented default access modifier on method 'bar(Object)' - 🟡
pmd:MethodArgumentCouldBeFinalL401 Parameter 'x' is not assigned and could be declared final - 🟡
pmd:EmptyControlStatementL402 存在空的控制语句(if/for/while 等) 建议: 补充逻辑或删除空语句块。 - 🟡
pmd:SimplifyConditionalL402 instanceof 前不需要检查 null 建议: 删除 x != null &&,因为 x instanceof List 已覆盖 null 情况。 - 🟡
pmd:AtLeastOneConstructorL408 Each class should declare at least one constructor - 🟡
pmd:SingularFieldL409 字段可能应改为局部变量 建议: 如果字段只在一个方法中使用,请改为方法内局部变量。 - 🟡
pmd:PublicMemberInNonPublicTypeL411 Public member 'foo' declared in a non-public type - 🟡
pmd:MethodArgumentCouldBeFinalL411 Parameter 'y' is not assigned and could be declared final - 🟡
pmd:AtLeastOneConstructorL418 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL419 Missing commented default access modifier on method 'bad(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL419 Parameter 'x' is not assigned and could be declared final - 🟡
pmd:SwitchDensityL420 switch 中语句与分支比例过高 建议: 将每个 case 的逻辑抽取为独立方法,或使用多态/映射表重构。 - 🟡
pmd:AtLeastOneConstructorL471 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL472 Missing commented default access modifier on method 'm()' - 🟡
pmd:AtLeastOneConstructorL475 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL477 Missing commented default access modifier on method 'm()' - 🟡
pmd:UselessOverridingMethodL477 重写方法仅调用 super,无实际用途 建议: 删除该重写方法,让父类方法直接生效。 - 🟡
pmd:UseUtilityClassL483 All members are static. Consider adding a private no-args constructor to prevent instantiation. - 🟡
pmd:CommentDefaultAccessModifierL484 Missing commented default access modifier on method 'helper()' - 🟡
pmd:AtLeastOneConstructorL491 Each class should declare at least one constructor - 🟡
pmd:PublicMemberInNonPublicTypeL492 Public member 'bar' declared in a non-public type - 🟡
pmd:MethodArgumentCouldBeFinalL492 Parameter 'x' is not assigned and could be declared final - 🟡
pmd:AtLeastOneConstructorL525 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL526 Missing commented default access modifier on method 'bar(Object, String)' - 🟡
pmd:MethodArgumentCouldBeFinalL526 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:MethodArgumentCouldBeFinalL526 Parameter 'baz' is not assigned and could be declared final - 🟡
pmd:MisplacedNullCheckL527 null 检查位置错误,可能引发 NullPointerException 建议: 先判空再调用方法,例如 a != null && a.equals(baz)。 - 🟡
pmd:AtLeastOneConstructorL536 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL537 Missing commented default access modifier on method 'bad(int)' - 🟡
pmd:AssignmentInOperandL538 避免在操作数中赋值 建议: 将赋值移到表达式外,单独一行,再参与判断。 - 🟡
pmd:UseUtilityClassL545 All members are static. Consider adding a private no-args constructor to prevent instantiation. - 🟡
pmd:MutableStaticStateL546 Do not use non-final non-private static fields - 🟡
pmd:CommentDefaultAccessModifierL546 Missing commented default access modifier on field 'counter' - 🟡
pmd:CommentDefaultAccessModifierL548 Missing commented default access modifier on constructor 'AssignStatic()' - 🟡
pmd:AssignmentToNonFinalStaticL549 构造函数中给非 final 静态字段赋值可能不安全 建议: 使用实例字段,或通过 static final/初始化块管理静态状态。 - 🟡
pmd:AtLeastOneConstructorL554 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL555 Missing commented default access modifier on method 'bad()' - 🟡
pmd:SignatureDeclareThrowsExceptionL555 A method/constructor should not explicitly throw java.lang.Exception - 🟡
pmd:LocalVariableCouldBeFinalL556 局部变量可声明为 final 建议: 为只赋值一次的局部变量添加 final 修饰符。 - 🟡
pmd:AvoidAccessibilityAlterationL557 不应使用 setAccessible(true) 修改可见性 建议: 避免反射破坏封装;若必须,应评估安全风险并限制调用权限。 - 🟡
pmd:AtLeastOneConstructorL562 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL563 Missing commented default access modifier on method 'bad()' - 🟡
pmd:LocalVariableCouldBeFinalL564 Local variable 'o' could be declared final - 🟡
pmd:AvoidCallingFinalizeL565 避免显式调用 finalize() 方法 建议: 删除显式调用,改用 try-with-resources 或 Cleaner 管理资源。 - 🟡
pmd:AtLeastOneConstructorL570 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL571 Missing commented default access modifier on field 'd' - 🟡
pmd:AvoidDecimalLiteralsInBigDecimalConstructorL571 避免用浮点字面量构造 BigDecimal,可能产生精度问题 建议: 使用字符串构造:new BigDecimal("0.1")。 - 🟡
pmd:AtLeastOneConstructorL575 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL576 Missing commented default access modifier on method 'bad()' - 🟡
pmd:AtLeastOneConstructorL583 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL584 Missing commented default access modifier on method 'bad(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL584 Parameter 'x' is not assigned and could be declared final - 🟡
pmd:AvoidLiteralsInIfConditionL585 if 条件中避免使用魔术数字/字面量 建议: 将 42、5 等常量提取为命名常量。 - 🟡
pmd:AtLeastOneConstructorL592 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL593 Missing commented default access modifier on method 'bad()' - 🟡
pmd:AssignmentInOperandL596 Avoid assignment to x in operand - 🟡
pmd:AtLeastOneConstructorL602 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL603 Missing commented default access modifier on field 'x' - 🟡
pmd:AvoidUsingOctalValuesL603 避免使用八进制字面量 建议: 去掉前导 0,或明确使用 0x/0b 前缀。 - 🟡
pmd:AtLeastOneConstructorL607 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL608 Missing commented default access modifier on method 'bad(Object, Object)' - 🟡
pmd:MethodArgumentCouldBeFinalL608 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:MethodArgumentCouldBeFinalL608 Parameter 'b' is not assigned and could be declared final - 🟡
pmd:EmptyControlStatementL609 Empty if statement - 🟡
pmd:AtLeastOneConstructorL615 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL616 Missing commented default access modifier on method 'bad()' - 🟡
pmd:UselessPureMethodCallL618 调用了纯方法但未使用结果 建议: 删除该调用,或将结果赋给变量并使用。 - 🟡
pmd:CommentDefaultAccessModifierL620 Missing commented default access modifier on method 'doSomething()' - 🟡
pmd:AtLeastOneConstructorL625 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL626 Missing commented default access modifier on method 'bad()' - 🟡
pmd:UselessPureMethodCallL627 Do not call pure method toString if the result is not used. - 🟡
pmd:CommentDefaultAccessModifierL630 Missing commented default access modifier on method 'doSomething()' - 🟡
pmd:AtLeastOneConstructorL635 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL636 Missing commented default access modifier on method 'bad()' - 🟡
pmd:CloseResourceL637 资源使用后应关闭 建议: 使用 try-with-resources 自动关闭 InputStream 等资源。 - 🟡
pmd:LocalVariableCouldBeFinalL637 Local variable 'in' could be declared final - 🟡
pmd:CheckSkipResultL638 应检查 InputStream.skip() 的返回值 建议: 将 skip 返回值赋给变量,并判断是否满足所需跳过字节数。 - 🟡
pmd:AtLeastOneConstructorL643 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL644 Missing commented default access modifier on method 'bad(Collection)' - 🟡
pmd:MethodArgumentCouldBeFinalL644 Parameter 'c' is not assigned and could be declared final - 🟡
pmd:UnusedLocalVariableL645 存在未使用的局部变量 建议: 删除未使用的局部变量,或补全其使用逻辑。 - 🟡
pmd:ClassCastExceptionWithToArrayL645 Collection.toArray() 的使用会抛出 ClassCastException 建议: 使用 c.toArray(new String[0]) 传入类型化数组。 - 🟡
pmd:AtLeastOneConstructorL650 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL651 Missing commented default access modifier on method 'bad()' - 🟡
pmd:LocalVariableCouldBeFinalL652 Local variable 'in' could be declared final - 🟡
pmd:AtLeastOneConstructorL658 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL659 Missing commented default access modifier on method 'bad()' - 🟡
pmd:UnusedLocalVariableL660 Avoid unused local variables such as 'l'. - 🟡
pmd:UnusedLocalVariableL661 Avoid unused local variables such as 'o'. - 🟡
pmd:PrimitiveWrapperInstantiationL661 不要使用 new Integer(...),应使用 Integer.valueOf(...) 建议: 使用装箱缓存或 Integer.valueOf 替代 new Integer。 - 🟡
pmd:UnnecessaryBoxingL661 存在不必要的显式装箱 建议: 直接使用基本类型或依赖自动装箱。 - 🟡
pmd:AtLeastOneConstructorL666 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL667 Missing commented default access modifier on method 'bad(String, String)' - 🟡
pmd:MethodArgumentCouldBeFinalL667 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:MethodArgumentCouldBeFinalL667 Parameter 'b' is not assigned and could be declared final - 🟡
pmd:EmptyControlStatementL668 Empty if statement - 🟡
pmd:CompareObjectsWithEqualsL668 比较对象引用应使用 equals() 而不是 == 建议: 对非基本类型对象比较使用 equals()。 - 🟡
pmd:UseEqualsToCompareStringsL668 比较字符串应使用 equals() 而不是 == 建议: 使用 a.equals(b),并按需调用 equalsIgnoreCase。 - 🟡
pmd:AtLeastOneConstructorL674 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL675 Missing commented default access modifier on method 'bad(double)' - 🟡
pmd:MethodArgumentCouldBeFinalL675 Parameter 'x' is not assigned and could be declared final - 🟡
pmd:EmptyControlStatementL676 Empty if statement - 🟡
pmd:ComparisonWithNaNL676 与 NaN 比较恒为 false 建议: 使用 Double.isNaN(x) 判断 NaN。 - 🟡
pmd:AtLeastOneConstructorL682 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL683 Missing commented default access modifier on method 'call()' - 🟡
pmd:CommentDefaultAccessModifierL686 Missing commented default access modifier on method 'accept(String[])' - 🟡
pmd:CommentDefaultAccessModifierL692 Missing commented default access modifier on constructor 'CtorCall()' - 🟡
pmd:CommentDefaultAccessModifierL695 Missing commented default access modifier on method 'overridable()' - 🟡
pmd:AtLeastOneConstructorL700 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL701 Missing commented default access modifier on method 'bad()' - 🟡
pmd:MissingSerialVersionUIDL707 Classes implementing Serializable should set a serialVersionUID - 🟡
pmd:AtLeastOneConstructorL707 Each class should declare at least one constructor - 🟡
pmd:DoNotExtendJavaLangThrowableL707 异常不应直接继承 java.lang.Throwable 建议: 应继承 Exception 或 RuntimeException。 - 🟡
pmd:AtLeastOneConstructorL711 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL712 Missing commented default access modifier on field 'path' - 🟡
pmd:DoNotHardCodeSDCardL712 不要硬编码 /sdcard 路径 建议: 使用环境变量或上下文 API 获取存储路径。 - 🟡
pmd:AtLeastOneConstructorL716 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL717 Missing commented default access modifier on method 'bad()' - 🟡
pmd:DoNotTerminateVML718 不应调用 System.exit() 终止 JVM 建议: 通过受控方式结束应用,或抛出异常交给上层处理。 - 🟡
pmd:AtLeastOneConstructorL723 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL724 Missing commented default access modifier on method 'bad()' - 🟡
pmd:CommentDefaultAccessModifierL731 Missing commented default access modifier on method 'doWork()' - 🟡
pmd:AtLeastOneConstructorL736 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL737 Missing commented default access modifier on method 'bad()' - 🟡
pmd:DontUseFloatTypeForLoopIndicesL738 不要使用浮点类型作为循环索引,浮点精度可能导致循环异常 建议: 改用 int/long 循环变量,或使用 double 并明确终止条件。 - 🟡
pmd:EmptyControlStatementL738 Empty for statement - 🟡
pmd:AtLeastOneConstructorL744 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL745 Missing commented default access modifier on method 'bad()' - 🟡
pmd:EmptyCatchBlockL748 避免空 catch 块 建议: 至少记录日志或做降级处理,不要静默吞掉异常。 - 🟡
pmd:AvoidCatchingGenericExceptionL748 避免捕获泛化 Exception 建议: 捕获具体异常类型,如 IOException、IllegalArgumentException。 - 🟡
pmd:CommentDefaultAccessModifierL751 Missing commented default access modifier on method 'doWork()' - 🟡
pmd:AtLeastOneConstructorL756 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL757 Missing commented default access modifier on method 'bad(Object)' - 🟡
pmd:MethodArgumentCouldBeFinalL757 Parameter 'o' is not assigned and could be declared final - 🟡
pmd:EmptyControlStatementL758 Empty if statement - 🟡
pmd:AtLeastOneConstructorL764 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL765 Missing commented default access modifier on method 'bad(String)' - 🟡
pmd:AtLeastOneConstructorL773 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL774 Missing commented default access modifier on method 'bad(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL774 Parameter 'x' is not assigned and could be declared final - 🟡
pmd:IdenticalConditionalBranchesL775 条件分支完全相同,条件判断无意义 建议: 删除 if/else,直接返回相同结果或提取公共逻辑。 - 🟡
pmd:OnlyOneReturnL776 A method should have only one exit point, and that should be the last statement in the method - 🟡
pmd:AtLeastOneConstructorL784 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL785 Missing commented default access modifier on method 'bad(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL785 Parameter 'x' is not assigned and could be declared final - 🟡
pmd:ImplicitSwitchFallThroughL789 switch 分支存在隐式 fall-through 建议: 在 case 末尾补上 break/return,或添加注释明确故意 fall-through。 - 🟡
pmd:AtLeastOneConstructorL799 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL800 Missing commented default access modifier on method 'bad()' - 🟡
pmd:UnusedLocalVariableL801 Avoid unused local variables such as 'c'. - 🟡
pmd:PrimitiveWrapperInstantiationL801 Do not usenew Integer(...), preferInteger.valueOf(...) - 🟡
pmd:AtLeastOneConstructorL806 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL807 Missing commented default access modifier on method 'bad()' - 🟡
pmd:ForLoopVariableCountL808 for 循环中控制变量过多 建议: 拆分循环或将额外变量移到循环外,保持循环头简洁。 - 🟡
pmd:AvoidReassigningLoopVariablesL809 避免修改循环控制变量 建议: 不要在循环体内或内层循环更新外层循环变量,使用独立变量。 - 🟡
pmd:AtLeastOneConstructorL815 Each class should declare at least one constructor - 🟡
pmd:MethodWithSameNameAsEnclosingClassL816 方法与包含它的类同名(可能误当构造函数) 建议: 重命名方法,避免与类名混淆。 - 🟡
pmd:CommentDefaultAccessModifierL816 Missing commented default access modifier on method 'SameName()' - 🟡
pmd:AtLeastOneConstructorL821 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL822 Missing commented default access modifier on method 'bad(String)' - 🟡
pmd:MethodArgumentCouldBeFinalL822 Parameter 's' is not assigned and could be declared final - 🟡
pmd:EmptyControlStatementL823 Empty if statement - 🟡
pmd:MissingStaticMethodInNonInstantiatableClassL829 Class cannot be instantiated and does not provide any static methods or fields - 🟡
pmd:UnusedPrivateFieldL836 Avoid unused private fields such as 'LOG1'. - 🟡
pmd:UnusedPrivateFieldL837 Avoid unused private fields such as 'LOG2'. - 🟡
pmd:AtLeastOneConstructorL841 Each class should declare at least one constructor - 🟡
pmd:NonStaticInitializerL842 非静态初始化器令人困惑 建议: 将初始化逻辑移到构造函数或工厂方法中。 - 🟡
pmd:AtLeastOneConstructorL848 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL849 Missing commented default access modifier on field 's' - 🟡
pmd:CommentDefaultAccessModifierL850 Missing commented default access modifier on method 'bad()' - 🟡
pmd:NullAssignmentL851 将对象赋值为 null 是代码坏味道 建议: 用 Optional 或空集合/空对象模式替代 null 赋值。 - 🟡
pmd:AtLeastOneConstructorL856 Each class should declare at least one constructor - 🟡
pmd:OverrideBothEqualsAndHashcodeL857 重写 equals() 时应同时重写 hashCode() 建议: 为相等的对象保证 hashCode 一致,避免集合类行为异常。 - 🟡
pmd:MissingOverrideL857 重写方法缺少 @Override 注解 建议: 在继承或实现的方法上添加 @Override 注解。 - 🟡
pmd:AtLeastOneConstructorL863 Each class should declare at least one constructor - 🟡
pmd:MissingOverrideL864 The method 'compareTo(CmpOnly)' is missing an @Override annotation. - 🟡
pmd:OverrideBothEqualsAndHashCodeOnComparableL864 实现 Comparable 时应同时重写 equals() 和 hashCode() 建议: 保持 compareTo、equals、hashCode 三者语义一致。 - 🟡
pmd:AtLeastOneConstructorL870 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL871 Missing commented default access modifier on field 'c' - 🟡
pmd:ReplaceJavaUtilCalendarL871 应使用 java.time 替代 java.util.Calendar 建议: 使用 LocalDate/LocalDateTime/ZonedDateTime 等新时间 API。 - 🟡
pmd:AtLeastOneConstructorL875 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL876 Missing commented default access modifier on field 'd' - 🟡
pmd:ReplaceJavaUtilDateL876 应使用 java.time 替代 java.util.Date 建议: 使用 Instant/LocalDateTime 并配合 DateTimeFormatter 处理格式。 - 🟡
pmd:ReplaceJavaUtilDateL876 Usage of java.util.Date should be replaced with classes from java.time - 🟡
pmd:AtLeastOneConstructorL880 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL881 Missing commented default access modifier on method 'bad()' - 🟡
pmd:AtLeastOneConstructorL887 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL888 Missing commented default access modifier on method 'bad()' - 🟡
pmd:OnlyOneReturnL890 A method should have only one exit point, and that should be the last statement in the method - 🟡
pmd:ReturnFromFinallyBlockL892 避免在 finally 块中返回值 建议: 从 try/catch 中返回结果,finally 只做资源清理。 - 🟡
pmd:AtLeastOneConstructorL898 Each class should declare at least one constructor - 🟡
pmd:AvoidFieldNameMatchingTypeNameL899 字段名与类名相同容易混淆 建议: 重命名字段,例如 sdf 改为 dateFormat。 - 🟡
pmd:CommentDefaultAccessModifierL899 Missing commented default access modifier on field 'sdf' - 🟡
pmd:SimpleDateFormatNeedsLocaleL899 SimpleDateFormat 实例化时应指定 Locale 建议: new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT)。 - 🟡
pmd:AtLeastOneConstructorL903 Each class should declare at least one constructor - 🟡
pmd:AvoidStringBufferFieldL904 StringBuffer 字段可能造成内存问题 建议: 优先使用 StringBuilder,并避免在长生命周期对象中持有大缓冲区。 - 🟡
pmd:CommentDefaultAccessModifierL904 Missing commented default access modifier on field 'sb' - 🟡
pmd:AtLeastOneConstructorL908 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL909 Missing commented default access modifier on method 'equals(String)' - 🟡
pmd:AtLeastOneConstructorL914 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL915 Missing commented default access modifier on method 'hashcode()' - 🟡
pmd:AtLeastOneConstructorL920 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL921 Missing commented default access modifier on field 's' - 🟡
pmd:AtLeastOneConstructorL925 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL926 Missing commented default access modifier on method 'bad()' - 🟡
pmd:UnconditionalIfStatementL927 不要使用恒真/恒假的 if 语句 建议: 删除无条件 if,直接执行其中的代码或删除整个语句块。 - 🟡
pmd:AtLeastOneConstructorL934 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL935 Missing commented default access modifier on method 'bad(String)' - 🟡
pmd:MethodArgumentCouldBeFinalL935 Parameter 's' is not assigned and could be declared final - 🟡
pmd:EmptyControlStatementL936 Empty if statement - 🟡
pmd:AtLeastOneConstructorL942 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL943 Missing commented default access modifier on method 'bad(int)' - 🟡
pmd:MethodArgumentCouldBeFinalL943 Parameter 'x' is not assigned and could be declared final - 🟡
pmd:UnusedLocalVariableL944 Avoid unused local variables such as 's'. - 🟡
pmd:UnnecessaryConversionTemporaryL944 避免不必要的临时转换对象 建议: 使用 String.valueOf(x) 替代 new Integer(x).toString()。 - 🟡
pmd:PrimitiveWrapperInstantiationL944 Do not usenew Integer(...), preferInteger.valueOf(...) - 🟡
pmd:AtLeastOneConstructorL949 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL950 Missing commented default access modifier on field 's' - 🟡
pmd:OverrideBothEqualsAndHashcodeL951 Ensure you override both equals() and hashCode() - 🟡
pmd:MissingOverrideL951 The method 'equals(Object)' is missing an @Override annotation. - 🟡
pmd:MethodArgumentCouldBeFinalL951 Parameter 'o' is not assigned and could be declared final - 🟡
pmd:EmptyControlStatementL952 Empty if statement - 🟡
pmd:AtLeastOneConstructorL959 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL960 Missing commented default access modifier on method 'bad(String, String)' - 🟡
pmd:MethodArgumentCouldBeFinalL960 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:MethodArgumentCouldBeFinalL960 Parameter 'b' is not assigned and could be declared final - 🟡
pmd:CompareObjectsWithEqualsL961 Use equals() to compare object references. - 🟡
pmd:UseEqualsToCompareStringsL961 Use equals() to compare strings instead of '==' or '!=' - 🟡
pmd:AtLeastOneConstructorL966 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL967 Missing commented default access modifier on method 'bad()' - 🟡
pmd:UselessPureMethodCallL968 Do not call pure method length if the result is not used. - 🟡
pmd:AtLeastOneConstructorL973 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL974 Missing commented default access modifier on method 'bad(String)' - 🟡
pmd:MethodArgumentCouldBeFinalL974 Parameter 's' is not assigned and could be declared final - 🟡
pmd:UselessPureMethodCallL975 Do not call pure method toUpperCase if the result is not used. - 🟡
pmd:UseLocaleWithCaseConversionsL975 toUpperCase()/toLowerCase() 应指定 Locale 建议: 使用 s.toUpperCase(Locale.ROOT) 或指定业务 locale。 - 🟡
pmd:AtLeastOneConstructorL980 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL981 Missing commented default access modifier on method 'bad()' - 🟡
pmd:UnusedLocalVariableL982 Avoid unused local variables such as 'cl'. - 🟡
pmd:UseProperClassLoaderL982 getClassLoader() 在 J2EE 中可能不符合预期 建议: 使用 Thread.currentThread().getContextClassLoader()。 - 🟡
pmd:AtLeastOneConstructorL987 Each class should declare at least one constructor - 🟡
pmd:AvoidFieldNameMatchingMethodNameL988 字段名与同名方法容易混淆 建议: 重命名字段或方法,避免同名歧义。 - 🟡
pmd:CommentDefaultAccessModifierL988 Missing commented default access modifier on field 'value' - 🟡
pmd:CommentDefaultAccessModifierL990 Missing commented default access modifier on method 'value()' - 🟡
pmd:AtLeastOneConstructorL995 Each class should declare at least one constructor - 🟡
pmd:AvoidFieldNameMatchingTypeNameL996 It is somewhat confusing to have a field name matching the declaring class name - 🟡
pmd:CommentDefaultAccessModifierL996 Missing commented default access modifier on field 'TypeName' - 🟡
pmd:AtLeastOneConstructorL1000 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1001 Missing commented default access modifier on method 'bad()' - 🟡
pmd:AvoidCatchingGenericExceptionL1004 Avoid catching Exception in try-catch block - 🟡
pmd:EmptyControlStatementL1005 Empty if statement - 🟡
pmd:AvoidInstanceofChecksInCatchClauseL1005 catch 块中不应使用 instanceof 判断异常类型 建议: 为每种异常类型增加独立的 catch 子句。 - 🟡
pmd:CommentDefaultAccessModifierL1009 Missing commented default access modifier on method 'doWork()' - 🟡
pmd:AtLeastOneConstructorL1014 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1015 Missing commented default access modifier on method 'bad()' - 🟡
pmd:LocalVariableCouldBeFinalL1016 Local variable 'x' could be declared final - 🟡
pmd:TooFewBranchesForSwitchL1017 switch 分支少于三个,使用 if 更高效 建议: 将 switch 改为 if/else if 判断。 - 🟡
pmd:NonExhaustiveSwitchL1017 switch 不完整,应包含 default 或所有枚举分支 建议: 补充 default 分支处理未知情况。 - 🟡
pmd:NonCaseLabelInSwitchL1020 switch 中出现了非 case 标签 建议: 移除标签,或重构 switch 逻辑。 - 🟡
pmd:UnusedLabelL1020 存在未使用的标签 建议: 删除未引用标签,避免误导。 - 🟡
pmd:PublicMemberInNonPublicTypeL1035 Public member 'getInstance' declared in a non-public type - 🟡
pmd:PublicMemberInNonPublicTypeL1039 Public member 'getInstance' declared in a non-public type - 🟡
pmd:MethodArgumentCouldBeFinalL1039 Parameter 'obj' is not assigned and could be declared final - 🟡
pmd:VariableCanBeInlinedL1040 局部变量可以内联,不需要额外存储 建议: 直接返回值或表达式,减少中间变量。 - 🟡
pmd:LocalVariableCouldBeFinalL1040 Local variable 's' could be declared final - 🟡
pmd:SignatureDeclareThrowsExceptionL1047 A method/constructor should not explicitly throw java.lang.Exception - 🟡
pmd:UnsupportedJdkApiUsageL1048 使用了不受支持的 JDK API(如 sun.misc.Unsafe) 建议: 改用标准 JDK API,例如 VarHandle/Atomic 类或通过受支持方式获取 Unsafe。 - 🟡
pmd:AtLeastOneConstructorL1053 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1054 Missing commented default access modifier on method 'bar()' - 🟡
pmd:IdempotentOperationsL1056 存在幂等操作(如变量赋值给自身/重复转换) 建议: 删除重复或自我赋值,保留一次有效操作。 - 🟡
pmd:UnusedAssignmentL1056 The value assigned to variable 'x' is never used - 🟡
pmd:AtLeastOneConstructorL1061 Each class should declare at least one constructor - 🟡
pmd:PublicMemberInNonPublicTypeL1062 Public member 'hashcode' declared in a non-public type - 🟡
pmd:SuspiciousHashcodeMethodNameL1062 方法名与 hashCode() 高度相似,但签名不符 建议: 重命名为 hashcode -> hashCode,并返回 int 且加上 @Override。 - 🟡
pmd:AtLeastOneConstructorL1068 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1069 Missing commented default access modifier on method 'foo()' - 🟡
pmd:SuspiciousOctalEscapeL1070 字符串中的八进制转义后紧跟数字字符很可疑 建议: 将转义拆分或改用 Unicode 转义,避免歧义。 - 🟡
pmd:AtLeastOneConstructorL1075 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1076 Missing commented default access modifier on method 'bad(String)' - 🟡
pmd:MethodArgumentCouldBeFinalL1076 Parameter 'buz' is not assigned and could be declared final - 🟡
pmd:LocalVariableCouldBeFinalL1077 Local variable 'answer' could be declared final - 🟡
pmd:LiteralsFirstInComparisonsL1077 字符串比较时应将字面量放在前面 建议: 使用 "BAZ".equals(buz) 避免 NPE。 - 🟡
pmd:UnnecessaryCaseChangeL1077 使用 toUpperCase/toLowerCase().equals() 不如 equalsIgnoreCase 清晰 建议: 改为 s1.equalsIgnoreCase(s2)。 - 🟡
pmd:UseLocaleWithCaseConversionsL1077 When doing a String.toLowerCase()/toUpperCase() call, use a Locale - 🟡
pmd:AtLeastOneConstructorL1083 Each class should declare at least one constructor - 🟡
pmd:PublicMemberInNonPublicTypeL1084 Public member 'method1' declared in a non-public type - 🟡
pmd:PublicMemberInNonPublicTypeL1087 Public member 'method' declared in a non-public type - 🟡
pmd:MethodArgumentCouldBeFinalL1087 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:UnusedNullCheckInEqualsL1088 equals() 中的 null 检查未被使用或位置不当 建议: 直接调用非空对象.equals(),或先用 Objects.equals() 统一判空。 - 🟡
pmd:AtLeastOneConstructorL1095 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1097 Missing commented default access modifier on method 'bar()' - 🟡
pmd:AvoidCatchingGenericExceptionL1100 Avoid catching Exception in try-catch block - 🟡
pmd:CommentDefaultAccessModifierL1104 Missing commented default access modifier on method 'doWork()' - 🟡
pmd:AtLeastOneConstructorL1109 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1111 Missing commented default access modifier on method 'bar()' - 🟡
pmd:AtLeastOneConstructorL1118 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1119 Missing commented default access modifier on method 'bar()' - 🟡
pmd:AvoidDuplicateLiteralsL1120 字符串字面量重复出现多次 建议: 提取为常量,避免重复字符串字面量。 - 🟡
pmd:CommentDefaultAccessModifierL1125 Missing commented default access modifier on method 'buz(String)' - 🟡
pmd:AtLeastOneConstructorL1130 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1131 Missing commented default access modifier on method 'foo()' - 🟡
pmd:JumbledIncrementerL1133 内层循环修改了外层循环的递增变量,循环逻辑混乱 建议: 确保内层循环更新自己的控制变量,不要更新外层循环变量。 - 🟡
pmd:LocalVariableCouldBeFinalL1133 Local variable 'k' could be declared final - 🟡
pmd:AvoidReassigningLoopVariablesL1133 Avoid reassigning the loop control variable 'i' - 🟡
pmd:AtLeastOneConstructorL1141 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1142 Missing commented default access modifier on method 'foo()' - 🟡
pmd:AvoidLiteralsInIfConditionL1144 Avoid using literals such as 5 in if statements - 🟡
pmd:AtLeastOneConstructorL1152 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1153 Missing commented default access modifier on method 'bad()' - 🟡
pmd:LocalVariableCouldBeFinalL1154 Local variable 'numbers' could be declared final - 🟡
pmd:CollectionTypeMismatchL1155 集合操作使用了与泛型类型不匹配的对象 建议: 确保存入/取出/删除的元素类型与泛型一致,例如用 Integer 而不是 String。 - 🟡
pmd:UseConcurrentHashMapL1156 并发访问场景应使用 ConcurrentHashMap 建议: 将 HashMap 改为 ConcurrentHashMap,或同步访问。 - 🟡
pmd:LocalVariableCouldBeFinalL1156 Local variable 'map' could be declared final - 🟡
pmd:UselessPureMethodCallL1157 Do not call pure method get if the result is not used. - 🟡
pmd:CollectionTypeMismatchL1157 Object of type 'int' cannot be in collection expecting 'java.lang.String' - 🟡
pmd:LocalVariableCouldBeFinalL1158 Local variable 'names' could be declared final - 🟡
pmd:UselessPureMethodCallL1159 Do not call pure method contains if the result is not used. - 🟡
pmd:CollectionTypeMismatchL1159 Object of type 'int' cannot be in collection expecting 'java.lang.String' - 🟡
pmd:AtLeastOneConstructorL1164 Each class should declare at least one constructor - 🟡
pmd:AtLeastOneConstructorL1165 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1165 Missing commented default access modifier on nested class 'C' - 🟡
pmd:CommentDefaultAccessModifierL1166 Missing commented default access modifier on method 'varargs(Object[])' - 🟡
pmd:CommentDefaultAccessModifierL1167 Missing commented default access modifier on method 'call()' - 🟡
pmd:ConfusingArgumentToVarargsMethodL1168 可变参数调用意图不清晰 建议: 显式转换为 Object 或 Object[],或直接展开参数,避免歧义。 - 🟡
pmd:ConfusingArgumentToVarargsMethodL1169 Unclear if a varargs or non-varargs call is intended. Cast to Object or Object[] to clarify intent. - 🟡
pmd:AtLeastOneConstructorL1175 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1176 Missing commented default access modifier on method 'bar(Object, String)' - 🟡
pmd:MethodArgumentCouldBeFinalL1176 Parameter 'a' is not assigned and could be declared final - 🟡
pmd:MethodArgumentCouldBeFinalL1176 Parameter 'baz' is not assigned and could be declared final - 🟡
pmd:AtLeastOneConstructorL1184 Each class should declare at least one constructor - 🟡
pmd:UnusedPrivateFieldL1186 Avoid unused private fields such as 'stream'. - 🟡
pmd:NonSerializableClassL1186 可序列化类包含不可序列化的字段 建议: 将该字段标记为 transient,或改为可序列化类型。 - 🟡
pmd:AtLeastOneConstructorL1190 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1191 Missing commented default access modifier on method 'bad()' - 🟡
pmd:CommentDefaultAccessModifierL1198 Missing commented default access modifier on method 'doWork()' - 🟡
pmd:AtLeastOneConstructorL1204 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1205 Missing commented default access modifier on method 'bad()' - 🟡
pmd:AtLeastOneConstructorL1215 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1216 Missing commented default access modifier on method 'foo()' - 🟡
pmd:AvoidLiteralsInIfConditionL1219 Avoid using literals such as 25 in if statements - 🟡
pmd:AtLeastOneConstructorL1228 Each class should declare at least one constructor - 🟡
pmd:CommentDefaultAccessModifierL1229 Missing commented default access modifier on method 'foo()' - 🟡
pmd:LocalVariableCouldBeFinalL1230 Local variable 'i' could be declared final - 🟡
pmd:LocalVariableCouldBeFinalL1231 Local variable 'b' could be declared final - 🟡
pmd:AtLeastOneConstructorL1237 Each class should declare at least one constructor - 🟡
pmd:PublicMemberInNonPublicTypeL1238 Public member 'bar' declared in a non-public type - 🟡
pmd:MethodArgumentCouldBeFinalL1238 Parameter 'string' is not assigned and could be declared final - 🟡
pmd:LiteralsFirstInComparisonsL1239 Position literals first in String comparisons - 🟡
pmd:OnlyOneReturnL1240 A method should have only one exit point, and that should be the last statement in the method - 🟡
pmd:LiteralsFirstInComparisonsL1242 Position literals first in String comparisons - 🟡
pmd:OnlyOneReturnL1243 A method should have only one exit point, and that should be the last statement in the method - 🟡
pmd:AtLeastOneConstructorL1252 Each class should declare at least one constructor - 🟡
pmd:PublicMemberInNonPublicTypeL1254 Public member 'clone' declared in a non-public type - 🟡
pmd:CloneMethodReturnTypeMustMatchClassNameL1254 clone() 返回类型必须与类名一致 建议: 将 clone() 返回类型改为当前类名。 - 🟡
pmd:CloneMethodMustImplementCloneableL1254 只有实现 Cloneable 接口才应实现 clone() 方法 建议: 要么移除 clone() 方法,要么让类实现 Cloneable。 - 🟡
pmd:AtLeastOneConstructorL1260 Each class should declare at least one constructor - 🟡
pmd:CloneMethodReturnTypeMustMatchClassNameL1262 The return type of the clone() method must be the class name when implements Cloneable - 🟡
pmd:CloneMethodMustBePublicL1262 实现 Cloneable 时 clone() 方法必须为 public 建议: 将 protected clone() 改为 public CloneableType clone()。 - 🟡
pmd:OnlyOneReturnL1264 A method should have only one exit point, and that should be the last statement in the method - 🟡
pmd:AtLeastOneConstructorL1272 Each class should declare at least one constructor - 🟡
pmd:PublicMemberInNonPublicTypeL1274 Public member 'clone' declared in a non-public type - 🟡
pmd:CloneMethodReturnTypeMustMatchClassNameL1274 The return type of the clone() method must be the class name when implements Cloneable - 🟡
pmd:OnlyOneReturnL1276 A method should have only one exit point, and that should be the last statement in the method - 🟡
pmd:AtLeastOneConstructorL1284 Each class should declare at least one constructor - 🟡
pmd:PublicMemberInNonPublicTypeL1286 Public member 'clone' declared in a non-public type - 🟡
pmd:CloneMethodReturnTypeMustMatchClassNameL1286 The return type of the clone() method must be the class name when implements Cloneable - 🟡
pmd:AtLeastOneConstructorL1294 Each class should declare at least one constructor - 🟡
pmd:EmptyFinalizerL1296 finalize() 方法为空,没有实际作用 建议: 删除空 finalize 方法,或使用 Cleaner 清理资源。 - 🟡
pmd:AtLeastOneConstructorL1301 Each class should declare at least one constructor - 🟡
pmd:FinalizeDoesNotCallSuperFinalizeL1304 finalize() 方法应最后调用 super.finalize() 建议: 在 finalize() 末尾添加 super.finalize()。 - 🟡
pmd:CommentDefaultAccessModifierL1306 Missing commented default access modifier on method 'cleanup()' - 🟡
pmd:AtLeastOneConstructorL1311 Each class should declare at least one constructor - 🟡
pmd:FinalizeOnlyCallsSuperFinalizeL1313 finalize() 只调用 super.finalize(),没有实际清理逻辑 建议: 删除无意义的 finalize,或在其中加入真正的资源清理逻辑。 - 🟡
pmd:AtLeastOneConstructorL1319 Each class should declare at least one constructor - 🟡
pmd:FinalizeOnlyCallsSuperFinalizeL1320 Finalize should do something besides just calling super.finalize() - 🟡
pmd:MissingOverrideL1320 The method 'finalize()' is missing an @Override annotation. - 🟡
pmd:FinalizeOverloadedL1323 finalize 方法不应被重载 建议: 删除重载的 finalize(int) 方法。 - 🟡
pmd:AtLeastOneConstructorL1328 Each class should declare at least one constructor - 🟡
pmd:FinalizeOnlyCallsSuperFinalizeL1330 Finalize should do something besides just calling super.finalize() - 🟡
pmd:FinalizeShouldBeProtectedL1330 finalize() 应声明为 protected 建议: 将 public finalize() 改为 protected finalize()。 - 🟡
pmd:PublicMemberInNonPublicTypeL1330 Public member 'finalize' declared in a non-public type - 🟡
pmd:AtLeastOneConstructorL1338 Each class should declare at least one constructor - 🟡
pmd:ProperLoggerL1339 logger 应定义为 private static final,并持有正确的类 建议: 改为 private static final Logger LOG = LoggerFactory.getLogger(Class.class); - 🟡
pmd:AtLeastOneConstructorL1343 Each class should declare at least one constructor - 🟡
pmd:ProperLoggerL1344 Logger should be defined private static final and have the correct class - 🟡
pmd:CommentDefaultAccessModifierL1345 Missing commented default access modifier on method 'bar()' - 🟡
pmd:AvoidCatchingGenericExceptionL1348 Avoid catching Exception in try-catch block - 🟡
pmd:CommentDefaultAccessModifierL1352 Missing commented default access modifier on method 'doWork()' - 🟡
pmd:MissingSerialVersionUIDL1359 Classes implementing Serializable should set a serialVersionUID - 🟡
pmd:AtLeastOneConstructorL1359 Each class should declare at least one constructor - 🟡
pmd:UnusedPrivateFieldL1360 Avoid unused private fields such as 'value'. - 🟡
pmd:AtLeastOneConstructorL1364 Each class should declare at least one constructor - 🟡
pmd:UnusedPrivateFieldL1366 Avoid unused private fields such as 'nonSerializableField'. - 🟡
pmd:ImmutableFieldL1366 Field 'nonSerializableField' may be declared final - 🟡
pmd:PublicMemberInNonPublicTypeL1378 Public member 'getInstance' declared in a non-public type - 🟡
pmd:PublicMemberInNonPublicTypeL1390 Public member 'getInstance' declared in a non-public type - 🟡
pmd:NonThreadSafeSingletonL1391 单例实现不是线程安全的 建议: 使用 enum 单例、静态持有者(holder)或双重检查加 volatile。 - 🔵
pmd:UnnecessaryFullyQualifiedNameL402 不必要使用全限定名 建议: 使用已导入的简单类名代替全限定名。 - 🔵
pmd:DoNotThrowExceptionInFinallyL727 在 finally 块中抛出异常会使控制流难以理解 建议: 不要在 finally 中抛出异常,先记录或吞掉 finally 中的异常。 - 🔵
pmd:InstantiationToGetClassL801 不要仅为获取 Class 对象而实例化 建议: 使用 Integer.class 而不是 new Integer(1).getClass()。 - 🔵
pmd:StringBufferInstantiationWithCharL904 new StringBuffer(char) 会把 char 隐式转为 int 容量 建议: 使用 new StringBuffer() 或 new StringBuffer("c") 明确意图。 - 🔵
pmd:InvalidLogMessageFormatL1112 日志消息格式参数数量不匹配 建议: 修正占位符数量:一个 {} 对应一个参数。 - 🔵
pmd:InvalidLogMessageFormatL1113 Too many arguments, expected 1 argument but found 2 - 🔵
pmd:UnnecessaryFullyQualifiedNameL1184 Unnecessary qualifier 'java.io': 'Serializable' is already in scope because it is imported in this file
AI 审查 · 9 条建议
- 🔴 [AI] [bug]
rethrow-missing-throwsL48 捕获 IOException 后重新抛出但方法未声明 throws IOException,编译失败 ReThrow.bad() 中 catch (IOException e) 后直接 throw e,但 bad() 没有 throws IOException,无法编译。 建议: 在方法签名上增加 throws IOException,或者更简单:不要捕获该异常,直接让 doWork() 的异常向外传播。 - 🔴 [AI] [bug]
wrap-same-missing-throwsL61 包装 IOException 抛出但方法未声明 throws IOException,编译失败 WrapSame.bad() 中 catch 后 throw new IOException(...),但 bad() 未声明 throws IOException,代码无法编译。 建议: 为 bad() 增加 throws IOException,或捕获后改为抛出一个非受检异常。 - 🔴 [AI] [bug]
finalize-protected-inaccessibleL565 显式调用 Object.finalize() 违反访问控制,无法编译 CallFinalize.bad() 中通过 Object 引用调用 o.finalize(),但 Object.finalize() 是 protected 方法,不在同包且不是通过子类引用访问,编译不通过。 建议: 删除该调用;如果需要清理资源,使用 AutoCloseable/Cleaner。 - 🔴 [AI] [bug]
null-inputstream-skip-npeL637 InputStream 初始化为 null 后直接调用 skip(),必现 NPE CheckSkip.bad() 中 InputStream in = null,随后调用 in.skip(10),运行时必然抛出 NullPointerException。 建议: 初始化真实流,并用 try-with-resources 管理生命周期,同时检查 skip 返回值。 - 🔴 [AI] [performance]
infinite-loop-inner-incrementL1133 内层循环误递增外层变量 i,且 k 永不变,导致无限循环 JumbledInc.foo() 的内层循环 for (int k = 0; k < 20; i++) 更新的是 i 而不是 k,k 恒为 0,内层循环永不退出,程序将挂起。 建议: 内层循环应递增自己的控制变量 k。 - 🟡 [AI] [design]
bean-getter-setter-namingL317 getter/setter 未遵循 JavaBean 命名规范,影响框架绑定 BadBean 中 getname/setname 不符合 JavaBean 规范,应为 getName/setName,否则很多序列化/绑定框架无法识别。 建议: 将 getter 改为 getName(),setter 改为 setName(String name)。 - 🟡 [AI] [security]
singleton-cast-classcastexceptionL1039 重载 getInstance(Object) 中无类型检查直接强转,会抛 ClassCastException SingletonDemo.getInstance(Object obj) 直接 (SingletonDemo) obj,传入非 SingletonDemo 对象时抛出 ClassCastException,且该重载破坏了单例语义。 建议: 删除该重载方法;如果确需接收对象,应先 instanceof 校验后再处理。 - 🟡 [AI] [bug]
log-exception-as-stringL1101 日志只输出异常的 toString,丢失堆栈信息 CorrectLog.bar() 中 _LOG.error(String.valueOf(e)) 只记录异常字符串,无法看到堆栈;应把异常对象作为最后一个参数传给日志 API。 建议: 使用 _LOG.error("doWork failed", e),保留异常堆栈。 - 🟡 [AI] [bug]
loop-break-on-first-iterationL1222 循环第一次迭代就 break,后续逻辑成为死代码 BranchLastInLoop.foo() 中 if (i > 25) 永远不成立(i 最大为 9),而循环体末尾的 break 无条件执行,导致循环只执行一次。 建议: 检查循环终止条件,删除多余的 break,或把 break 放入有意义的条件判断中。