-
Notifications
You must be signed in to change notification settings - Fork 784
Open
Description
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
@SuppressWarningsshould be accompanied by a comment describing why the warning is safe to ignore."- This implies ALL
@SuppressWarnings
- This implies ALL
- In the "The problem" section: "Suppressions for
uncheckedorrawtypeswarnings should have an accompanying comment..."- This implies this check is only applicable to
@SuppressWarningsforuncheckedandrawtypes
- This implies this check is only applicable to
- In the "Introduction / One line summary" section: "Use of
-
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")));
- Code comment states: "The Google style guide mandates this for all suppressions; this is only matching on
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.
- Note: I cannot find a reference to this rule in the current published Java style guide at https://google.github.io/styleguide/javaguide.html
Suggested Fix
- Update the implementation to check all
@SuppressWarningsannotations - Or update the implementation to check only
@SuppressWarningsforuncheckedorrawtypes - Or update the documentation to clearly state that this check currently only applies to "deprecation" suppressions
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels