3

我有一个遗留的 maven 项目,并希望集成FindBugs继任者SpotBugs以创建所有问题的报告,但如果仅存在优先级问题(目前)则失败。

很容易只创建报告而不会失败在特定阈值上失败。但是,当指定阈值时,所有低于该阈值的问题也会从报告中删除。

我试图根据文档配置插件但没有成功:

<plugin>
  <groupId>com.github.spotbugs</groupId>
  <artifactId>spotbugs-maven-plugin</artifactId>
  <version>3.1.3</version>
  <configuration>
    <effort>Max</effort>
    <threshold>High</threshold>
    <xmlOutput>true</xmlOutput>
    <spotbugsXmlOutputDirectory>${project.build.directory}/spotbugs-reports</spotbugsXmlOutputDirectory>
    <xmlOutputDirectory>${project.build.directory}/spotbugs-reports</xmlOutputDirectory>
    </configuration>
    <executions>
      <execution>
        <goals>
          <goal>check</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

我正在使用 Maven 3 和 SpotBugs 3.1.3。

4

1 回答 1

0

不确定这是否有帮助,这主要是一种解决方法。

我有一个类似的案例,我所做的是将配置放在“报告”标签(而不是 reportSets)中。在“build”标签中,我只是放置了插件信息和依赖项。配置使用输出 xml 和输出文件夹的默认值。我还添加了过滤掉一些错误的文件:

<build>
        <plugins>
            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <version>3.1.10</version>
                <dependencies>
                    <dependency>
                        <groupId>com.github.spotbugs</groupId>
                        <artifactId>spotbugs</artifactId>
                        <version>3.1.11</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <version>3.1.10</version>
                <configuration>
                    <excludeFilterFile>spotbugs_filter.xml</excludeFilterFile>
                </configuration>
            </plugin>
        </plugins>
    </reporting>

然后我做了一个

mvn clean install site spotbugs:check

这给了我:

  • build_directory 中的一个 spotbugsXml.xml 文件,其中包含找到的所有错误(未应用过滤器)。
  • 在目标/站点中生成了一个报告 spotbugs.html,其中包含过滤的错误列表。

因此,为了将此与您的问题联系起来,我想使用这些“步骤”您可以得到两份报告,一份有阈值,另一份没有。

这有意义吗?

于 2019-03-04T12:10:31.223 回答