Julian
Julian

Reputation: 4055

Findbugs exclude generated files

I am trying to filter out the generated files from the findbugs check and all I tried does not seem to work. Pretty much part of my build process I create a whole lot of classes that end up in a folder called src/generated I would be interested in filtering out all those classes. I am using maven but I don't think it matters.

Thank you in advance.

Upvotes: 12

Views: 11698

Answers (2)

Dave Newton
Dave Newton

Reputation: 160191

Without knowing what you tried it's a bit problematic to help.

Here's a fragment we use to skip over a few bug patterns present in code generated by Avro.

<FindBugsFilter>
  <Match>
    <!-- Avro generates redundant "implements" interface declarations -->
    <Or>
      <Package name="~com[.]foo[.]plugh[.]avro([.].*)?"     />
      <Package name="~com[.]foo[.]xyzzy[.]protocol([.].*)?" />
    </Or>

    <Or>
      <Bug pattern="RI_REDUNDANT_INTERFACES" />
      <Bug pattern="NM_CLASS_NAMING_CONVENTION" />
      <Bug pattern="REC_CATCH_EXCEPTION" />
    </Or>
  </Match>
</FindBugsFilter>

Upvotes: 2

user944849
user944849

Reputation: 14951

Here's how using the Codehaus findbugs-maven-plugin. You include the packages you DO want to analyze, instead of excluding those you don't.

<reporting>
    <plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>2.5.2</version>
        <configuration>
            <onlyAnalyze>com.company.util.*,com.company.myapp.*</onlyAnalyze>
        </configuration>
    </plugin>
    </plugins>
</reporting>

Upvotes: 1

Related Questions