You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2022/06/13 01:32:14 UTC

[servicecomb-java-chassis] branch master updated: [SCB-2560] enable checkstyle NoWhitespaceBefore (#3059)

This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new 08c514044 [SCB-2560] enable checkstyle NoWhitespaceBefore (#3059)
08c514044 is described below

commit 08c51404400e61fbbed0c768e0573bbffd898766
Author: TingTing Wang <19...@qq.com>
AuthorDate: Mon Jun 13 09:32:08 2022 +0800

    [SCB-2560] enable checkstyle NoWhitespaceBefore (#3059)
---
 ci/checkstyle/checkstyle.xml                                   | 10 ++++++++++
 .../org/apache/servicecomb/foundation/common/net/NetUtils.java |  2 +-
 .../java/org/apache/servicecomb/config/TestConfigUtil.java     |  2 +-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ci/checkstyle/checkstyle.xml b/ci/checkstyle/checkstyle.xml
index 10a7490f8..1aecaa3df 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 90d6301de..34d2d4135 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 @@ public final class NetUtils {
       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 ba0b018b1..11d2508fa 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 @@ public class TestConfigUtil {
     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);