gpt4 book ai didi

maven - 如何配置 SpotBugs maven 插件以创建完整报告但仅检查高阈值?

转载 作者:行者123 更新时间:2023-12-05 07:33:01 26 4
gpt4 key购买 nike

我有一个遗留的 maven 项目,想集成 FindBugs 继任者 SpotBugs 来创建所有问题的报告,但如果存在 High 仅限优先问题(目前)。

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

我已尝试根据 documentation 配置插件但没有成功:

<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。

最佳答案

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

我有一个类似的案例,我所做的是将配置放在“reporting”标签中(不是 reportSets)。在“构建”标签中,我只是放置了插件信息和依赖项。配置使用输出 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,其中包含过滤后的错误列表。

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

这有意义吗?

关于maven - 如何配置 SpotBugs maven 插件以创建完整报告但仅检查高阈值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50823305/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com