jooby-project / jooby

The modular web framework for Java and Kotlin
https://jooby.io
Apache License 2.0
1.7k stars 199 forks source link

Maybe consider using package-info.java for default nonnull returns #3459

Closed agentgt closed 3 months ago

agentgt commented 3 months ago

Jooby does not have package-info.java and I noticed this when I did the upgrade of findbugs to spotbugs for the modularization in 3.0.

If we add package-info.java to all the packages then we can add the annotation:

edu.umd.cs.findbugs.annotations.ReturnValuesAreNonnullByDefault to the packages themselves (there are also a bunch of ones called DefaultXXX where you set the default annotation but in practice I find the null analysis tool don't work as well with those).

This will make the return values default to @NonNull if no annotation is present. This should work fine with Kotlin.

See #3458 (this is why Spring does not have the @NonNull annotations on return as they use something similar to the above).

Also package-info.java makes javadoc look prettier.