Check overall for Nonnull in Sonar using JSR305?

51 views Asked by At

I would like to check for possible null parameters, variables and return objects in Sonar. The Sonar we use do not support the jakarta annotations but it does support JSR305 javax annotations.

I could add @Nonnull annotations everywhere but that seems like a lot of boiler plate coding.

I could create a package-info.java file:

@ParametersAreNonnullByDefault
package my.base.package;

import javax.annotation.ParametersAreNonnullByDefault;

And then only do explicit @Nullable where it is required.

But the package-info does not work for subpackages.

I come accross another stackoverlow article from 7 years ago where a gradle script is used to duplicate the package-info.java files in every single directory that contains a java file.

This seems so much boiler plate again with files that I do not really want to see.

Is there no better way to do this?

0

There are 0 answers