PMD 报告超过 X 次违规行为
如果我违反特定规则超过 3000 次,是否有办法让 pmd 报告失败。我希望 CyclomaticComplexity 低于 1000 次违规,ExcessivePublicCount 低于 2000 次。我知道有一种方法可以获取违规数量,但我不想要总数,因为如果我将 CC 数量减少到 800,然后增加将EPC的数量改为2200,看起来就好像没有发生任何变化一样。如果不创建 2 个规则集(每个文件一个),然后使用不同的 pmd 目标运行,是否有更好的方法来做到这一点。
有没有办法 pmd 可以给我每种类型的违规数量(即:500 - CC 和 200 - EPC),而不仅仅是所有违规的列表?谢谢。
Is there a way to have pmd report failure if I exceed 3000 violations of a specific rule. I want CyclomaticComplexity to be under 1000 violations and ExcessivePublicCount to be under 2000. I know there is a way to get the number of violations, but I don't want the total number because if I reduce the amount of CC to 800, and increase the number of EPC to 2200, it will appear as if no changes happened. Without creating 2 rulesets, one for each file, then running with different pmd target, is there a better way to do this.
Is there a way pmd can give me the number of violations per type(I.E: 500 - CC and 200 - EPC), not just a list of all violations? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种想法 - 您可以让 PMD 以 XML 形式输出结果。然后,您可以编写 XPath 表达式来对这些计数的输出进行后处理。
在纯 PMD 中,我认为您可以编写一条规则来包装/扩展它们的规则并在静态变量中跟踪违规情况。如果你运行多个 CPU 核心,这将不起作用,所以我不会走这条路。另一个限制是您不知道有多少次失败。您可以因第 2001 个错误而失败,但不能因最后一个错误而失败。
One thought - you can have PMD output the results in XML. Then you can write an XPath expression to post process the output for those counts.
In pure PMD, I supposed you could write a rule that wraps/extends theirs and keeps track of violations in a static variable. This won't work if you run across multiple CPU cores though so I wouldn't go this route. Another limitation is that you won't know how many failures there are. You can fail on the 2001st error, but not the last error.