-
Notifications
You must be signed in to change notification settings - Fork 30
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
Specify @SuppressWarnings suppression strings relevant to analyses powered by our annotations #55
Comments
Thanks for bringing this up! In addition to If the group thinks |
For the Checker Framework, the relevant documentation is here:
In For finer-grained suppressions we support both |
I see a lot of value in standardizing suppression strings. They are API! I believe we can think of this as an orthogonal effort to standardizing the annotations and their semantics. But to me it does belong under the 'codeanalysis' banner, and even though our current github and group names happen to include "annotations" I am totally fine with treating this as in scope. |
I think giving some hierarchical structure to the strings is an interesting idea that could prove useful. Suppose checker A cares about distinguishing |
One thing that I could imagine is wanting is to see errors for unsafe conversions due to unannotated code but wanting not to see them for cases like |
(One possible approach: |
I still believe in this one and have a proposal to pitch at some point. It doesn't feel urgent, but if anyone else is thinking about this, drop me a note. |
Current decision: We will not include this feature in 1.0. Proposal for 1.0: Finalize the current decision. If you agree, please add a thumbs-up emoji (👍) to this comment. If you disagree, please add a thumbs-down emoji (👎) to this comment and briefly explain your disagreement. Please only add a thumbs-down if you feel you can make a strong case why this decision will be materially worse for users or tool providers than an alternative. |
Simple thing we can do today: add to our spec that Less simple things we can consider to finally properly solve the problem: see a detailed draft proposal from 2021: |
It seems we have a consensus that our project not only specifies which code is correct and which is not but also specifies which kinds of warnings at which code locations should be issued. So it seems reasonable also to specify ways to suppress such warnings. I believe it's not the top priority problem. Probably we may even skip it for the first release, allowing tools to use their current suppression mechanisms. But having a conversion about this won't harm.
Note that we should provide suppressions for the specified warnings only. And we probably should not overspecify. E.g.
I believe, all the tools which report nullability violations already have ways to suppress the warnings. Most of them support a standard
@SuppressWarnings
annotation. A notable exception is bytecode analyzers such as FindBugs and SpotBugs. As they don't see the source code normally, and@SuppressWarnings
annotation has SOURCE retention, they cannot see it.. So if we recommend using@SuppressWarnings
, these tools will be unable to follow our recommendations. Both of them define a CLASS-level@SuppressFBWarnings
annotation (also they allow to define such annotation in any package you like if you don't want an external dependency).Suppression of FindBugs problem requires to specify the internal ID of the issued warning. E.g.
@SuppressFBWarnings("NP_NULL_PARAM_DEREF_NONVIRTUAL")
for non-virtual method parameter dereference. They are too granular and, I believe, we don't need to specify such granularity. On the other hand, it's possible to suppress by prefix like@SuppressFBWarnings("NP")
: suppresses all NPE-related warnings (though IIRC not all of them actually start with "NP").IntelliJIDEA supports standard
@SuppressWarnings
annotation, as well as special comment like//noinspection ...
which allows suppressing warning on every statement inside method body (not only on the declaration statement). As a value, you should specify a "suppressionId" which often coincides with internal inspection ID. Here we have the opposite picture: most of the nullability problems are reported by too broad inspection named "Constant Conditions & Exceptions", so you have to write//noinspection ConstantConditions
or@SuppressWarnings("ConstantConditions")
. This looks crazy and also may suppress many more warnings like "Condition is always true" or "Array index is out of bounds". So I would definitely not recommend using IntelliJIDEA suppression ID as a standard.Eclipse supports standard
@SuppressWarnings
annotation (no way to suppress for individual statement), and their suppress IDs looks much better than ones IntelliJ or FindBugs has. For nullability violation, it's just a@SuppressWarnings("null")
. This suppression is not too specific and not too broad. To me, it looks the best way to suppress the warnings about unsafe conversion from nullable type to non-nullable (assign nullable to not-null; pass nullable argument as not-null parameter; dereference nullable; throw nullable; unbox nullable; etc.). However, we also need to be able to suppress strict mode warnings (conversion from nullable to unknown and from unknown to not-null), these should have separate suppress ID (I'm inclined to have single suppress ID for both cases).@SuppressWarnings("unchecked-null")
looks fine to me, though you may suggest something better.Now it's unclear whether we should have the same suppress ID when the implicit conversion of container element nullability is performed. E.g.:
I think we should specify that the warning must be issued at
list2 = list1
declaration. Should it have the same"null"
suppress ID or something different?Please share how suppression works in your tools (Sonar, ErrorProne, Checker Framework, etc.) Thank you!
The text was updated successfully, but these errors were encountered: