forked from checkstyle/checkstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue checkstyle#12943: Resolve pitest suppression for FallThroughCheck
- Loading branch information
1 parent
673e86a
commit ba6a74d
Showing
3 changed files
with
51 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughTryCatchInSwitch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
FallThrough | ||
checkLastCaseGroup = (default)false | ||
reliefPattern = (default)falls?[ -]?thr(u|ough) | ||
*/ | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.coding.fallthrough; | ||
|
||
import java.io.IOException; | ||
|
||
public class InputFallThroughTryCatchInSwitch { | ||
public int foo(int x) { | ||
switch (x) { | ||
case 1: | ||
try { | ||
// Some code | ||
throw new IOException("Exception occurred."); | ||
} catch (IOException e) { | ||
// Some code | ||
if (e.getMessage().contains("Exception")) { | ||
break; | ||
} else { | ||
return 0; | ||
} | ||
} catch (Exception e) { | ||
// Some code | ||
for (int i = 0; i < 3; i++) { | ||
if (i == 1) { | ||
break; | ||
} | ||
} | ||
} finally { | ||
// Some code | ||
} | ||
default: // violation 'Fall through from previous branch of the switch statement.' | ||
// Some code | ||
} | ||
|
||
return 0; | ||
} | ||
} |