-
Notifications
You must be signed in to change notification settings - Fork 611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
False positive about the rule NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT #2558
Comments
I find that public class Test {
public boolean equals(@lombok.NonNull Object a) { //report a warning, but it is an FP
return a.hashCode() == this.hashCode();
}
} |
gtoison
added a commit
to gtoison/spotbugs
that referenced
this issue
Nov 10, 2023
hazendaz
pushed a commit
that referenced
this issue
Mar 1, 2024
* test: reproducer for issue #2558 * Recognize more nullability annotations * fix: added back check for Eclipse's NonNullByDefault * fix: made eclipseNonNullByDefault a field again since used externally * fix: with the other changes the smoke tests flag that field as NonNull LogicalLocation.properties should be annotated NonNull * doc: added changelog entry * fix: updated the comment now that the false positive is fixed
PatrikScully
pushed a commit
to PatrikScully/spotbugs
that referenced
this issue
Jun 14, 2024
* test: reproducer for issue spotbugs#2558 * Recognize more nullability annotations * fix: added back check for Eclipse's NonNullByDefault * fix: made eclipseNonNullByDefault a field again since used externally * fix: with the other changes the smoke tests flag that field as NonNull LogicalLocation.properties should be annotated NonNull * doc: added changelog entry * fix: updated the comment now that the false positive is fixed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version: 4.7.3
I found a false positive about the rule NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT.
In the example below, SpotBugs reports no warning. The
equals
method takes a parameter that is marked as@javax.annotation.Nonnull
. So it obeys this rule correctly.However, in the example below, SpotBugs reports a warning at line 3 if we use
@org.netbeans.api.annotations.common.NonNull
instead. Actually,@javax.annotation.Nonnull
and@org.netbeans.api.annotations.common.NonNull
are equivalent. So, this exmaple does not violate the rule NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT and the warning is a false positive.I use the cmd
spotbugs -textui -low -xml -output= report.xml -auxclasspath org.eclipse.jdt.annotation-2.2.700.jar Test.class
The text was updated successfully, but these errors were encountered: