-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify interactions between settings for generated code, restrictive annotations, etc. #978
Comments
An initial proposal here:
Thoughts? Hoping someone can come up with better names 😅 |
(Anecdotally, "is this code generated" has been something that has repeatedly been useful to know the answer for in other analysis tools, so I wouldn't go out of my way to remove that semantic knowledge from NullAway, assuming the use case is still exclusively generated code vs the many other ways we have to specify unmarked code) |
I like
So this setting currently means two things:
(I.e., the previous default meaning of "unannotated".) Do we think it's reasonable to have a setting
I agree. One thing I am trying to accomplish, though, is to make the custom |
Historically, NullAway has had settings for "annotated" vs "unannotated" packages and classes. Annotated code is assumed to be annotated according to NullAway's conventions. For unannotated code, we make no such assumption, and further, by default we completely ignore any annotations present in that code. This default can be changed via the
AcknowledgeRestrictiveAnnotations
setting; when provided, this setting causes@Nullable
annotations on return types and@NonNull
annotations on parameter types to be acknowledged even within unannotated code.NullAway also has a setting
TreatGeneratedAsUnannotated
which causes all code within a@Generated
annotation (or any custom generated code annotation) to be treated as unannotated. Crucially (and non-obviously), if bothTreatGeneratedAsUnannotated
andAcknowledgeRestrictiveAnnotations
are passed, restrictive annotations in generated code are still not acknowledged. OurTreatGeneratedAsUnannotated
setting is rather coarse, and in trying to make it more flexible, I ran into this subtle interaction that I hadn't recalled.Also, NullAway now supports
@NullMarked
and@NullUnmarked
annotations.@NullMarked
is equivalent to "annotated" (I think), whereas@NullUnmarked
corresponds to "unannotated" with theAcknowledgeRestrictiveAnnotations
setting enabled. There is no standard null-markedness setting that corresponds to our default "unannotated" config, where all annotations are ignored.So what is the point of this issue?
AcknowledgeRestrictiveAnnotations
should be on by default, with a setting to disable it? This way, "unannotated" and@NullUnmarked
would be equivalent out of the box, modulo generated code.AcknowledgeRestrictiveAnnotations
andTreatGeneratedAsUnannotated
; maybe we can do better?The text was updated successfully, but these errors were encountered: