Garfield Garfield - 4 months ago 36
Java Question

DLS_DEAD_LOCAL_STORE SuppressWarnings FindBugs false positive

I'm trying to eliminate a false positive for DLS_DEAD_LOCAL_STORE

Here's what I have tried so far:

@SuppressWarnings("DLS_DEAD_LOCAL_STORE")


@edu.umd.cs.findbugs.annotations.SuppressWarnings("DLS_DEAD_LOCAL_STORE")


(based on SuppressWarnings not working on FindBugs)

@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "DLS_DEAD_LOCAL_STORE", justification = "please go away")


based on http://osdir.com/ml/java-findbugs-general/2010-06/msg00017.html

But none of the options is helping. Please advice.
Using Eclipse Indigo.

Answer

More Googling + Experimenting and I finally figured out a way to do this.

Check Section 6 under http://findbugs.sourceforge.net/manual/filter.html .

You need to create your own XML file with all the custom supressions in there. You'll then need let build.xml file know about this file via findbugs.exclude.filter

 <Match>
   <Class name="com.foobar.MyClass" />
   <Method name="someMethod" />
   <Bug pattern="DLS_DEAD_LOCAL_STORE" />
 </Match>

No need to add the @SuppressWarnings tag in the method once this is there in the XML.

Hope this helps someone!