我收到了SpotBugs警告,类字段的代码为“EI_EXPOSE_REP2”
private final LocalDate localDate
我试图排除java.util.LocalDate
类对整个应用程序的检查。
我试着使用注释@SuppressFBWarnings("EI_EXPOSE_REP2")
,它可以工作。但是对我来说,将这个注释添加到每个使用LocalDate
的地方并不是个好主意。相反,我更愿意将这条规则添加到Pointbugs-opende.xml中。我这样做了,但它不起作用(仍然收到SpotBugs警告)。我的检举错误-专营.file文件:
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Class name="java.time.LocalDate" />
<Bug code="EI_EXPOSE_REP2" />
</Match>
</FindBugsFilter>
pom.xml
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs.mavenplugin.version}</version>
<executions>
<execution>
<id>spotbugs-verify</id>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
</configuration>
</plugin>
那么,我的问题是:如何排除整个应用程序中特定类的SpotBugs检查?
更多的问题:我们能不能混淆同一个应用程序中的点缺陷--epitde.xml和注释@SuppressFBWarnings?SpotBugs能够识别这两种配置吗?
发布于 2021-07-27 08:22:11
我做了更多的调查,并在这里发现了类似的话题:https://github.com/spotbugs/spotbugs/issues/1601
因此,对于4.3.0版本,SpotBugs插件具有错误行为,可以检查不可变的类,并提供警告EI_EXPOSE_REP和EI_EXPOSE_REP2。
因此,我的决定是:从4.3.0迁移到4.2.3 --目前所有这些都能工作。
https://stackoverflow.com/questions/68539930
复制相似问题