![](/img/trans.png)
[英]How do i run findbugs on specific package ignore other packages in eclipse
[英]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>
這工作,並匹配所有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>
嘗試這個:
<Package name="com\.xenoterracide\.rpf\.\*(\.ui)?"/>
更新:即使我從你的“語法”開始,這將更有意義:
<Package name="~com[.]xenoterracide[.]rpf[.][*]([.]ui)?"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.