Skip to content

Commit 474554a

Browse files
cushonError Prone Team
authored andcommitted
Remove // fall out comments, which are sometimes used to document an empty default: statement group
PiperOrigin-RevId: 658827224
1 parent ac7ebf5 commit 474554a

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

core/src/main/java/com/google/errorprone/bugpatterns/StatementSwitchToExpressionSwitch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public final class StatementSwitchToExpressionSwitch extends BugChecker
9494
ImmutableSet.of(THROW, EXPRESSION_STATEMENT);
9595
private static final ImmutableSet<Kind> KINDS_RETURN_OR_THROW = ImmutableSet.of(THROW, RETURN);
9696
private static final Pattern FALL_THROUGH_PATTERN =
97-
Pattern.compile("\\bfalls?.?through\\b", Pattern.CASE_INSENSITIVE);
97+
Pattern.compile("\\bfalls?.?(through|out)\\b", Pattern.CASE_INSENSITIVE);
9898
// Default (negative) result for assignment switch conversion analysis. Note that the value is
9999
// immutable.
100100
private static final AssignmentSwitchAnalysisResult DEFAULT_ASSIGNMENT_SWITCH_ANALYSIS_RESULT =

core/src/test/java/com/google/errorprone/bugpatterns/StatementSwitchToExpressionSwitchTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3657,4 +3657,36 @@ public void unnecessaryBreaks() {
36573657
.setArgs("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion=true")
36583658
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
36593659
}
3660+
3661+
@Test
3662+
public void fallOutComment() {
3663+
assumeTrue(RuntimeVersion.isAtLeast14());
3664+
refactoringHelper
3665+
.addInputLines(
3666+
"Test.java",
3667+
"public class Test {",
3668+
" void f(int x) {",
3669+
" switch (x) {",
3670+
" case 0:",
3671+
" System.err.println(\"ZERO\");",
3672+
" break;",
3673+
" default:",
3674+
" // fall out",
3675+
" }",
3676+
" }",
3677+
"}")
3678+
.addOutputLines(
3679+
"Test.java",
3680+
"public class Test {",
3681+
" void f(int x) {",
3682+
" switch (x) {",
3683+
" case 0 -> System.err.println(\"ZERO\");",
3684+
" default -> {}",
3685+
" }",
3686+
" }",
3687+
"}")
3688+
.setArgs(
3689+
ImmutableList.of("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion"))
3690+
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
3691+
}
36603692
}

0 commit comments

Comments
 (0)