You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/05/08 14:44:07 UTC

[shardingsphere] branch master updated: Supplement relevant instructions and profile of spotless (#17453)

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

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 969d0e597a7 Supplement relevant instructions and profile of spotless (#17453)
969d0e597a7 is described below

commit 969d0e597a76c78e21f346b37e49f86d9cb72997
Author: 龙台 Long Tai <77...@users.noreply.github.com>
AuthorDate: Sun May 8 22:43:59 2022 +0800

    Supplement relevant instructions and profile of spotless (#17453)
    
    * Change the name of the spotless code format file
    
    * Add spotless description
    
    * Add spotless maven profile
    
    * Change the instructions for the use of spotless
---
 .../content/contribute/code-conduct.cn.md          |  3 +-
 .../content/contribute/code-conduct.en.md          |  3 +-
 pom.xml                                            | 99 ++++++++++++----------
 ...r.xml => spotless_shardingsphere_formatter.xml} |  0
 4 files changed, 55 insertions(+), 50 deletions(-)

diff --git a/docs/community/content/contribute/code-conduct.cn.md b/docs/community/content/contribute/code-conduct.cn.md
index 470c2ead016..d2c917ffaae 100644
--- a/docs/community/content/contribute/code-conduct.cn.md
+++ b/docs/community/content/contribute/code-conduct.cn.md
@@ -23,12 +23,11 @@ chapter = true
  - 应尽量将设计精细化拆分;做到小幅度修改,多次数提交,但应保证提交的完整性。
  - 确保遵守编码规范。
  - 如果您使用 IDEA,可导入推荐的 [Settings](https://shardingsphere.apache.org/community/data/shardingsphere-settings.jar)。
+ - 通过 Spotless 统一代码风格,执行 Maven 命令时添加 `-Pcode.format`。
  
 ## 编码规范
 
  - 使用 linux 换行符。
- - 缩进(包含空行)和上一行保持一致。
- - 类声明后与下面的变量或方法之间需要空一行。
  - 不应有无意义的空行。请提炼私有方法,代替方法体过长或代码段逻辑闭环而采用的空行间隔。
  - 类、方法和变量的命名要做到顾名思义,避免使用缩写。
  - 返回值变量使用 `result` 命名;循环中使用 `each` 命名循环变量;map 中使用 `entry` 代替 `each`。
diff --git a/docs/community/content/contribute/code-conduct.en.md b/docs/community/content/contribute/code-conduct.en.md
index 930d073a1d3..a52b12f4915 100644
--- a/docs/community/content/contribute/code-conduct.en.md
+++ b/docs/community/content/contribute/code-conduct.en.md
@@ -20,12 +20,11 @@ The following code of conduct is based on full compliance with [ASF CODE OF COND
  - Careful consideration for each `pull request`; Small and frequent `pull request` with complete unit function is welcomed.
  - Conform to `Contributor Covenant Code of Conduct` below.
  - If using IDEA, you can import the recommended [Settings](https://shardingsphere.apache.org/community/data/shardingsphere-settings.jar).
+ - Through the uniform code style of spotless, add `-Pcode.format` when executing Maven command.
 
 ## Contributor Covenant Code of Conduct
 
  - Use linux line separators.
- - Keep indents (including blank lines) consistent with the previous one.
- - Keep one blank line after class definition.
  - No meaningless blank lines. Please extract private methods to instead of blank lines if too long method body or different logic code fragments.
  - Use meaningful class, method and variable names, avoid to use abbreviate. 
  - Return values are named with `result`; Variables in the loop structure are named with `each`; Replace `each` with `entry` in map.
diff --git a/pom.xml b/pom.xml
index 59808d51165..c59cf129c24 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1030,52 +1030,6 @@
                     </execution>
                 </executions>
             </plugin>
-            <plugin>
-                <groupId>com.diffplug.spotless</groupId>
-                <artifactId>spotless-maven-plugin</artifactId>
-                <version>${spotless-maven-plugin.version}</version>
-                <configuration>
-                    <java>
-                        <eclipse>
-                            <file>${maven.multiModuleProjectDirectory}/src/resources/shardingsphere_eclipse_formatter.xml</file>
-                        </eclipse>
-                        <licenseHeader>
-                            <file>${maven.multiModuleProjectDirectory}/src/resources/license-header</file>
-                        </licenseHeader>
-                    </java>
-                    <pom>
-                        <sortPom>
-                            <encoding>UTF-8</encoding>
-                            <nrOfIndentSpace>4</nrOfIndentSpace>
-                            <keepBlankLines>true</keepBlankLines>
-                            <indentBlankLines>true</indentBlankLines>
-                            <indentSchemaLocation>true</indentSchemaLocation>
-                            <spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
-                            <sortModules>false</sortModules>
-                            <sortExecutions>false</sortExecutions>
-                            <predefinedSortOrder>custom_1</predefinedSortOrder>
-                            <expandEmptyElements>false</expandEmptyElements>
-                            <sortProperties>false</sortProperties>
-                        </sortPom>
-                        <replace>
-                            <name>Leading blank line</name>
-                            <search>--&gt;
-&lt;project</search>
-                            <replacement>--&gt;
-
-&lt;project</replacement>
-                        </replace>
-                    </pom>
-                </configuration>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>apply</goal>
-                        </goals>
-                        <phase>compile</phase>
-                    </execution>
-                </executions>
-            </plugin>
             <plugin>
                 <artifactId>maven-checkstyle-plugin</artifactId>
                 <version>${maven-checkstyle-plugin.version}</version>
@@ -1345,5 +1299,58 @@
                 </pluginManagement>
             </build>
         </profile>
+        <profile>
+            <id>code.format</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>com.diffplug.spotless</groupId>
+                        <artifactId>spotless-maven-plugin</artifactId>
+                        <version>${spotless-maven-plugin.version}</version>
+                        <configuration>
+                            <java>
+                                <eclipse>
+                                    <file>${maven.multiModuleProjectDirectory}/src/resources/spotless_shardingsphere_formatter.xml</file>
+                                </eclipse>
+                                <licenseHeader>
+                                    <file>${maven.multiModuleProjectDirectory}/src/resources/license-header</file>
+                                </licenseHeader>
+                            </java>
+                            <pom>
+                                <sortPom>
+                                    <encoding>UTF-8</encoding>
+                                    <nrOfIndentSpace>4</nrOfIndentSpace>
+                                    <keepBlankLines>true</keepBlankLines>
+                                    <indentBlankLines>true</indentBlankLines>
+                                    <indentSchemaLocation>true</indentSchemaLocation>
+                                    <spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
+                                    <sortModules>false</sortModules>
+                                    <sortExecutions>false</sortExecutions>
+                                    <predefinedSortOrder>custom_1</predefinedSortOrder>
+                                    <expandEmptyElements>false</expandEmptyElements>
+                                    <sortProperties>false</sortProperties>
+                                </sortPom>
+                                <replace>
+                                    <name>Leading blank line</name>
+                                    <search>--&gt;
+&lt;project</search>
+                                    <replacement>--&gt;
+
+&lt;project</replacement>
+                                </replace>
+                            </pom>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>apply</goal>
+                                </goals>
+                                <phase>compile</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
     </profiles>
 </project>
diff --git a/src/resources/shardingsphere_eclipse_formatter.xml b/src/resources/spotless_shardingsphere_formatter.xml
similarity index 100%
rename from src/resources/shardingsphere_eclipse_formatter.xml
rename to src/resources/spotless_shardingsphere_formatter.xml