The Java analyzer is more accurate on Java Nullability

Hi Java developers,

We well understand that the Nullability in Java is a concern.

Therefore I am very happy to announce that we successfully reworked all our existing rules regarding Nullability to improve their accuracy. We also updated the associated issue messages to facilitate the understanding of the issue:

  • S2638: Method overrides should not change contracts
  • S2789: “null” should not be used with “Optional”
  • S4682: “@CheckForNull” or “@Nullable” should not be used on primitive types
  • S2637: “@NonNull” values should not be set to null
  • S4454: “equals” method parameters should not be marked “@Nonnull
  • S2447: Null should not be returned from a “Boolean” method
  • S1168: Empty arrays and collections should be returned instead of null
  • S4449: Nullness of parameters should be guaranteed
  • S2259: Null pointers should not be dereferenced

This is available now on SonarCloud and will come with SonarQube 9.3.