gpt4 book ai didi

java - SpotBugs Maven 插件排除目录

转载 作者:搜寻专家 更新时间:2023-10-31 20:16:55 29 4
gpt4 key购买 nike

我使用 SpotBugs Maven Plugin进行静态分析,我想从检查中排除一个目录。查看 spotbugs:check goal documentation , 似乎不可能配置插件是这样的方式。我还检查了 SpotBugs 的文档 filter file .

在 Apache Maven PMD 插件中,这可以通过使用 excludeRoots 来完成。参数:

<excludeRoots>
<excludeRoot>target</excludeRoot>
</excludeRoots>

是否可以从 SpotBugs 检查中排除一个目录?

最佳答案

可以使用 SpotBugs 从检查中排除一个目录,尽管该方法与您为 PMD 描述的方法不同。这是一个两步过程:

  1. 第一个 create an XML filter file指定要排除的目录的条件。

  2. 然后,在 pom.xml 中使用可选的 <excludeFilterFile> 引用该文件环境。不幸的是,the documentation for that setting非常简短。

举个简单的例子:

  1. 创建一个名为 ignore.xml 的过滤器文件,其中包含引用名为 mydir 的目录的以下内容:

     <?xml version="1.0" encoding="UTF-8"?>
    <FindBugsFilter>
    <Match>
    <Source name="~mydir\..*"/>
    </Match>
    </FindBugsFilter>

    the <Source> tag is here 的文档.请参阅有关 Java element name matching 的部分有关如何指定 <Source>名称 的详细信息.

  2. 然后在 pom.xmlspotbugs-maven-plugin 规范中,包含一个 <excludeFilterFile>标记,以便 SpotBugs 忽略 mydir:

     <configuration>
    <excludeFilterFile>ignore.xml</excludeFilterFile>
    </configuration>

注意事项:

  • 还有一个 <includeFilterFile>标签。请参阅 the usage documentation 中标题为指定要运行的错误过滤器的部分。 .

  • 以及Source , SpotBugs 提供了几种其他方法来指定要包含或排除检查的代码。请参阅 Package 的过滤器文件文档, Class , Method , Local , FieldType标签。

  • 将您的 <excludeFilterFile>在项目的根目录中。

关于java - SpotBugs Maven 插件排除目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52336795/

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