Skip to content

Commit 6a02870

Browse files
authored
[Feature][style] Add spotless maven plugin for automatic style fix. (apache#11272)
* [Feature][style] Add spotless maven plugin for automatic style fix (apache#10963) * Fix spotless ratchet configuration * Remove license-check and decrease line length threshold value * Update related docs * Remove checkstyle and add pre-commit hook * Test updated pre-commit hook * Replace checkstyle with spotless in CI * Remove reviewdog
1 parent bf5f7a8 commit 6a02870

File tree

12 files changed

+543
-776
lines changed

12 files changed

+543
-776
lines changed

Diff for: .github/actions/reviewdog-setup

-1
This file was deleted.

Diff for: .github/actions/sanity-check/action.yml

+1-16
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,5 @@ runs:
3434
- name: Check License Header
3535
uses: apache/skywalking-eyes@30367d8286e324d5efc58de4c70c37ea3648306d
3636

37-
- uses: ./.github/actions/reviewdog-setup
38-
with:
39-
reviewdog_version: v0.10.2
40-
41-
- shell: bash
42-
run: ./mvnw -B -q checkstyle:checkstyle-aggregate
43-
4437
- shell: bash
45-
env:
46-
REVIEWDOG_GITHUB_API_TOKEN: ${{ inputs.token }}
47-
run: |
48-
if [[ -n "${{ inputs.token }}" ]]; then
49-
reviewdog -f=checkstyle \
50-
-reporter="github-pr-review" \
51-
-filter-mode="added" \
52-
-fail-on-error="true" < target/checkstyle-result.xml
53-
fi
38+
run: ./mvnw spotless:check

Diff for: .gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,3 @@
2121
[submodule ".github/actions/translate-on-issue"]
2222
path = .github/actions/translate-on-issue
2323
url = https://github.com/xingchun-chen/translation-helper
24-
[submodule ".github/actions/reviewdog-setup"]
25-
path = .github/actions/reviewdog-setup
26-
url = https://github.com/reviewdog/action-setup

Diff for: .licenserc.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ header:
4444
- '**/NOTICE'
4545
- '**/node_modules/**'
4646
- '.github/actions/comment-on-issue/**'
47-
- '.github/actions/reviewdog-setup/**'
4847
- '.github/actions/translate-on-issue/**'
4948
- '**/.gitkeep'
5049

Diff for: docs/docs/en/contribute/development-environment-setup.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,28 @@ cd dolphinscheduler
1919
git clone [email protected]:apache/dolphinscheduler.git
2020
```
2121

22-
### compile source code
22+
### Compile Source Code
2323

2424
Supporting system:
2525
* MacOS
2626
* Liunx
2727

2828
Run `mvn clean install -Prelease -Dmaven.test.skip=true`
2929

30+
### Code Style
31+
32+
DolphinScheduler uses `Spotless` for code style and formatting checks.
33+
You could run the following command and `Spotless` will automatically fix
34+
the code style and formatting errors for you:
35+
36+
```shell
37+
./mvnw spotless:apply
38+
```
39+
40+
You could copy the `pre-commit hook` file `/style/pre-commit` to your `.git/hooks/`
41+
directory so that every time you commit your code with `git commit`, `Spotless` will automatically
42+
fix things for you.
43+
3044
## Docker image build
3145

3246
DolphinScheduler will release new Docker images after it released, you could find them in [Docker Hub](https://hub.docker.com/search?q=DolphinScheduler).

Diff for: docs/docs/zh/contribute/development-environment-setup.md

+13
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ git clone [email protected]:apache/dolphinscheduler.git
2727

2828
运行 `mvn clean install -Prelease -Dmaven.test.skip=true`
2929

30+
31+
### 代码风格
32+
33+
DolphinScheduler使用`Spotless`检查并修复代码风格和格式问题。
34+
您可以执行如下的命令,`Spotless`将会为您自动检查并修复代码风格和格式问题。
35+
36+
```shell
37+
./mvnw spotless:apply
38+
```
39+
40+
您可将`/style/pre-commit`目录下的`pre-commit hook`文件拷贝到您的`.git/hooks/`
41+
目录下,这样您每次使用`git commit`命令时,`Spotless`将会自动为您修复代码风格和格式问题。
42+
3043
## Docker镜像构建
3144

3245
DolphinScheduler 每次发版都会同时发布 Docker 镜像,你可以在 [Docker Hub](https://hub.docker.com/search?q=DolphinScheduler) 中找到这些镜像

Diff for: dolphinscheduler-api-test/pom.xml

-32
Original file line numberDiff line numberDiff line change
@@ -138,38 +138,6 @@
138138
<artifactId>maven-surefire-plugin</artifactId>
139139
<version>2.22.2</version>
140140
</plugin>
141-
<plugin>
142-
<groupId>org.apache.maven.plugins</groupId>
143-
<artifactId>maven-checkstyle-plugin</artifactId>
144-
<version>${checkstyle.version}</version>
145-
<dependencies>
146-
<dependency>
147-
<groupId>com.puppycrawl.tools</groupId>
148-
<artifactId>checkstyle</artifactId>
149-
<version>8.45</version>
150-
</dependency>
151-
</dependencies>
152-
<configuration>
153-
<consoleOutput>true</consoleOutput>
154-
<encoding>UTF-8</encoding>
155-
<configLocation>../style/checkstyle.xml</configLocation>
156-
<failOnViolation>true</failOnViolation>
157-
<violationSeverity>warning</violationSeverity>
158-
<includeTestSourceDirectory>true</includeTestSourceDirectory>
159-
<sourceDirectories>
160-
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
161-
</sourceDirectories>
162-
<excludes>**\/generated-sources\/</excludes>
163-
</configuration>
164-
<executions>
165-
<execution>
166-
<phase>compile</phase>
167-
<goals>
168-
<goal>check</goal>
169-
</goals>
170-
</execution>
171-
</executions>
172-
</plugin>
173141
</plugins>
174142
</build>
175143
</project>

Diff for: dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTask.java

+6-9
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,23 @@
1717

1818
package org.apache.dolphinscheduler.plugin.task.jupyter;
1919

20-
20+
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
21+
import org.apache.dolphinscheduler.spi.utils.PropertyUtils;
22+
import org.apache.dolphinscheduler.spi.utils.StringUtils;
23+
import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
24+
import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
2125
import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
2226
import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
2327
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
28+
2429
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
2530
import org.apache.dolphinscheduler.plugin.task.api.model.Property;
2631
import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
2732
import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
28-
import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
29-
import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
30-
import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
3133
import org.apache.dolphinscheduler.spi.utils.DateUtils;
32-
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
33-
import org.apache.dolphinscheduler.spi.utils.PropertyUtils;
34-
import org.apache.dolphinscheduler.spi.utils.StringUtils;
3534

3635
import java.io.IOException;
3736
import java.util.ArrayList;
38-
import java.util.HashMap;
3937
import java.util.List;
4038
import java.util.Map;
4139

@@ -152,7 +150,6 @@ protected String buildCommand() throws IOException {
152150
return command;
153151
}
154152

155-
156153
/**
157154
* build jupyter parameterization
158155
*

0 commit comments

Comments
 (0)