Search code examples
javafindbugs

How to exclude a constructor in findbugs?


I can exclude a regular method like this in my findbugs-exclude.xml:

<Match>
    <Class name="com.my.package.MyClass"/>
    <Method name="calculateSomeValue"/>
    <Bug pattern="CLI_CONSTANT_LIST_INDEX"/>
</Match>

But what if I want to ignore the bug pattern being flagged in a constructor?

I've tried

<Method name="MyClass"/>

and

<Method name="new"/>

which don't seem to work.

MyClass only defines one constructor.


Solution

  • You have to use this code for exclude constructor:

    <Method name="&lt;init&gt;"/>