Skip to content
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

NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE false positive when code is formatted on different lines #2874

Merged
merged 6 commits into from Feb 28, 2024

Conversation

gtoison
Copy link
Contributor

@gtoison gtoison commented Feb 24, 2024

As noted in #782 calls such as checkNotNull(get()); are correctly analyzed but when formatting on different lines they are not:

        Object c = checkNotNull(
                get()); // false positive

Objects.requireNonNull is correctly recognized since #2709 was merged

Concerning javax.annotation.Nullable its nullability is @Nonnull(when = When.UNKNOWN), my understanding is that this explains why it is ignored here. On the other end, the custom annotation from the sample is @Nonnull(when = When.MAYBE) so it is considered and flagged accordingly

@nullable is @nonnull(when = When.UNKNOWN) so it seems OK that we're not
reporting a bug (i.e. some of the cases do not seem to be false
negatives)
@gtoison gtoison marked this pull request as ready for review February 26, 2024 20:23
@hazendaz hazendaz self-assigned this Feb 28, 2024
@hazendaz hazendaz merged commit d41aa64 into spotbugs:master Feb 28, 2024
15 checks passed
@hazendaz hazendaz added this to the SpotBugs 4.8.4 milestone Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants