Skip to content
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

-XepAllSuggestionsAsWarnings doesn't work for checks manually enabled with default severity #4206

Open
Marcono1234 opened this issue Nov 29, 2023 · 0 comments

Comments

@Marcono1234
Copy link
Contributor

Marcono1234 commented Nov 29, 2023

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:

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant