java - 如何根据单个 Findbugs 检测器的结果使构建失败?

标签 java ant build-process findbugs

如果您使用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

  1. 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"...

这就是您正在寻找的。

path/to /includeFilter (或 excludeFilter )可能是根据另一个属性的值设置的属性,该属性可能默认为 dev 之类的值对于常规构建,test对于 CI 构建,以及 deploy对于部署构建并指定您希望在每个阶段看到或不希望看到哪些特定警告。

希望有帮助。

关于java - 如何根据单个 Findbugs 检测器的结果使构建失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4225958/

相关文章:

java - 在ubuntu 10.10上安装jdk1.7.0

java - Gremlin:Blazegraph Remote

ant - 我可以编写一个在从另一个 ant 任务执行时接受参数的 ant 任务吗?

performance - 我们应该进行哪些硬件改进来加速我们的构建机器?

eclipse - 使用 eclipse 和 SVN 自动更新和构建

java - 生成复合 PK null id

java - 将两个包含不同对象的不同列表组合到第三个包含对象的列表作为两个列表的交叉连接

Java ant 脚本不显示警告

java - 重新加载特定 Web 应用程序的脚本

java - 如何使用 ant4eclipse 复制 eclipse 项目的所有引用的 jar?