[SCB-2551] enable checkstyle WhitespaceAround (#3044)
diff --git a/ci/checkstyle/checkstyle.xml b/ci/checkstyle/checkstyle.xml
index c7ce946..f3e014e 100644
--- a/ci/checkstyle/checkstyle.xml
+++ b/ci/checkstyle/checkstyle.xml
@@ -30,6 +30,7 @@
</module>
<module name="TreeWalker">
<module name="AvoidStarImport"/>
+ <module name="EmptyStatement"/>
<module name="NoWhitespaceAfter">
<!-- Checks that there is no whitespace after various unary operators.
Linebreaks are allowed.
@@ -52,5 +53,19 @@
-->
<property name="tokens" value="COMMA, SEMI, TYPECAST"/>
</module>
+ <module name="WhitespaceAround">
+ <!-- Checks that various tokens are surrounded by whitespace.
+ This includes most binary operators and keywords followed
+ by regular or curly braces.
+ -->
+ <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
+ BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
+ EQUAL, GE, GT, LAND, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
+ LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
+ LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
+ MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
+ SL, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
+ <property name="severity" value="error"/>
+ </module>
</module>
</module>
diff --git a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/JvmUtils.java b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/JvmUtils.java
index 8e0507a..6ed60ff 100644
--- a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/JvmUtils.java
+++ b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/JvmUtils.java
@@ -54,7 +54,7 @@
}
}
}
- if(StringUtils.isEmpty(mainClass)){
+ if (StringUtils.isEmpty(mainClass)) {
LOGGER.info("Can't found main class by stackTrace.");
return null;
}
@@ -85,7 +85,7 @@
String mainClassOrJar = command.trim().split(" ")[0];
mainClass = readFromJar(mainClassOrJar);
}
- if(StringUtils.isEmpty(mainClass)){
+ if (StringUtils.isEmpty(mainClass)) {
LOGGER.info("Can't found main class by manifest.");
return null;
}
diff --git a/huawei-cloud/darklaunch/src/main/java/org/apache/servicecomb/darklaunch/oper/LikeCondition.java b/huawei-cloud/darklaunch/src/main/java/org/apache/servicecomb/darklaunch/oper/LikeCondition.java
index 00933c0..790ba9a 100644
--- a/huawei-cloud/darklaunch/src/main/java/org/apache/servicecomb/darklaunch/oper/LikeCondition.java
+++ b/huawei-cloud/darklaunch/src/main/java/org/apache/servicecomb/darklaunch/oper/LikeCondition.java
@@ -46,9 +46,9 @@
@Override
public boolean match() {
SupportedType type = this.getType();
- if(type == SupportedType.STRING) {
+ if (type == SupportedType.STRING) {
return this.pattern.matcher((String) this.getActual()).matches();
- } else{
+ } else {
return false;
}
}
diff --git a/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/generator/core/AbstractOperationGenerator.java b/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/generator/core/AbstractOperationGenerator.java
index 94bfef6..bd88314 100644
--- a/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/generator/core/AbstractOperationGenerator.java
+++ b/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/generator/core/AbstractOperationGenerator.java
@@ -439,7 +439,7 @@
anyMatch(annotation -> NOT_NULL_ANNOTATIONS.contains(annotation.annotationType().getSimpleName()));
if (requireItem) {
Property property = properties.get(field.getName());
- if(property != null){
+ if (property != null) {
property.setRequired(true);
}
}