Hi,
sorry, but I strongly disagree. Let me explain.
There's no way to statically enforce that a @Nonnull parameter cannot be null, especially not in public methods of framework libraries. While a value
should not be null, the documented API contract can still be violated at runtime. Additional safeguards are a good thing for non-private methods.
This is not only my personal opinion, see for example this Oracle blog post, which says "Optional Type Annotations are not a substitute for runtime validation"
https://blogs.oracle.com/java-platform-group/java-8s-new-type-annotationsWhile it's not necessary to have null checks in all methods that use the values right away, they're important in public API setters and constructors which just store the values. If you don't check input values here, nullability problem can propagate badly. Read "Item 38: Check parameters for validity" of J. Bloch's book Effective Java, 2nd ed.: "It is particularly important to check the validity of parameters that are not used by a method but are stored away for later use."
Nullable annotations are not only for tools, they also serve as API documentation for humans. They're a great way to improve API documentation. With your decision to forbid runtime-checks, you're basically saying that these annotations cannot be used in public framework methods.
Please, please, revisit your decision. Or would you even forbid the semantically equivalent call to "requireNonNull" in a future version? I hope not.
If you still disagree, let's at least treat this as a "controversial rule" and move it out of the useful rules S2583 and S2589. According to this post you don't want to enable controversial rules by default:
https://groups.google.com/d/msg/sonarqube/DFPXz2PrToE/ABn_8_viAwAJUsing "Won't Fix" (or @SuppressWarnings in code) at every such issue is not an option in a large existing code base. And it's problematic for large development teams, because an active rule would misguide inexperienced developers. It's important to provide sane defaults.
Thank you,
Andreas