## *Backgroud*
Now we lack code format for our source code. This will cause the code
repository to be filled with lots of code styles.

*## Proposal*
I propose to involve the 'spotless' plugin to do code formatting. Some
Apache projects have already added this plugin for code formatting, such as
Apache Flink.

the spotless plugin will help to some format, such as:
* remove unused imports
* order the imports
* remove unnecessary blanks and spaces
* ...

More details can be found here:
https://github.com/diffplug/spotless/blob/main/plugin-gradle/README.md

*## How to use*
Once involved the plugin, we can use it as:
* format code: "mvn spotless:apply"
* check: "mvn spotless:check"

We can ref the pending PR:
https://github.com/apache/incubator-linkis/pull/1244,to see how "spotless"
will affect Linkis code.

Thanks.
Kelu.
------
## *背景*
目前代码仓库中缺少一个统一的代码格式化工具,导致项目仓库中的代码风格不统一。

*## 提议*
提议使用 spotless 插件来格式化代码,目前有些 Apache 项目也使用了 spotless 插件,比如 Apache Flink.

Spotless 可以帮忙我们做如下的一些格式化操作,比如:
* 移除没有使用的 import
* 对 package 的 import 进行排序
* 移除不必要的空行和空格
* ...

更多详细信息可以参考:
https://github.com/diffplug/spotless/blob/main/plugin-gradle/README.md


*## 使用*
引入了插件之后,可以像如下方式使用:
* 代码格式化: "mvn spotless:apply"
* 代码检查: "mvn spotless:check"

大家可以参考这个 PR 查看 Spotless 引入到 Linkis 项目代码之后的改动:
https://github.com/apache/incubator-linkis/pull/1244




-- 

Hello, Find me here: www.legendtkl.com.

Reply via email to