-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add check-style plugin #1810
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1f04187
add checkstyle plugin
d06d7e6
trigger CLA check
seagle-yuan 1d603b3
merge checkstyle and intellij-java-code-style
seagle-yuan f096b98
update checkstyle.xml
seagle-yuan 96c3ab5
Merge branch 'hugegraph:master' into checkstyle-branch
seagle-yuan 8d57a41
delete unnecessary blank lines
seagle-yuan c5d0075
commented checkstyle ImportOrder module
seagle-yuan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE module PUBLIC | ||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" | ||
"https://checkstyle.org/dtds/configuration_1_3.dtd"> | ||
<!-- 参考:https://checkstyle.sourceforge.io/checks.html --> | ||
<module name="Checker"> | ||
<!--检查不通过时被判定的违规级别,必须修复后才能使build通过--> | ||
<property name="severity" value="error"/> | ||
<!--对java文件做检查--> | ||
<property name="fileExtensions" value="java"/> | ||
<!--对UTF-8编码的文件做检查--> | ||
<property name="charset" value="UTF-8"/> | ||
<!--文件中不允许包含制表符--> | ||
<module name="FileTabCharacter"> | ||
<property name="eachLine" value="true"/> | ||
</module> | ||
|
||
<!--检查java源文件并定义一些适用于检查此类文件的一些属性--> | ||
<module name="TreeWalker"> | ||
<!--检查行长度--> | ||
<module name="LineLength"> | ||
<property name="max" value="80"/> | ||
<!--可以忽略的行--> | ||
<property name="ignorePattern" | ||
value="^package.*|^import.*|a href|href|http://|https://|ftp://"/> | ||
</module> | ||
<!--检查没有import语句使用*号--> | ||
<module name="AvoidStarImport"/> | ||
<!--检查是否存在多余的import语句,比如重复的,java自带的包,相同包下的其他类--> | ||
<module name="RedundantImport"/> | ||
<!--检查是否存在没有使用的import语句--> | ||
<module name="UnusedImports"/> | ||
<!--检查包名称是否遵守命名规约--> | ||
<module name="PackageName"> | ||
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/> | ||
</module> | ||
<!--检查局部变量的名称是否遵守命名规约--> | ||
<module name="LocalVariableName"> | ||
<property name="format" value="^[a-z][a-zA-Z0-9_]*$"/> | ||
</module> | ||
<!--检查成员变量(非静态字段)的名称是否遵守命名规约--> | ||
<module name="MemberName"> | ||
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/> | ||
</module> | ||
<!--检查方法名称是否遵守命名规约--> | ||
<module name="MethodName"> | ||
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/> | ||
</module> | ||
<!--检查参数名称是否遵守命名规约--> | ||
<module name="ParameterName"> | ||
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/> | ||
</module> | ||
<!--检查常量(用static final修饰的字段)的名称是否遵守命名规约--> | ||
<module name="ConstantName"> | ||
<property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/> | ||
</module> | ||
<!--检查数组是否属于java风格,方括号放在类型后面,而不是变量后面,比如:int[] nums(合法),int nums[](不合法)--> | ||
<module name="ArrayTypeStyle"> | ||
<property name="javaStyle" value="true"/> | ||
</module> | ||
<!--long类型的字面量如果要以"L"结尾,必须是大写的"L",而非小写的"l"--> | ||
<module name="UpperEll"/> | ||
<!--代码换行时,运算符必须在当前行的末尾,比如:+、&&、?、: 等--> | ||
<module name="OperatorWrap"> | ||
<property name="option" value="eol"/> | ||
</module> | ||
<!--检查指定标记的周围是否有空格,比如:if、for、while、synchoronized 等--> | ||
<module name="WhitespaceAround"/> | ||
<!--左圆括号之后和右圆括号之前是否需要有一个空格,不需要--> | ||
<module name="ParenPad"/> | ||
<!--检查修饰符是否符合Java建议,顺序是:public、protected、private、abstract、default、static、final、transient、volatile、synchronized、native、strictfp--> | ||
<module name="ModifierOrder"/> | ||
<!--检查代码块的左花括号的放置位置,必须在当前行的末尾--> | ||
<module name="LeftCurly"> | ||
<property name="option" value="eol"/> | ||
<property name="ignoreEnums" value="false"/> | ||
</module> | ||
<!--代码中不允许有空语句,也就是单独的;符号--> | ||
<module name="EmptyStatement"/> | ||
<!--覆盖equals()方法的类必须也覆盖了hashCode()方法--> | ||
<module name="EqualsHashCode"/> | ||
<!--switch语句必须含有default子句--> | ||
<module name="MissingSwitchDefault"/> | ||
<!--switch语句的default必须放在所有的case分支之后--> | ||
<module name="DefaultComesLast"/> | ||
<!--覆盖clone()方法时调用了super.clone()方法--> | ||
<module name="SuperClone"/> | ||
</module> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<code_scheme name="hugegraph-style" version="173"> | ||
<option name="LINE_SEPARATOR" value="
" /> | ||
<option name="RIGHT_MARGIN" value="80" /> | ||
<option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="true" /> | ||
<option name="SOFT_MARGINS" value="80" /> | ||
<JavaCodeStyleSettings> | ||
<option name="ANNOTATION_PARAMETER_WRAP" value="1" /> | ||
<option name="ALIGN_MULTILINE_ANNOTATION_PARAMETERS" value="true" /> | ||
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="100" /> | ||
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="100" /> | ||
<option name="IMPORT_LAYOUT_TABLE"> | ||
<value> | ||
<package name="" withSubpackages="true" static="true" /> | ||
<emptyLine /> | ||
<package name="java" withSubpackages="true" static="false" /> | ||
<emptyLine /> | ||
<package name="javax" withSubpackages="true" static="false" /> | ||
<emptyLine /> | ||
<package name="org" withSubpackages="true" static="false" /> | ||
<emptyLine /> | ||
<package name="com" withSubpackages="true" static="false" /> | ||
<emptyLine /> | ||
<package name="" withSubpackages="true" static="false" /> | ||
</value> | ||
</option> | ||
</JavaCodeStyleSettings> | ||
<XML> | ||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" /> | ||
</XML> | ||
<codeStyleSettings language="JAVA"> | ||
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" /> | ||
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" /> | ||
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" /> | ||
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" /> | ||
<option name="ALIGN_MULTILINE_ASSIGNMENT" value="true" /> | ||
<option name="ALIGN_MULTILINE_TERNARY_OPERATION" value="true" /> | ||
<option name="ALIGN_MULTILINE_THROWS_LIST" value="true" /> | ||
<option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" /> | ||
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" /> | ||
<option name="CALL_PARAMETERS_WRAP" value="1" /> | ||
<option name="METHOD_PARAMETERS_WRAP" value="1" /> | ||
<option name="RESOURCE_LIST_WRAP" value="1" /> | ||
<option name="EXTENDS_LIST_WRAP" value="1" /> | ||
<option name="THROWS_LIST_WRAP" value="1" /> | ||
<option name="METHOD_CALL_CHAIN_WRAP" value="1" /> | ||
<option name="BINARY_OPERATION_WRAP" value="1" /> | ||
<option name="TERNARY_OPERATION_WRAP" value="1" /> | ||
<option name="FOR_STATEMENT_WRAP" value="1" /> | ||
<option name="ARRAY_INITIALIZER_WRAP" value="1" /> | ||
<option name="ASSIGNMENT_WRAP" value="1" /> | ||
<option name="ASSERT_STATEMENT_WRAP" value="1" /> | ||
<option name="IF_BRACE_FORCE" value="1" /> | ||
<option name="DOWHILE_BRACE_FORCE" value="3" /> | ||
<option name="WHILE_BRACE_FORCE" value="1" /> | ||
<option name="FOR_BRACE_FORCE" value="1" /> | ||
<option name="WRAP_LONG_LINES" value="true" /> | ||
<option name="PARAMETER_ANNOTATION_WRAP" value="1" /> | ||
<option name="ENUM_CONSTANTS_WRAP" value="2" /> | ||
<indentOptions> | ||
<option name="SMART_TABS" value="true" /> | ||
</indentOptions> | ||
</codeStyleSettings> | ||
</code_scheme> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems we already have one code-style file (in dir root), u could update that directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your reminder,I have noticed this problems.
first i will delete "style/intellij-java-code-style.xml"
and then can you review "code/checkstyle.xml"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, if u update in the old file, we could see the diff easily