forked from checkstyle/checkstyle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue checkstyle#4764: correct NeedBracesCheck
- Loading branch information
Showing
3 changed files
with
118 additions
and
88 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
34 changes: 34 additions & 0 deletions
34
.../com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesCaseDefault.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,34 @@ | ||
package com.puppycrawl.tools.checkstyle.checks.blocks.needbraces; | ||
|
||
public class InputNeedBracesCaseDefault { | ||
|
||
public String aMethod(int val) { | ||
switch (val){ | ||
default: | ||
case 0: | ||
case -1: break; | ||
case -2: Math.random(); | ||
} | ||
switch (val){ | ||
default: break; | ||
} | ||
switch (val){ | ||
default: Math.random(); | ||
} | ||
switch (val){ | ||
case 1: {} | ||
default: | ||
} | ||
switch (val) { | ||
case 0: { | ||
return "zero"; | ||
} | ||
case 1: { | ||
return "one"; | ||
} | ||
default: { | ||
return "non-binary"; | ||
} | ||
} | ||
} | ||
} |