Add NoWhitespaceBeforeCaseDefaultColon
commit-id:3265f01a
This commit is contained in:
parent
a5b7542ac3
commit
e34168f6bb
2 changed files with 36 additions and 0 deletions
|
@ -1538,3 +1538,10 @@ rules:
|
||||||
enabled: true
|
enabled: true
|
||||||
source: SEVNTU
|
source: SEVNTU
|
||||||
uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MoveVariableInsideIfCheck.html
|
uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MoveVariableInsideIfCheck.html
|
||||||
|
-
|
||||||
|
name: NoWhitespaceBeforeCaseDefaultColon
|
||||||
|
parent: TREEWALKER
|
||||||
|
level: LAYOUT
|
||||||
|
enabled: true
|
||||||
|
source: CHECKSTYLE
|
||||||
|
uri: https://checkstyle.sourceforge.io/config_whitespace.html#NoWhitespaceBeforeCaseDefaultColon
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
|
||||||
|
Checks that there is no whitespace before the colon in a switch block. .
|
||||||
|
|
||||||
|
Valid:
|
||||||
|
````
|
||||||
|
switch(1) {
|
||||||
|
case 1:
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
````
|
||||||
|
|
||||||
|
Invalid:
|
||||||
|
````
|
||||||
|
switch(2) {
|
||||||
|
case 2: // ok
|
||||||
|
break;
|
||||||
|
case 3, 4
|
||||||
|
: break; // violation, whitespace before ':' is not allowed here
|
||||||
|
case 4,
|
||||||
|
5: break; // ok
|
||||||
|
default
|
||||||
|
: // violation, whitespace before ':' is not allowed here
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
````
|
Loading…
Reference in a new issue