Adding exclusive filter for <static initializer> in findbugs

Posted by MilanAleksic on Stack Overflow See other posts from Stack Overflow or by MilanAleksic
Published on 2010-05-11T16:57:09Z Indexed on 2010/05/11 20:24 UTC
Read the original article Hit count: 283

Filed under:
|
|

Hi all, I want my findbugs report not show the following error:

DM_NUMBER_CTOR: Method invokes inefficient Number constructor; use static valueOf instead

The problem is that this happens in groovy-generated code files, so I can't control the source code - that is why I want to exclude it and add it to my exclude filter.

I do not want to add explicitly class (since I make API that many tools will use, I want my filter to be generic). I would not like to completely remove this bug from the report by type, I would really like to only exclude this bug from appearing if it happenned in "static initializer" methods. Any idea? I tried the filter below but no luck, maybe somebody has better idea?

<Match>
    <Method name="~.*static initializer.*" />
    <Bug pattern="DM_NUMBER_CTOR" />
</Match>

Here is the "stacktrace" of FindBugs in that case:

In class net.milanaleksic.cuc.tools.sound.SoundPlayerTool In method net.milanaleksic.cuc.tools.sound.SoundPlayerTool.() Called method new Long(long) Should call Long.valueOf(long) instead In SoundPlayerTool.groovy

© Stack Overflow or respective owner

Related posts about java

Related posts about groovy