You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by li...@apache.org on 2021/10/08 16:27:36 UTC

[dolphinscheduler-website] branch master updated: Use Checkstyle for Intellij auto format (#449)

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

lidongdai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler-website.git


The following commit(s) were added to refs/heads/master by this push:
     new 7b76cc9  Use Checkstyle for Intellij auto format (#449)
7b76cc9 is described below

commit 7b76cc9862868980186c90753f8923e44f445c13
Author: Jiajie Zhong <zh...@hotmail.com>
AuthorDate: Sat Oct 9 00:27:33 2021 +0800

    Use Checkstyle for Intellij auto format (#449)
---
 community/en-us/development/pull-request.md |  30 +++++++++++---------------
 community/zh-cn/development/pull-request.md |  32 +++++++++++-----------------
 img/code-style-idea.png                     | Bin 503219 -> 397042 bytes
 3 files changed, 24 insertions(+), 38 deletions(-)

diff --git a/community/en-us/development/pull-request.md b/community/en-us/development/pull-request.md
index 13571d0..bf8e947 100644
--- a/community/en-us/development/pull-request.md
+++ b/community/en-us/development/pull-request.md
@@ -58,31 +58,25 @@ Please refer to the commit message section.
 
 ### Pull Request Code Style
 
-[Checkstyle](https://checkstyle.sourceforge.io/) is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard.
+Code style is the thing you have to consider when you submit pull request for DolphinScheduler. We using [Checkstyle](https://checkstyle.sourceforge.io), a development tool to help programmers write Java code that adheres to a coding standard, in CI to keep DolphinScheduler codebase in the same style. Your pull request could not be merged if your code style checker failed. You could format your code by *Checkstyle* in your local environment before you submit your pull request to check co [...]
 
-How to configure checkstyle and code style in dolphin scheduler:
+1. Prepare Checkstyle configuration file: You could download it manually by [click here](https://github.com/apache/dolphinscheduler/blob/dev/style/checkstyle.xml), but find it in DolphinScheduler repository would be a better way. You could find configuration file in the path `style/checkstyle.xml` after you clone repository from Github.
 
-1.checkstyle and code-style configuration files
+2. Download Checkstyle plugins in Intellij IDEA: Search plugin by keyword **CheckStyle-IDEA** or install in [this page](https://plugins.jetbrains.com/plugin/1065-checkstyle-idea). You could see [install plugin](https://www.jetbrains.com/help/idea/managing-plugins.html#install_plugin_from_repo) if you do not know how to install plugin in Intellij IDEA
 
-checkstyle: https://github.com/apache/dolphinscheduler/blob/dev/style/checkstyle.xml
+3. Configure and activate Checkstyle and Intellij IDEA code-style: After completing the above steps, you could configure and activate it in your environment. You could find Checkstyle plugins in the path `Preferences -> Tool -> Checkstyle`. After that you could activate Checkstyles as screenshot show
 
-code-style: https://github.com/apache/dolphinscheduler/blob/dev/style/intellij-java-code-style.xml
+<p align="center">
+    <img src="/img/checkstyle-idea.png" alt="checkstyle idea configuration" />
+</p>
 
-2.checkstyle configuration
+For now your Checkstyle plugins are setup, it would show codes and files which out of style. We highly recommend you configure Intellij IDEA code-style for auto-formatting your code in Intellij IDEA, you could find this setting in `Preferences -> Editor -> Code Style -> Java` and then activate it as screenshot show
 
- <p align="center">
-   <img src="/img/checkstyle-idea.png" alt="checkstyle idea configuration" />
- </p>
- 
-3.code-style configuration
+<p align="center">
+    <img src="/img/code-style-idea.png" alt="code style idea configuration" />
+</p>
 
- <p align="center">
-   <img src="/img/code-style-idea.png" alt="code style idea configuration" />
- </p>
- 
-4.How to use checkstyle and code style
-
-After configuration, before submitting a Pull Request, the checkstyle tool will automatically help you format code and import order in the changed code file when you use `Ctrl+L`.
+1. Format your codebase in Intellij IDEA before submit your pull request: After you done above steps, you could using Intellij IDEA shortcut `Command + L`(for Mac) or `Ctrl+L`(for Windows) to format your code. The best time to format your code is before you commit your change to your local git repository.
 
 ### Question
 
diff --git a/community/zh-cn/development/pull-request.md b/community/zh-cn/development/pull-request.md
index bc072ea..60096eb 100644
--- a/community/zh-cn/development/pull-request.md
+++ b/community/zh-cn/development/pull-request.md
@@ -64,31 +64,23 @@ waste time。
 
 ### Pull Request Code Style
 
-checkstyle [参考](https://checkstyle.sourceforge.io/)是一种帮助开发者编写遵循编码规范的 Java 代码开发工具。它可以自动化检查 Java 代码的方法以及格式,使得开发者不用再做这项无聊(但很重要)的任务。它非常适合于希望实施编码标准的项目。
+当你向 DolphinScheduler 提交 pull request 的时候 code-style 是你不得不考虑的问题。我们在 CI 中使用 Checkstyle [参考](https://checkstyle.sourceforge.io/)来保持代码风格的统一,它是一种帮助开发者编写遵循编码规范的 Java 代码开发工具。如果你的 pull request 没有通过 Checkstyle 的检测,那它将不会被合并到主库中。你可以在提交 pull request 前使用 Checkstyle 来检测或者格式化你的代码。如下的步骤将引领你配置并激活 Checkstyle
 
-在 DolphinScheduler 中配置 checkstyle 和 code-style 的方式:
+1. 准备 Checkstyle 配置文件:你可以点击[这里](ttps://github.com/apache/dolphinscheduler/blob/dev/style/checkstyle.xml)手动下载,但是我们更加推荐在 DolphinScheduler 代码库中找到它。当你将代码库克隆下来后,你可以在路径 `style/checkstyle.xml` 下找到配置文件
+2. 下载 Intellij IDEA Checkstyle 插件:通过关键字**CheckStyle-IDEA**或者通过[这个页面](https://plugins.jetbrains.com/plugin/1065-checkstyle-idea)安装均可。如果你不清楚如何安装Intellij IDEA插件,可以参考[这个连接](https://www.jetbrains.com/help/idea/managing-plugins.html#install_plugin_from_repo)
+3. 配置并激活 Checkstyles 以及 Intellij IDEA 代码风格:当完成上面几步后,你就可以配置并激活他们了。你可以在路径`Preferences -> Tool -> Checkstyle`中找到 Checkstyle,请参照下图完成其配置
 
-1.checkstyle 和 code-style 配置文件
+<p align="center">
+    <img src="/img/checkstyle-idea.png" alt="checkstyle idea configuration" />
+</p>
 
-checkstyle: https://github.com/apache/dolphinscheduler/blob/dev/style/checkstyle.xml
+截止目前,Checkstyle 插件已经配置完成了,当有代码或者文件不符合风格时就会显示在 Checkstyle 中。但强烈建议同时配置 Intellij IDEA 的代码风格,完成配置后可以使用 Intellij IDEA 自动格式化功能。你可以在路径`Preferences -> Editor -> Code Style -> Java`找到配置,请参照下图完成其配置
 
-code-style: https://github.com/apache/dolphinscheduler/blob/dev/style/intellij-java-code-style.xml
+<p align="center">
+    <img src="/img/code-style-idea.png" alt="code style idea configuration" />
+</p>
 
-2.checkstyle 配置过程
-
- <p align="center">
-   <img src="/img/checkstyle-idea.png" alt="checkstyle idea 配置方式" />
- </p>
- 
-3.code-style 配置过程
-
- <p align="center">
-   <img src="/img/code-style-idea.png" alt="code style idea 配置方式" />
- </p>
- 
-4.怎样使用 checkstyle 和 code-style
-
-当你配置完成后,在提交 Pull Request 前,在改动过后的代码文件中 `Ctrl+L`,checkstyle 工具就会自动帮你 format code 和 import 顺序。
+1. 在提交 pull request 前格式化你的代码:完成上面全部后,你可以使用快捷键`Command + L`(Mac用户) or `Ctrl+L`(Windows用户)在 Intellij IDEA 完成自动格式化。格式化代码的最佳时间是将你的修改提交到本地 git 版本库之前
 
 ### 相关问题
 
diff --git a/img/code-style-idea.png b/img/code-style-idea.png
index 4e4177b..6c2ecfa 100644
Binary files a/img/code-style-idea.png and b/img/code-style-idea.png differ