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
The -XepAllSuggestionsAsWarnings flag added by #3301 does not seem to work properly when you manually enable a check which is disabled by default, without overwriting its default severity.
When the default severity is 'suggestion', instead of being increased to 'warning' it remains at 'suggestion'.
Maybe that second code snippet could use severities.putIfAbsent instead (haven't test it yet though)?
Reproduction steps
Use -XepAllSuggestionsAsWarnings
Use -Xep:SwitchDefault to enable that check, because it is disabled by default
(SwitchDefault has the default severity 'suggestion')
Bug: SwitchDefault is reported as 'suggestion' instead of 'warning'
Workaround
When enabling the check also explicitly specify the severity, e.g. -Xep:SwitchDefault:WARN, but that has these disadvantages
you might forget to do this (in case you don't apply :WARN for all checks), or it might be missing after a newer Error Prone version reduced the default severity of a check to 'suggestion'
you might accidentally reduce the severity if you apply :WARN for all manually enabled checks, but some of them had 'error' as default severity
The text was updated successfully, but these errors were encountered:
Version
Error Prone 2.23.0
JDK 17
Description
The
-XepAllSuggestionsAsWarnings
flag added by #3301 does not seem to work properly when you manually enable a check which is disabled by default, without overwriting its default severity.When the default severity is 'suggestion', instead of being increased to 'warning' it remains at 'suggestion'.
I assume the underlying reason is:
error-prone/check_api/src/main/java/com/google/errorprone/scanner/ScannerSupplier.java
Lines 172 to 176 in 7acf133
error-prone/check_api/src/main/java/com/google/errorprone/scanner/ScannerSupplier.java
Lines 213 to 215 in 7acf133
Maybe that second code snippet could use
severities.putIfAbsent
instead (haven't test it yet though)?Reproduction steps
-XepAllSuggestionsAsWarnings
-Xep:SwitchDefault
to enable that check, because it is disabled by default(
SwitchDefault
has the default severity 'suggestion')Bug:
SwitchDefault
is reported as 'suggestion' instead of 'warning'Workaround
When enabling the check also explicitly specify the severity, e.g.
-Xep:SwitchDefault:WARN
, but that has these disadvantages:WARN
for all checks), or it might be missing after a newer Error Prone version reduced the default severity of a check to 'suggestion':WARN
for all manually enabled checks, but some of them had 'error' as default severityThe text was updated successfully, but these errors were encountered: