以下是一些常见的PMD规则:

  1. Unused local variable(未使用的局部变量):检测未使用的局部变量。
  2. Unused formal parameter(未使用的形式参数):检测未使用的方法参数。
  3. Unused private method(未使用的私有方法):检测未使用的私有方法。
  4. Unused private field(未使用的私有字段):检测未使用的私有字段。
  5. Empty if/while/for statement(空的if/while/for语句):检测空的if/while/for语句。
  6. Empty try/catch/finally block(空的try/catch/finally块):检测空的try/catch/finally块。
  7. Duplicate import(重复的导入):检测重复导入的包。
  8. Empty statement block(空的语句块):检测空的语句块。
  9. Avoid using System.out.println()(避免使用System.out.println()):检测使用System.out.println()语句。
  10. Cyclomatic complexity(圈复杂度):检测方法的圈复杂度,即方法中的决策路径数。
  11. Excessive parameter list(过多的参数列表):检测方法参数列表过长的情况。
  12. Long method(过长的方法):检测方法长度过长的情况。
  13. ClassCastException with instanceof(使用instanceof时的ClassCastException):检测在使用instanceof时可能引发ClassCastException的情况。
  14. Avoid using double brace initialization(避免使用双括号初始化):检测使用双括号初始化的情况。
  15. Unused method(未使用的方法):检测未使用的公共方法。

这只是一部分PMD规则的示例,具体的规则可以根据项目的需求和开发团队的规范进行配置和选择

pmd rules有哪写

原文地址: https://www.cveoy.top/t/topic/h8G5 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录