有没有办法通过类名模式从 PMD 规则中排除类?
我正在寻找类似的东西:
<rule ref="rulesets/java/coupling.xml/ExcessiveImports">
<exclude-pattern>.*Test\.class</exclude-pattern>
</rule>
我知道 violationSuppressXPath 方法,但我发现它太丑陋/太复杂。
谢谢!
最佳答案
如果类名以 DTO
结尾,这里有一条规则将忽略特定规则:
<rule ref="category/java/bestpractices.xml/UnusedPrivateField">
<properties>
<!--Ignore UnusedPrivateField on classes where the class name ends with DTO-->
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration['.*DTO']"/>
</properties>
</rule>
关于java - 如何通过正则表达式从 pmd 规则中排除类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46728525/