You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by do...@apache.org on 2021/09/03 15:38:21 UTC
[orc] branch main updated: ORC-982: Extract checkstyle to a single
file, help newcomers check code style (#895)
This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/orc.git
The following commit(s) were added to refs/heads/main by this push:
new 796b8ca ORC-982: Extract checkstyle to a single file, help newcomers check code style (#895)
796b8ca is described below
commit 796b8cacfc70d4a6c5e3b5d590f8b65c0f305907
Author: Guiyanakaung <gu...@gmail.com>
AuthorDate: Fri Sep 3 23:38:13 2021 +0800
ORC-982: Extract checkstyle to a single file, help newcomers check code style (#895)
### What changes were proposed in this pull request?
Extract checkstyle to a single file.
Added tips to coding.md.
### Why are the changes needed?
[CheckStyle-IDEA](https://plugins.jetbrains.com/plugin/1065-checkstyle-idea) plugin is very simple to load this checkstyle.xml. This way you get checkstyle errors/warnings already when you are coding.
![image](https://user-images.githubusercontent.com/4069905/131971923-a08b9520-2a9d-4444-844f-a5e3e1396e57.png)
### How was this patch tested?
Pass the CIs.
---
java/checkstyle.xml | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++
java/pom.xml | 42 +--------------------------------------
site/develop/coding.md | 5 +++++
3 files changed, 60 insertions(+), 41 deletions(-)
diff --git a/java/checkstyle.xml b/java/checkstyle.xml
new file mode 100644
index 0000000..d7a84d4
--- /dev/null
+++ b/java/checkstyle.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" ?>
+<!--
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.2//EN" "https://checkstyle.org/dtds/configuration_1_2.dtd">
+
+<module name="Checker">
+ <module name="FileTabCharacter">
+ <property name="eachLine" value="true"/>
+ </module>
+ <module name="NewlineAtEndOfFile">
+ </module>
+ <module name="LineLength">
+ <property name="max" value="100"/>
+ <property name="ignorePattern" value="a href|https://|^ +\* .*$|^ *// .*$|throw new IllegalArgumentException"/>
+ </module>
+ <module name="RegexpSingleline">
+ <property name="format" value="\s+$"/>
+ <property name="message" value="No trailing white space allowed."/>
+ </module>
+ <module name="TreeWalker">
+ <module name="OuterTypeFilename"/>
+ <module name="CommentsIndentation"/>
+ <module name="UnusedImports"/>
+ <module name="RedundantImport"/>
+ <!-- https://checkstyle.sourceforge.io/config_imports.html#ImportOrder IntelliJ default example -->
+ <module name="CustomImportOrder">
+ <property name="customImportOrderRules" value="THIRD_PARTY_PACKAGE###SPECIAL_IMPORTS###STANDARD_JAVA_PACKAGE###STATIC"/>
+ <property name="specialImportsRegExp" value="^javax\."/>
+ <property name="standardPackageRegExp" value="^java\."/>
+ <property name="sortImportsInGroupAlphabetically" value="true"/>
+ <property name="separateLineBetweenGroups" value="false"/>
+ </module>
+ <module name="ModifierOrder"/>
+ <module name="RedundantModifier"/>
+ <module name="NoLineWrap"/>
+ <module name="OneStatementPerLine"/>
+ <module name="NeedBraces">
+ <property name="allowSingleLineStatement" value="true"/>
+ </module>
+ <module name="UpperEll"/>
+ <module name="ArrayTypeStyle"/>
+ </module>
+</module>
diff --git a/java/pom.xml b/java/pom.xml
index 294258d..6bf5cd2 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -279,47 +279,7 @@
<sourceDirectories>
<directory>${basedir}/src/java</directory>
</sourceDirectories>
- <checkstyleRules>
- <module name="Checker">
- <module name="FileTabCharacter">
- <property name="eachLine" value="true"></property>
- </module>
- <module name="NewlineAtEndOfFile">
- </module>
- <module name="LineLength">
- <property name="max" value="100"/>
- <property name="ignorePattern" value="a href|https://|^ +\* .*$|^ *// .*$|throw new IllegalArgumentException"/>
- </module>
- <module name="RegexpSingleline">
- <property name="format" value="\s+$"/>
- <property name="message" value="No trailing white space allowed."/>
- </module>
- <module name="TreeWalker">
- <module name="OuterTypeFilename"/>
- <module name="CommentsIndentation"/>
- <module name="UnusedImports"/>
- <module name="RedundantImport"/>
- <!-- https://checkstyle.sourceforge.io/config_imports.html#ImportOrder IntelliJ default example -->
- <module name="CustomImportOrder">
- <property name="customImportOrderRules"
- value="THIRD_PARTY_PACKAGE###SPECIAL_IMPORTS###STANDARD_JAVA_PACKAGE###STATIC"/>
- <property name="specialImportsRegExp" value="^javax\."/>
- <property name="standardPackageRegExp" value="^java\."/>
- <property name="sortImportsInGroupAlphabetically" value="true"/>
- <property name="separateLineBetweenGroups" value="false"/>
- </module>
- <module name="ModifierOrder"/>
- <module name="RedundantModifier"/>
- <module name="NoLineWrap"/>
- <module name="OneStatementPerLine"/>
- <module name="NeedBraces">
- <property name="allowSingleLineStatement" value="true"/>
- </module>
- <module name="UpperEll"/>
- <module name="ArrayTypeStyle"/>
- </module>
- </module>
- </checkstyleRules>
+ <configLocation>checkstyle.xml</configLocation>
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>
diff --git a/site/develop/coding.md b/site/develop/coding.md
index e0c36e2..efba561 100644
--- a/site/develop/coding.md
+++ b/site/develop/coding.md
@@ -35,3 +35,8 @@ title: Coding Guidelines
* Variables should be in camel case.
* Constants should be in upper case.
+## Static code analysis tool
+
+* [CheckStyle-IDEA](https://plugins.jetbrains.com/plugin/1065-checkstyle-idea)
+
+You can download this plugin to load `java/checkstyle.xml` to check the java code style. This way you get checkstyle errors/warnings already when you are coding.
\ No newline at end of file