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

panyuepeng pushed a commit to branch dev
in repository 
https://gitbox.apache.org/repos/asf/incubator-streampark-website.git


The following commit(s) were added to refs/heads/dev by this push:
     new 8c969ab1 [Improve] Add code quality rules (#252)
8c969ab1 is described below

commit 8c969ab102015de43b1e9f27bfb69e3f18a0f25e
Author: ChunFuWu <[email protected]>
AuthorDate: Wed Sep 20 08:43:55 2023 +0800

    [Improve] Add code quality rules (#252)
    
    * [Improve] Add code quality rules
    
    * [Improve] Add code quality rules
---
 .../submit_guide/code-style-and-quality-guide.md   | 132 ++++++++++++++++++++-
 1 file changed, 129 insertions(+), 3 deletions(-)

diff --git a/community/submit_guide/code-style-and-quality-guide.md 
b/community/submit_guide/code-style-and-quality-guide.md
index 86ea140b..05fc1e06 100644
--- a/community/submit_guide/code-style-and-quality-guide.md
+++ b/community/submit_guide/code-style-and-quality-guide.md
@@ -135,9 +135,9 @@ sidebar_position: 3
        private static final long serialVersionUID = 1L;
       ```
 
-2. Redundant strings should be extracted as constants
-If a constant has been hardcoded twice or more times, please directly extract 
it as a constant and change the corresponding reference.
-In generally, constants in `log` can be ignored to extract.
+2. Redundant strings should be extracted as constants  
+   >If a constant has been hardcoded twice or more times, please directly 
extract it as a constant and change the corresponding reference.
+   In generally, constants in `log` can be ignored to extract.
 
     - Negative demo:
 
@@ -400,6 +400,132 @@ to reduce code line depth and improve readability like 
follows:
 
 1. Use a unified `Utils.requireXXX` to complete the validation of the 
prerequisite, and if possible, replace the `AlertXXException.throwIfXXX` by new 
pre-conditions checking.
 
+### 3.11 StringUtils
+
+1. Use `StringUtils.isBlank` instead of `StringUtils.isEmpty`
+
+   - Negative demo:
+   
+      ```java
+      if (StringUtils.isEmpty(name)) {
+     return;
+      }
+      ```
+   
+   - Positive demo:
+   
+     ```java
+     if (StringUtils.isBlank(name)) {
+     return;
+     }
+     ```
+
+2. Use `StringUtils.isNotBlank` instead of `StringUtils.isNotEmpty`
+
+   - Negative demo:
+   
+      ```java
+      if (StringUtils.isNotEmpty(name)) {
+        return;
+      }
+      ```
+   
+   - Positive demo:
+   
+     ```java
+     if (StringUtils.isNotBlank(name)) {
+       return;
+     }
+     ```
+
+3. Use `StringUtils.isAllBlank` instead of `StringUtils.isAllEmpty`
+
+   - Negative demo:
+   
+      ```java
+      if (StringUtils.isAllEmpty(name, age)) {
+        return;
+      }
+      ```
+   
+   - Positive demo:
+   
+     ```java
+     if (StringUtils.isAllBlank(name, age)) {
+       return;
+     }
+     ```
+
+### 3.12 `Enum` Class
+
+1. Enumeration value comparison
+
+   - Negative demo:
+   
+      ```java
+      if (status.equals(JobStatus.RUNNING)) {
+        return;
+      }
+      ```
+   
+   - Positive demo:
+   
+     ```java
+     if (status == JobStatus.RUNNING) {
+       return;
+     }
+     ```
+
+2. Enumeration classes do not need to implement Serializable
+
+   - Negative demo:
+   
+      ```java
+      public enum JobStatus implements Serializable {
+        ...
+      }
+      ```
+   
+   - Positive demo:
+   
+     ```java
+     public enum JobStatus {
+       ...
+     }
+     ```
+
+3. Use `Enum.name()` instead of `Enum.toString()`
+
+   - Negative demo:
+   
+      ```java
+      System.out.println(JobStatus.RUNNING.toString());
+      ```
+   
+   - Positive demo:
+   
+     ```java
+     System.out.println(JobStatus.RUNNING.name());
+     ```
+
+4. Enumeration class names uniformly use the Enum suffix
+
+   - Negative demo:
+   
+      ```java
+      public enum JobStatus {
+        ...
+      }
+      ```
+   
+   - Positive demo:
+   
+     ```java
+     public enum JobStatusEnum {
+       ...
+     }
+     ```
+
 ## 4 Exception Processing
 
 This `streampark-console-service` module is the core module for processing 
user requests.

Reply via email to