1

我正在使用此插件运行 findbugs 和 maven,然后构建失败,即使我通过 Eclipse 运行最大设置为 20 的查找错误,我得到 0 个错误。现在它以 33 失败。

 <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>findbugs-maven-plugin</artifactId>
    <version>2.0.1</version>
    <configuration>
      <threshold>Ignore</threshold>
      <xmlOutput>true</xmlOutput>
    </configuration>
    <executions>
      <execution>
        <phase>verify</phase> 
        <goals>
          <goal>check</goal> 
        </goals>
      </execution>
    </executions>
  </plugin>

两个问题:

为什么 Eclipse Findbugs 插件和 Maven Findbugs 插件之间存在如此差异?

我能否以某种方式让 Eclipse Findbugs 加载从 Maven Findbugs 生成的 findbugscheck.xml,以便我的代码自动突出显示。通过xml文件钓鱼非常烦人。

4

1 回答 1

1

Eclipse Findbugs 插件和 findbugs-maven-plugin 之间的差异可能是由于这两个产品使用不同版本的 Findbugs 实用程序。这些产品中的每一个都运行 FindBugs 实用程序(在此处找到),然后解析实用程序的输出并显示结果。findbugs-maven-plugin-2.0.1 基于 Findbugs 1.3.8。我不能说你的 Eclipse 插件基于哪个版本的 Findbugs。

Findbugs 实用程序支持一些可以影响结果的命令行选项(例如 -effort:max、-effort:min)。Eclipse Findbugs 插件和 findbugs-maven-plugin 可能提供不同的命令行选项,导致结果不一致。如果它们都为这些命令行选项提供配置,则可以消除这种差异。

Eclipse Findbugs 插件在 Eclipse 内的插件视图中提供了一些过滤结果。过滤可以在插件的视图中作为工具栏图标访问(不是 100% 确定它的位置,因为我目前不在我的开发框中)。

此外,来自 Findbugs网站

“FindBugs 支持插件架构,允许任何人添加新的错误检测器。”

这可能意味着 Eclipse 插件已经插入了其他错误检测器,但我不知道是不是这种情况,这只是一种需要指出的可能性。我从来没有找到让 Ecipe Findbugs 插件从 maven 构建中加载 findbugscheck.xml 的方法。

ETA:您可以尝试运行Findbugs GUI并使用它来加载和查看结果,而不是手动搜索 findbugs 结果 xml。

于 2012-01-19T03:17:33.317 回答