如何排除特定 findbugs 规则的包
How do I exclude a package for a specific findbugs rule
我尝试了几次迭代,但这是我最新的
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Package name="~com[.]xenoterracide[.]rpf[.]([.].*)?"/>
<Bug code="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
</Match>
</FindBugsFilter>
最终我希望所有包都匹配(glob 语法)
com.xenoterracide.rpf.*.ui
或者只是 com.xenoterracide.rpf.*
INFO] The field com.xenoterracide.rpf.character.ui.CharactersView.editDialog is transient but isn't set by deserialization [com.xenoterracide.rpf.character.ui.CharactersView] In CharactersView.java SE_TRANSIENT_FIELD_NOT_RESTORED
[INFO] The field com.xenoterracide.rpf.character.ui.CharactersView.messenger is transient but isn't set by deserialization [com.xenoterracide.rpf.character.ui.CharactersView] In CharactersView.java SE_TRANSIENT_FIELD_NOT_RESTORED
[INFO] The field com.xenoterracide.rpf.character.ui.CharactersView.repo is transient but isn't set by deserialization [com.xenoterracide.rpf.character.ui.CharactersView] In CharactersView.java SE_TRANSIENT_FIELD_NOT_RESTORED
[INFO] The field com.xenoterracide.rpf.ui.NavigationBar.messages is transient but isn't set by deserialization [com.xenoterracide.rpf.ui.NavigationBar] In NavigationBar.java SE_TRANSIENT_FIELD_NOT_RESTORED
[INFO] The field com.xenoterracide.rpf.ui.components.EditDialog.repository is transient but isn't set by deserialization [com.xenoterracide.rpf.ui.components.EditDialog] In EditDialog.java SE_TRANSIENT_FIELD_NOT_RESTORED
[INFO]
父配置
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.3</version>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<xmlOutput>false</xmlOutput>
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
</configuration>
<executions>
<execution>
<phase>test-compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
这有效,但相当冗长且无法扩展
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Class name="com.xenoterracide.rpf.character.ui.CharactersView"/>
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
</Match>
<Match>
<Class name="com.xenoterracide.rpf.character.ui.CharacterEditDialog"/>
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
</Match>
<Match>
<Class name="com.xenoterracide.rpf.ui.NavigationBar"/>
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
</Match>
<Match>
<Class name="com.xenoterracide.rpf.ui.components.EditDialog"/>
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
</Match>
</FindBugsFilter>
试试这个:
<Package name="com\.xenoterracide\.rpf\.\*(\.ui)?"/>
更新:即使我从你的 "syntax" 开始,这也会更有意义:
<Package name="~com[.]xenoterracide[.]rpf[.][*]([.]ui)?"/>
这有效,并且匹配所有 5 类
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Package name="~com\.xenoterracide\.rpf[.a-zA-Z0-9]*\.ui.*"/>
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
</Match>
</FindBugsFilter>
我尝试了几次迭代,但这是我最新的
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Package name="~com[.]xenoterracide[.]rpf[.]([.].*)?"/>
<Bug code="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
</Match>
</FindBugsFilter>
最终我希望所有包都匹配(glob 语法)
com.xenoterracide.rpf.*.ui
或者只是 com.xenoterracide.rpf.*
INFO] The field com.xenoterracide.rpf.character.ui.CharactersView.editDialog is transient but isn't set by deserialization [com.xenoterracide.rpf.character.ui.CharactersView] In CharactersView.java SE_TRANSIENT_FIELD_NOT_RESTORED
[INFO] The field com.xenoterracide.rpf.character.ui.CharactersView.messenger is transient but isn't set by deserialization [com.xenoterracide.rpf.character.ui.CharactersView] In CharactersView.java SE_TRANSIENT_FIELD_NOT_RESTORED
[INFO] The field com.xenoterracide.rpf.character.ui.CharactersView.repo is transient but isn't set by deserialization [com.xenoterracide.rpf.character.ui.CharactersView] In CharactersView.java SE_TRANSIENT_FIELD_NOT_RESTORED
[INFO] The field com.xenoterracide.rpf.ui.NavigationBar.messages is transient but isn't set by deserialization [com.xenoterracide.rpf.ui.NavigationBar] In NavigationBar.java SE_TRANSIENT_FIELD_NOT_RESTORED
[INFO] The field com.xenoterracide.rpf.ui.components.EditDialog.repository is transient but isn't set by deserialization [com.xenoterracide.rpf.ui.components.EditDialog] In EditDialog.java SE_TRANSIENT_FIELD_NOT_RESTORED
[INFO]
父配置
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.3</version>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<xmlOutput>false</xmlOutput>
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
</configuration>
<executions>
<execution>
<phase>test-compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
这有效,但相当冗长且无法扩展
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Class name="com.xenoterracide.rpf.character.ui.CharactersView"/>
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
</Match>
<Match>
<Class name="com.xenoterracide.rpf.character.ui.CharacterEditDialog"/>
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
</Match>
<Match>
<Class name="com.xenoterracide.rpf.ui.NavigationBar"/>
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
</Match>
<Match>
<Class name="com.xenoterracide.rpf.ui.components.EditDialog"/>
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
</Match>
</FindBugsFilter>
试试这个:
<Package name="com\.xenoterracide\.rpf\.\*(\.ui)?"/>
更新:即使我从你的 "syntax" 开始,这也会更有意义:
<Package name="~com[.]xenoterracide[.]rpf[.][*]([.]ui)?"/>
这有效,并且匹配所有 5 类
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Package name="~com\.xenoterracide\.rpf[.a-zA-Z0-9]*\.ui.*"/>
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
</Match>
</FindBugsFilter>