I'm getting what I think are false positives from FindBugs (2.0.2) and Sonar (3.7.3) on code that is being generated via static weaving of EclipseLink (2.5.1) JPA entities. Specifically, I am seeing multiple occurrences of
ES_COMPARING_PARAMETER_STRING_WITH_EQ
Comparison of String parameter using == or != in com.test.domain.MyEntity._persistence_set(String, Object)
and
URV_INHERITED_METHOD_WITH_RELATED_TYPES
Inherited method com.test.domain.MyEntity._persistence_get(String) returns more specific type of object than declared
Is there a way to eliminate these warnings for the code generated by EclipseLink without having to globally disable the rules or exclude analysis on the entities entirely?
Very good question! Since your issues originate with FindBugs, you can use FindBugs exclusion filters to address this. Especially, take a look at the <Method>
exclusion. You can specify a regex that matches the method names of your getters and setters in the entity classes, such as
<Method name="~_persistence_[gs]et" />
Such a filter file can be used by all forms of FindBugs, including the Eclipse plugin and SonarQube. For example, using the SonarQube ant task, you can set the property sonar.findbugs.excludesFilters
to the absolute path to the FindBugs exclusion file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With