-
Notifications
You must be signed in to change notification settings - Fork 741
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
Suggestion from StatementSwitchToExpressionSwitch's "direct conversion" could be better if case already has braces #4222
Comments
copybara-service bot
pushed a commit
that referenced
this issue
Jan 4, 2024
If a case contains a single block statement, skip past the braces of the block statement. Enables fixes like: ``` case 0 -> System.out.println("0"); ``` Instead of: ``` case 0 -> { { System.out.println("0"); break; } } ``` Fixes #4222 PiperOrigin-RevId: 593453909
copybara-service bot
pushed a commit
that referenced
this issue
Jan 4, 2024
If a case contains a single block statement, skip past the braces of the block statement. Enables fixes like: ``` case 0 -> System.out.println("0"); ``` Instead of: ``` case 0 -> { { System.out.println("0"); break; } } ``` Fixes #4222 PiperOrigin-RevId: 593453909
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On Error Prone 2.24.0 with
-Xep:StatementSwitchToExpressionSwitch -XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion=true -XepPatchChecks:StatementSwitchToExpressionSwitch -XepPatchLocation:...
and the codethe suggestion from Error Prone is the following (after formatting):
For
case 1
andcase 2
this is nice.For
case 0
(which had already braces before) it adds redundant braces and it fails to remove the now unnecessarybreak;
. For converting a large code base it would be nice if the output could be improved in this regard.The text was updated successfully, but these errors were encountered: