如果您使用Findbugs对于编译代码检查,是否有可能根据单个检测器或检测器类别的结果使构建失败?
例如,我想确保没有任何优先级的任何与空指针相关的检测( this list 中的“NP”前缀)。同样,我们真的不想有任何 wait not in loop情况。也就是说,我不一定希望基于国际化检测的构建失败,因为这些对我们的应用程序并不立即至关重要。
期望的最终状态是一个我们可以针对从 IDE 级别(Eclipse 和 Netbeans)到发布级别(使用 CruiseControl 生成构建)的各种开发阶段进行调整的过程。
注意:我知道 Eclipse 和 Netbeans 都有类似的内置检测方法,但这是 FindBugs 的特定问题。
最佳答案
来自FindBugs Using the Ant Task section :
includeFilter
Optional attribute. It specifies the filename of a filter specifying which bugs are reported. See Chapter 8, Filter Files.
来自第 8 章:
However, a filter could also be used to select bug instances to specifically report:
$ findbugs -textui -include myIncludeFilter.xml myApp.jar
和
- Match certain tests from all classes by specifying their abbreviations.
<Match>
<Bug code="DE,UrF,SIC" />
</Match></pre>
所以我会假设:
<Match>
<Bug code="Wa,NP" />
</Match>
在您的包含过滤器中和
<findbugs includeFilter="path/to/includefilter.xml"...
这就是您正在寻找的。p>
path/to /includeFilter
(或 excludeFilter
)可能是根据另一个属性的值设置的属性,该属性可能默认为 dev
之类的值对于常规构建,test
对于 CI 构建,以及 deploy
对于部署构建并指定您希望在每个阶段看到或不希望看到哪些特定警告。
希望有帮助。
关于java - 如何根据单个 Findbugs 检测器的结果使构建失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4225958/