Skip to content

Commit

Permalink
Merge pull request #102 from Pil0tXia/checkstyle_100
Browse files Browse the repository at this point in the history
[ISSUE #100] Improving the import and usage methods of Checkstyle
  • Loading branch information
qqeasonchen committed Jul 24, 2023
2 parents 28768f7 + 15806cb commit 9d7263b
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 23 deletions.
49 changes: 40 additions & 9 deletions community/contribute/01-contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,58 @@ If you are a new contributor who wants to contribute to the EventMesh community,

#### Import Code Style

File location: Import the [`eventmesh-code-style.xml`](https://github.com/apache/incubator-eventmesh/blob/master/style/eventmesh-code-style.xml) file located in the `incubator-eventmesh/style` directory of the source code into **`IntelliJ IDEA`**.
File location: Import the [`eventmesh-code-style.xml`](https://github.com/apache/eventmesh/blob/master/style/eventmesh-code-style.xml) file located in the `eventmesh/style` directory of the source code into **`IntelliJ IDEA`**.

```
Editor -> Code Style -> Import Scheme -> IntelliJ IDEA code style XML
Settings -> Editor -> Code Style -> Import Scheme -> IntelliJ IDEA code style XML
```

![import code style](../../static/images/contribute/import-codestyle.png)

#### Import Check Style
#### Import CheckStyle

File location: Import the [`checkStyle.xml`](https://github.com/apache/incubator-eventmesh/blob/master/style/checkStyle.xml)file located in the `incubator-eventmesh/style` directory of the source code into **`IntelliJ IDEA`**.
File location: Import the [`checkStyle.xml`](https://github.com/apache/incubator-eventmesh/blob/master/style/checkStyle.xml)file located in the `eventmesh/style` directory of the source code into **`IntelliJ IDEA`**.

For IDEA, you can import check style file by:
Please install the CheckStyle-IDEA plugin. For IDEA, you need to import the CheckStyle code style file in the following two settings:
```shell
Editor -> Code Style -> Java -> Scheme -> Import Scheme -> CheckStyle Configuration
Settings -> Editor -> Code Style -> Java -> Scheme -> Import Scheme -> CheckStyle Configuration
```

If you can't see CheckStyle Configuration section under Import Scheme, you can install CheckStyle-IDEA plugin first, and you will see it.
```
Settings -> Tools -> Checkstyle -> Configuration File
```

![](../../static/images/contribute/import-checkstyle_1.png)

![](../../static/images/contribute/import-checkstyle_2.png)

#### Enable CheckStyle

You can set EventMesh's code style file to `Active` (default option) in `Tools -> Checkstyle -> Configuration File`. Otherwise, before running CheckStyle checks, you will need to manually specify EventMesh's code style configuration.

![](../../static/images/contribute/enable-checkstyle.png)

#### Use CheckStyle Plugin

To check the code style of the current file, the simplest way is to right-click in the editor and execute `Check Current File`:

![](../../static/images/contribute/use-checkstyle_1.png)

It will open a tab at the bottom where you can observe code style warnings output. If none appear, everything complies with the standards.

![](../../static/images/contribute/use-checkstyle_2.png)

You can further run scans for the current module or the entire project on the left side of this tab.

(Note: When you submit a PR, the CI will only check the files that were changed in that PR).

#### Use CheckStyle Task

You can perform a code style scan for a specific module or the entire project in the right-side Gradle tab in IDEA:

![](../../static/images/contribute/use-checkstyle_3.png)

You can also use `./gradlew check` to check the code style.
(Note: this command will check all file in project, when you submit a pr, the ci will only check the file has been changed in this pr).
You can also use `./gradlew check` in the terminal to check the code style of all files in the project.

### Continuous Integration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,61 @@ sidebar_position: 0

### 代码风格

#### 导入Code Style
#### 导入 Code Style

文件位置:源码 `incubator-eventmesh/style`目录下面的 [`eventmesh-code-style.xml`](https://github.com/apache/incubator-eventmesh/blob/master/style/eventmesh-code-style.xml) 文件导入 **`IntelliJ IDEA`**
文件位置:源码 `eventmesh/style`目录下面的 [`eventmesh-code-style.xml`](https://github.com/apache/eventmesh/blob/master/style/eventmesh-code-style.xml) 文件,请将其导入您的 **`IntelliJ IDEA`**

```
Editor -> Code Style -> Import Scheme -> IntelliJ IDEA code style XML
Settings -> Editor -> Code Style -> Import Scheme -> IntelliJ IDEA code style XML
```

![import code style](../../../../../static/images/contribute/import-codestyle.png)

#### 导入Check Style
#### 导入 CheckStyle

文件位置:源码源码 `incubator-eventmesh/style`目录下面的 [`checkStyle.xml`](https://github.com/apache/incubator-eventmesh/blob/master/style/checkStyle.xml)文件导入您的 **`IntelliJ IDEA`**
文件位置:源码 `eventmesh/style`目录下面的 [`checkStyle.xml`](https://github.com/apache/eventmesh/blob/master/style/checkStyle.xml)文件

对于 IDEA,您可以通过以下方式导入检查样式文件
请安装 CheckStyle-IDEA 插件。对于 IDEA,您需要在以下两处设置项中导入 CheckStyle 代码风格文件

```shell
Editor -> Code Style -> Java -> Scheme -> Import Scheme -> CheckStyle Configuration
```
Settings -> Editor -> Code Style -> Java -> Scheme -> Import Scheme -> CheckStyle Configuration
```

```
Settings -> Tools -> Checkstyle -> Configuration File
```

![](../../../../../static/images/contribute/import-checkstyle_1.png)

![](../../../../../static/images/contribute/import-checkstyle_2.png)

#### 启用 CheckStyle

您可以在`Tools - Checkstyle - Configuration File`中将 EventMesh 的代码风格文件设置为`Active`(默认选项),否则,您需要在运行 CheckStyle 检查之前,手动指定 EventMesh 的代码风格配置。

![](../../../../../static/images/contribute/enable-checkstyle.png)

#### 使用 CheckStyle 插件

要检查当前文件的代码风格,最简单的方式是在编辑器中右键并执行`Check Current File`

![](../../../../../static/images/contribute/use-checkstyle_1.png)

它将为您在底部打开一个选项卡,您可以观察是否输出了代码风格警告。如果没有,则格式正确。

![](../../../../../static/images/contribute/use-checkstyle_2.png)

您可以进一步地在该选项卡左侧运行对当前模块和整个项目的扫描。

(注意:当您提交 PR 时,CI 将仅检查此 PR 中已更改的文件)。

#### 使用 CheckStyle 任务

您可以在 IDEA 的右侧 Gradle 选项卡中执行对某个模块或整个项目的代码风格扫描:

如果在Import Scheme下看不到CheckStyle Configuration部分,可以先安装CheckStyle-IDEA插件,就可以看到了。
![](../../../../../static/images/contribute/use-checkstyle_3.png)

您还可以使用 ./gradlew check 来检查代码风格。
(注意:此命令将检查项目中的所有文件,当您提交 pr 时,ci 将仅检查此 pr 中已更改的文件)。
您还可以在终端中使用 `./gradlew check` 来检查项目中所有文件的代码风格。

### CI 持续集成

Expand All @@ -61,7 +92,7 @@ Your Forked Repository -> Settings -> Actions -> General -> Workflow Permissions
2. clone fork到本地仓库

```git
git clone git@github.com:yourgithub/incubator-eventmesh.git
git clone git@github.com:yourgithub/eventmesh.git
```

3. 创建一个新分支并处理它
Expand All @@ -71,7 +102,7 @@ git checkout -b fix_patch_xx

4. 保持分支同步
```git
git remote add upstream git@github.com:apache/incubator-eventmesh.git
git remote add upstream git@github.com:apache/eventmesh.git
git fetch upstream master:upstream_master
git rebase upstream_master
```
Expand All @@ -80,7 +111,7 @@ git rebase upstream_master

6. 将你的提交推送到你fork的远程仓库

7. 创建pull request
7. 创建Pull Request

## 解释

Expand Down
Binary file added static/images/contribute/enable-checkstyle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/contribute/import-checkstyle_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/contribute/import-checkstyle_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/contribute/use-checkstyle_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/contribute/use-checkstyle_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/contribute/use-checkstyle_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9d7263b

Please sign in to comment.