Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I exclude a package for a specific findbugs rule

I've tried several iterations, but here's my latest

<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
  <Match>
    <Package name="~com[.]xenoterracide[.]rpf[.]([.].*)?"/>
    <Bug code="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
  </Match>
</FindBugsFilter>

ultimately I'd like to get all packages matching (glob syntax)

com.xenoterracide.rpf.*.ui or maybe just 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]

config in parent

  <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>

This, works, but is rather verbose and won't scale

<?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>
like image 913
xenoterracide Avatar asked Jan 24 '16 21:01

xenoterracide


1 Answers

this works, and matches all 5 classes

<?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>
like image 188
xenoterracide Avatar answered Oct 02 '22 20:10

xenoterracide