There is an inconsistency between the documentation and the actual implementation of the SuppressWarningsWithoutExplanation bug checker in Error Prone.
Description
-
The main documentation at https://errorprone.info/bugpattern/SuppressWarningsWithoutExplanation states the following:
- In the "Introduction / One line summary" section: "Use of
@SuppressWarnings should be accompanied by a comment describing why the warning is safe to ignore."
- This implies ALL
@SuppressWarnings
- In the "The problem" section: "Suppressions for
unchecked or rawtypes warnings should have an accompanying comment..."
- This implies this check is only applicable to
@SuppressWarnings for unchecked and rawtypes
-
The actual code implementation at SuppressWarningsWithoutExplanation.java:
- Code comment states: "The Google style guide mandates this for all suppressions; this is only matching on
{@code deprecation} as a trial."
- Implementation only checks for "deprecation" suppressions as shown in:
private static final Matcher<AnnotationTree> SUPPRESS_WARNINGS =
allOf(
isSameType(SuppressWarnings.class),
hasArgumentWithValue("value", stringLiteral("deprecation")));
Expected Behavior
Based on the Google style guide referenced in the code (which mandates explanatory comments for all suppressions) and the general documentation, this check should apply to ALL @SuppressWarnings annotations, not just those with "deprecation" value.
Suggested Fix
- Update the implementation to check all
@SuppressWarnings annotations
- Or update the implementation to check only
@SuppressWarnings for unchecked or rawtypes
- Or update the documentation to clearly state that this check currently only applies to "deprecation" suppressions
There is an inconsistency between the documentation and the actual implementation of the
SuppressWarningsWithoutExplanationbug checker in Error Prone.Description
The main documentation at https://errorprone.info/bugpattern/SuppressWarningsWithoutExplanation states the following:
@SuppressWarningsshould be accompanied by a comment describing why the warning is safe to ignore."@SuppressWarningsuncheckedorrawtypeswarnings should have an accompanying comment..."@SuppressWarningsforuncheckedandrawtypesThe actual code implementation at SuppressWarningsWithoutExplanation.java:
{@code deprecation}as a trial."Expected Behavior
Based on the Google style guide referenced in the code (which mandates explanatory comments for all suppressions) and the general documentation, this check should apply to ALL
@SuppressWarningsannotations, not just those with "deprecation" value.Suggested Fix
@SuppressWarningsannotations@SuppressWarningsforuncheckedorrawtypes