From e34168f6bbb22515d43cfa1df6f44e952411443b Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 11 Aug 2021 16:34:55 +0100 Subject: [PATCH] Add NoWhitespaceBeforeCaseDefaultColon commit-id:3265f01a --- builder/src/main/resources/application.yml | 7 +++++ .../NoWhitespaceBeforeCaseDefaultColon.md | 29 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 builder/src/main/resources/rules/NoWhitespaceBeforeCaseDefaultColon.md diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 8e7b58f..c371992 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -1538,3 +1538,10 @@ rules: enabled: true source: SEVNTU 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 diff --git a/builder/src/main/resources/rules/NoWhitespaceBeforeCaseDefaultColon.md b/builder/src/main/resources/rules/NoWhitespaceBeforeCaseDefaultColon.md new file mode 100644 index 0000000..98ceaf3 --- /dev/null +++ b/builder/src/main/resources/rules/NoWhitespaceBeforeCaseDefaultColon.md @@ -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; +} +````