开发者

PMD report more than X violations

开发者 https://www.devze.com 2023-02-21 18:49 出处:网络
Is there a way to have pmd report failure if I exceed 3000 violations of a specific rule. I want CyclomaticComplexity to be unde开发者_运维知识库r 1000 violations and ExcessivePublicCount to be under

Is there a way to have pmd report failure if I exceed 3000 violations of a specific rule. I want CyclomaticComplexity to be unde开发者_运维知识库r 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号