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#13553: Finished false positive in FallThroughCheck o…
…n last case
- Loading branch information
1 parent
27b7ee9
commit e3d5e59
Showing
15 changed files
with
248 additions
and
34 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
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
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
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
15 changes: 15 additions & 0 deletions
15
...ppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughInlineSingleCase.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,15 @@ | ||
/* | ||
FallThrough | ||
checkLastCaseGroup = true | ||
reliefPattern = (default)falls?[ -]?thr(u|ough) | ||
*/ | ||
package com.puppycrawl.tools.checkstyle.checks.coding.fallthrough; | ||
|
||
public class InputFallThroughInlineSingleCase{ | ||
void method(int a) { | ||
switch (a) {case 1:;} | ||
// violation above 'Fall\ through from the last branch of the switch statement.' | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
...wl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughMultipleReliefPatterns.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,26 @@ | ||
/* | ||
FallThrough | ||
checkLastCaseGroup = true | ||
reliefPattern = (default)falls?[ -]?thr(u|ough) | ||
*/ | ||
package com.puppycrawl.tools.checkstyle.checks.coding.fallthrough; | ||
|
||
public class InputFallThroughMultipleReliefPatterns { | ||
|
||
void method(int i) { | ||
while (true) { | ||
switch (i) { | ||
case 5: { | ||
i++; | ||
} | ||
/* block */ /* fallthru */ // comment | ||
case 6: | ||
i++; | ||
/* block */ /* fallthru */ // comment | ||
|
||
} | ||
} | ||
} | ||
} |
117 changes: 117 additions & 0 deletions
117
...rawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughWithoutReliefPattern.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,117 @@ | ||
/* | ||
FallThrough | ||
checkLastCaseGroup = (default)false | ||
reliefPattern = Continue with next case | ||
*/ | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.coding.fallthrough; | ||
|
||
public class InputFallThroughWithoutReliefPattern { | ||
void method(int i, boolean cond) { | ||
while (true) { | ||
switch (i) { | ||
case 0: | ||
case 1: | ||
i++; | ||
break; | ||
case 2: | ||
i++; | ||
case 3: // violation 'Fall\ through from previous branch of the switch statement.' | ||
i++; | ||
break; | ||
case 4: | ||
return; | ||
case 5: | ||
throw new RuntimeException(""); | ||
case 6: | ||
continue; | ||
case 7: { | ||
break; | ||
} | ||
case 8: { | ||
return; | ||
} | ||
case 9: { | ||
throw new RuntimeException(""); | ||
} | ||
case 10: { | ||
continue; | ||
} | ||
case 11: { | ||
i++; | ||
} | ||
case 12: // violation 'Fall\ through from previous branch of the switch statement.' | ||
if (false) | ||
break; | ||
else | ||
break; | ||
case 13: | ||
if (true) { | ||
return; | ||
} | ||
case 14: // violation 'Fall\ through from previous branch of the switch statement.' | ||
if (true) { | ||
return; | ||
} else { | ||
//do nothing | ||
} | ||
case 15: // violation 'Fall\ through from previous branch of the switch statement.' | ||
do { | ||
System.identityHashCode("something"); | ||
return; | ||
} while (true); | ||
case 16: | ||
for (int j1 = 0; j1 < 10; j1++) { | ||
String.valueOf("something"); | ||
return; | ||
} | ||
case 17: | ||
while (true) | ||
throw new RuntimeException(""); | ||
case 18: | ||
while (cond) { | ||
break; | ||
} | ||
case 19: // violation 'Fall\ through from previous branch of the switch statement.' | ||
try { | ||
i++; | ||
break; | ||
} catch (RuntimeException e) { | ||
break; | ||
} catch (Error e) { | ||
return; | ||
} | ||
case 20: | ||
try { | ||
i++; | ||
break; | ||
} catch (RuntimeException e) { | ||
} catch (Error e) { | ||
return; | ||
} | ||
case 21: // violation 'Fall\ through from previous branch of the switch statement.' | ||
try { | ||
i++; | ||
} catch (RuntimeException e) { | ||
i--; | ||
} finally { | ||
break; | ||
} | ||
case 22: | ||
try { | ||
i++; | ||
break; | ||
} catch (RuntimeException e) { | ||
i--; | ||
break; | ||
} finally { | ||
i++; | ||
} | ||
default: | ||
i++; | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.