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

发布于 2024-10-03 08:13:38 字数 590 浏览 6 评论 0原文

如果您使用 Findbugs 进行编译代码检查,是否有可能根据结果导致构建失败单个探测器或探测器类别?

例如,我想确保没有任何与空指针相关的检测(此列表)任何优先级。同样,我们真的不希望出现任何等待不在循环中的情况。也就是说,我不一定希望基于国际化检测的构建失败,因为这些对我们的应用程序并不立即至关重要。

期望的最终状态是一个我们可以针对从 IDE 级别(Eclipse 和 Netbeans)到发布级别(使用 CruiseControl 生成构建)的各种开发阶段进行调整的过程。

注意:我知道 Eclipse 和 Netbeans 都有类似的内置检测方法,但这是 FindBugs 的特定问题。

If you are using Findbugs for compiled code inspection, is it possible to fail a build based on the result of a single detector or category of detectors?

For example, I would like to ensure that I don't have any null pointer-related detections (prefix of "NP" in this list) of any priority. Likewise, we really don't want to have any wait not in loop situations. That said, I don't necessarily want to fail a build based on internationalization detections as those aren't immediately critical to our application.

The desired end-state would be a process that we could tune for a variety of development phases ranging from the IDE level (Eclipse and Netbeans) to the release level (builds are generated using CruiseControl).

NOTE: I am aware that Eclipse and Netbeans both have similar detection methods built-in but this is a FindBugs specific question.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

や莫失莫忘 2024-10-10 08:13:38

使用 Ant 任务查找 Bug 部分

includeFilter

可选属性。它指定过滤器的文件名,指定报告哪些错误。请参阅第 8 章,过滤文件

从第 8 章开始:

但是,过滤器也可用于选择要专门报告的错误实例:

$ findbugs -textui -include myIncludeFilter.xml myApp.jar

  1. 通过指定缩写来匹配所有类中的某些测试。
 <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 之类的值code> 用于常规构建,test 用于 CI 构建,deploy 用于部署构建,并指定您希望在每个阶段看到或不希望看到的特定警告。

希望有帮助。

From the 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.

From Chapter 8:

However, a filter could also be used to select bug instances to specifically report:

$ findbugs -textui -include myIncludeFilter.xml myApp.jar

and

  1. Match certain tests from all classes by specifying their abbreviations.
 <Match>
     <Bug code="DE,UrF,SIC" />
 </Match></pre>

So I would assume something along the lines of:

<Match>
    <Bug code="Wa,NP" />
</Match>

In your include filter and

<findbugs includeFilter="path/to/includefilter.xml"...

Would be what you're looking for.

The path/to /includeFilter (or excludeFilter) could be a property that gets set based on the value of another property which could default to something like dev for regular builds, test for CI builds, and deploy for deployment builds and specify which specific warnings you want to see or don't want to see at each stage.

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文