-
Notifications
You must be signed in to change notification settings - Fork 187
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: Redundant nullcheck #160
Comments
toSting() should never return null. |
@iloveeclipse , you asume any third-party API class method dont return null |
Yes, I assume that no one in the world should ever return |
But this rule is applicable for every variable, not only the return of toString(). This assumption fails my code every time when check variables depends on third-party API methods. My you what to add rules for null return in toString :-p |
Please note, that this project is dead. If you want to contribute something, please do it via https://github.com/spotbugs/spotbugs. |
I have a generic type as follows, which calls
.toString()
on an instance of the parameter type.FindBugs gives a
RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE
warning on the null check ofstring
, saying that it is "a known non-null value". However, this can be trivially show to be incorrect, as the following code demonstrates.If
Simple.toString()
did not have the null check onstring
, and return an alternate non-null value, then we would get an NPE thrown when calling.length()
. Since_raw
is of the unknown typeT
, FindBugs should not treat_raw.toString()
as "a known non-null value".The text was updated successfully, but these errors were encountered: