This is an automated email from the ASF dual-hosted git repository.
benjobs 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 23aafe15 [Improve] add Use `isEmpty()` instead of `length() == 0` or
`size() == 0` rule (#293)
23aafe15 is described below
commit 23aafe152f7190eb1b54e58cfd57270341b1112b
Author: VampireAchao <[email protected]>
AuthorDate: Sun Nov 12 00:28:21 2023 +0800
[Improve] add Use `isEmpty()` instead of `length() == 0` or `size() == 0`
rule (#293)
* [Improve] add Use `isEmpty()` instead of `length() == 0` or `size() == 0`
rule
* [Improve] code style optimize
---
community/submit_guide/code-style-and-quality-guide.md | 18 ++++++++++++++++++
.../submit_guide/code-style-and-quality-guide.md | 18 ++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/community/submit_guide/code-style-and-quality-guide.md
b/community/submit_guide/code-style-and-quality-guide.md
index 02ee2704..1f77d17c 100644
--- a/community/submit_guide/code-style-and-quality-guide.md
+++ b/community/submit_guide/code-style-and-quality-guide.md
@@ -249,6 +249,24 @@ sidebar_position: 3
public CurrentHashMap funName();
```
+3. Use `isEmpty()` instead of `length() == 0` or `size() == 0`
+
+ - Negative demo:
+
+ ```java
+ if (pathPart.length() == 0) {
+ return;
+ }
+ ```
+
+ - Positive demo:
+
+ ```java
+ if (pathPart.isEmpty()) {
+ return;
+ }
+ ```
+
### 3.5 Concurrent Processing
1. The `thread pool` needs to be managed, using a unified entry point to
obtain the `thread pool`.
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs-community/current/submit_guide/code-style-and-quality-guide.md
b/i18n/zh-CN/docusaurus-plugin-content-docs-community/current/submit_guide/code-style-and-quality-guide.md
index 5cd2a3a0..e438ebec 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs-community/current/submit_guide/code-style-and-quality-guide.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs-community/current/submit_guide/code-style-and-quality-guide.md
@@ -249,6 +249,24 @@ sidebar_position: 3
public CurrentHashMap funName();
```
+3. 使用 `isEmpty()` 而不是 `length() == 0` 或者 `size() == 0`
+
+ - 负面示例:
+
+ ```java
+ if (pathPart.length() == 0) {
+ return;
+ }
+ ```
+
+ - 正面示例:
+
+ ```java
+ if (pathPart.isEmpty()) {
+ return;
+ }
+ ```
+
### 3.5 并发处理
1. 需要管理 `线程池`,使用统一的入口点获取 `线程池`。