Sunday 15 February 2015

java - Is there a way to ignore a single FindBugs warning? -


With PMD, if you want to ignore a specific warning, you can // NOPMD Can ignore that row.

Is there anything similar to searchbugs?

FindBugs initial approach XML configuration files include aka It is actually less convenient than PMD solutions But FindBugs works on bytecode, not on the source code, so the comments are not clearly an option. Example:

  & lt; Mail & gt; & Lt; Class name = "com.mycompany.Foo" /> & Lt; Method name = "bar" /> & Lt; Bug Pattern = "DLS_DEAD_STORE_OF_CLASS_LITERAL" /> & Lt; / Match & gt; However, to solve this problem, FindBugs has later submitted another solution (based on) that you can use in class or method level (more convenient than XML in my opinion). Example (probably not the best but, well, this is just an example):    @ edu.umd.cs.findbugs.annotations.SuppressWarnings (value = "HE_EQUALS_USE_HASHCODE", justification = "I know what I'm doing")  

Note that since FindBugs 3.0.0 SuppressWarnings to @SuppressFBWarnings The party has been deprecated in favor of Java with SuppressWarnings .


No comments:

Post a Comment