-
Notifications
You must be signed in to change notification settings - Fork 774
Open
Description
Problem
There is an experimental AddNullMarkedToPackageInfo bug pattern which reports package-info.java files which do not have @NullMarked applied to them.
It does help detect the issue of forgetting to add @NullMarked to the package, but in our experience a more common problem is forgetting to create package-info itself and thus marking it with @NullMarked which is currently not caught by the checker.
Solution
The suggestion is to also handle this scenario, probably also allowing the package to be explicitly @NullUnmarked so that there still is an escape hatch for unannotated packages.
Pseudo-code
Currently:
if (thePackage.exists()) {
if (!thePackage.isAnnotated(NullMarked.class)) {
reportError("No @NullMarked on packages %s", thePackage);
}
}Suggested:
if (thePackage.exists()) {
if (!thePackage.isAnnotated(NullMarked.class)
&& !thePackage.isAnnotated(NullUnmarked.class)) {
reportError("No @NullMarked or @NullUnmarked on packages %s", thePackage);
}
} else {
reportError("No package info %s", thePackage);
}PhilippWendler and cushon
Metadata
Metadata
Assignees
Labels
No labels