@H_301_1@当我运行pmd分析时,我发现了违规行为:
@H_301_1@
Each class should declare at least one constructor
@H_301_1@此违规是在Spring控制器上.这个控制器是由Spring实例化的,所以不应该调用这个类.
@H_301_1@建议忽略此违规的方法是什么?
@H_301_1@根据http://pmd.sourceforge.net/pmd-4.3/suppressing.html可以使用// NOPMD,但我只是想忽略特定的违规行为.最佳答案
PMD还支持@SuppressWarnings注释:
@H_301_1@
// This will suppress all the PMD warnings in this class
@SuppressWarnings("PMD")
public class Bar {
void bar() {
int foo;
}
}
@H_301_1@或者只是一种警告:
@H_301_1@
// This will suppress UnusedLocalVariable warnings in this class
@SuppressWarnings("PMD.UnusedLocalVariable")
public class Bar {
void bar() {
int foo;
}
}
@H_301_1@您可能还想查看的内容是creating a ruleset and exclusions.也许您想要禁用某个规则,或者从PMD检查中排除某些文件.