[SCB-2560] enable checkstyle NoWhitespaceBefore (#3059)
diff --git a/ci/checkstyle/checkstyle.xml b/ci/checkstyle/checkstyle.xml
index 10a7490..1aecaa3 100644
--- a/ci/checkstyle/checkstyle.xml
+++ b/ci/checkstyle/checkstyle.xml
@@ -44,6 +44,16 @@
<property name="allowLineBreaks" value="true"/>
<property name="severity" value="error"/>
</module>
+ <module name="NoWhitespaceBefore">
+ <!-- Checks that there is no whitespace before various unary operators.
+ Linebreaks are allowed.
+ -->
+ <property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
+ <property name="allowLineBreaks" value="true"/>
+ <property name="severity" value="error"/>
+ </module>
+ <!-- Checks for over-complicated boolean expressions. -->
+ <module name="SimplifyBooleanExpression"/>
<module name="RedundantImport"/>
<module name="RedundantModifier">
<property name="tokens" value="METHOD_DEF, VARIABLE_DEF, ANNOTATION_FIELD_DEF, INTERFACE_DEF, CLASS_DEF, ENUM_DEF"/>
diff --git a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/net/NetUtils.java b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/net/NetUtils.java
index 90d6301..34d2d41 100644
--- a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/net/NetUtils.java
+++ b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/net/NetUtils.java
@@ -340,7 +340,7 @@
return String.valueOf(bytes);
}
int exp = (int) (Math.log(bytes) / Math.log(unit));
- char pre = "KMGTPE" .charAt(exp - 1);
+ char pre = "KMGTPE".charAt(exp - 1);
return String.format("%.3f%c", bytes / Math.pow(unit, exp), pre);
}
}
diff --git a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestConfigUtil.java b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestConfigUtil.java
index ba0b018..11d2508 100644
--- a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestConfigUtil.java
+++ b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestConfigUtil.java
@@ -342,7 +342,7 @@
Class<?>[] classes = Collections.class.getDeclaredClasses();
Map<String, String> env = System.getenv();
for (Class<?> cl : classes) {
- if ("java.util.Collections$UnmodifiableMap" .equals(cl.getName())) {
+ if ("java.util.Collections$UnmodifiableMap".equals(cl.getName())) {
Field field = cl.getDeclaredField("m");
field.setAccessible(true);
Object obj = field.get(env);