You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Write a unit test that scans the parameters of methods and constructors, and the return value of methods and that reports any that don't have @NotNull or @Nullable.
To do
Add org.reflections as a test dependency
Write a test that collects all classes of ConfigMe
Skip classes that end in "Test"
Collect all method/constructor params and method return values
Report all instances where neither nullability annotation is used
Special case arrays: T @NotNull [] is how the array itself is reported not null. Probably should also check the component if possible?
Begs the question what to do with other generic types such as List<String> (vs. List<@NotNull String>)...?
The text was updated successfully, but these errors were encountered:
@NotNull and @Nullable have SOURCE retention, so need to use org.reflections or javassist to pick out the values
org.reflections has no way of returning whether a specific method parameter has an annotation
javassist has a bug where it thinks @Foo String[] means the array is annotated, while it's supposed to be String @Foo []. This leads to a lot of false positives.
- One problem is that javassist does not recognize `String @nullable []` as the annotation being for the whole type, leading to a lot of false positives
Write a unit test that scans the parameters of methods and constructors, and the return value of methods and that reports any that don't have
@NotNull
or@Nullable
.To do
T @NotNull []
is how the array itself is reported not null. Probably should also check the component if possible?List<String>
(vs.List<@NotNull String>
)...?The text was updated successfully, but these errors were encountered: