Overview
Since Spring Framework 5.0 (see #20099), we annotate packages in package-info.java
files with null-safety annotations such as @NonNullApi
; however, not all packages contain package-info.java
files which prevents us from enforcing non-null semantics by default for those packages.
Scope
This applies to all packages within src/main
. Conversely, this does not apply to packages in src/test
.
Deliverables
- [x] Configure the
JavadocPackage
Checkstyle module to requirepackage-info.java
files for all packages undersrc/main
. - [x] Determine if it is possible to require that
package-info.java
files include null-safety annotations – for example, via Checkstyle. - [x] If it's possible to require that
package-info.java
files include null-safety annotations, configure the necessary infrastructure. - [x] Introduce missing
package-info.java
files with package-level Javadoc and null-safety annotations.
Comment From: edyda99
Hi @sbrannen , this task seems to be straightforward, I would appreciate it if you allow me to do it. Thank you
Comment From: sbrannen
Hi @edyda99,
this task seems to be straightforward
Indeed it does seem rather straightforward; however, it may end up being more work than you'd expect.
I have updated the title and description of this issue to reflect the scope and expected deliverables.
I would appreciate it if you allow me to do it.
Please review the updated scope and deliverables.
If you're still up to the task, please let me know and I'll assign it to you.
Ideally, we'd like to address this before 6.0.7. So please keep that in mind.
Comment From: edyda99
Hi, first thank you a lot for giving me the opportunity.
Second I spent these two hours doing some readings to know more about this subject.
- As it seems to me that the initial point requires
<module name="JavadocPackage">
<property name="severity" value="warning"/>
</module>
-
Regarding 'applies to all packages within src/main' There is no direct property to add to the module, there is a property 'baseDir' but it would be applied to all the modules. So I need to use filters to suppress warnings to directories other than src/main
-
Regarding nullSafety I found a documentation about RegexpSinglelineJava, which may help me.
-
And finally, regarding the last point, It needs mainly time more than skills.
Please correct me if I said anything wrong.
I will dedicate this week to this task if you allow me and will push on a daily basis so you can track my progress.
Again thank you!
Comment From: edyda99
This is my pull request: https://github.com/spring-projects/spring-framework/pull/30069
Comment From: edyda99
@sbrannen My mr is ready for your comments.
I haven't done yet the last step, as I am stuck in choosing which is the best way to check null-safety annotations
My first solution was RegexpSinglelineJavaCheck but it has one limitation by checking null-safe annotations made up of multiple lines for example
@\n
NonNull
The second option is: RegexpMultiline which has one limitation that it won't be able to check if the annotation is commented or not
These two options are available in my commit, I am waiting for your advice. (One remaining option is to use a complex regex with RegexpMultiline that satisfies the following: if a commented block is declared it should be before any annotation)
Thank you a lot
Comment From: sbrannen
- superseded by #30069