java - SuppressWarnings not working on FindBugs -


i ran findbugs on eclipse project , got potential bug warning suppress specific reason (outside context of question). here's code:

public class logitem {     private string name;      private void setname(final string nm) {         name = nm;     } } 

when run findbugs on class gives warning on name = nm assignment operation, stating: unread field: com.me.myorg.logitem.name.

so tried adding this:

    private void setname(final string nm) {         @edu.umd.cs.findbugs.annotations.suppresswarnings(value = "np", justification = "because can")         name = nm;     } 

when syntax (compile) error in eclipse, stating:

duplicate local variable nm; name cannot resolved type.

so tried adding findbugs' suppresswarnings on field itself, after re-running findbugs on class, findbugs still complaining same line of code , same reason. tried adding suppresswarnings setname method, , still no difference.

how (exactly!) use annotation quiet findbugs?!?

put annotation on field , fix bug identifier. works me:

public class logitem {     @edu.umd.cs.findbugs.annotations.suppresswarnings("urf_unread_field")     private string name; 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -