0

我可以*.kt使用排除文件

<plugin>
    <groupId>com.github.spotbugs</groupId>
    <artifactId>spotbugs-maven-plugin</artifactId>
    <configuration>
        <excludeFilterFile>spotbugs-exclude-filter.xml</excludeFilterFile>
    </configuration>
</plugin>

spotbugs-exclude-filter.xml包含:

<FindBugsFilter>
    <Match>
        <Source name="~.*\.kt"/>
    </Match>
</FindBugsFilter> 

但是,由于 spotbugs 在父 pom 中(Java 和 Kotlin 项目都使用),我更喜欢纯 maven 解决方案,因此继承项目不需要额外的 xml 文件。可能吗?

4

2 回答 2

0

在插件的配置中includeFilterFile使用excludeFilterFile

并将模式从 更改"~.*\.kt""~.*Kt\.java"

于 2020-10-23T08:07:46.560 回答
0

SpotBugs 假设代码是从 Java 类编译的(即使类文件可能具有正确的文件名)。如果您查看 SpotBugs XML 报告文件,您将看到根据 SpotBugs 的源文件。为了排除 Kotlin 类,您必须执行以下操作,因为 Kotlin 编译为XxxxxxKt.class

<FindBugsFilter>
    <Match>
        <Source name="~.*Kt\.java"/>
    </Match>
</FindBugsFilter>
于 2019-03-19T15:44:14.223 回答