<?xml version=”1.0″?>
<!DOCTYPE module PUBLIC
“-//Puppy Crawl//DTD Check Configuration 1.3//EN”
“http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd”>

<!–
Checkstyle configuration that checks the Google coding conventions from Google Java Style
that can be found at https://google.github.io/styleguide/javaguide.html
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.org (or in your downloaded distribution).
To completely disable a check, just comment it out or delete it from the file.
To suppress certain violations please review suppression filters.
Authors:LYQH
–>

<module name=”Checker”>
<!–
编码格式–>
<property name=”charset” value=”UTF-8″/>
<property name=”severity” value=”error”/>
<!–
文件扩展名–>
<property name=”fileExtensions” value=”java, properties,xml, vm, g, g4, dtd”/>
<!– Excludes all ‘module-info.java’ files –>
<!– See https://checkstyle.org/config_filefilters.html –>
<module name=”BeforeExecutionExclusionFileFilter”>
<property name=”fileNamePattern” value=”module\-info\.java$”/>
</module>
<!– Filters –>
<module name=”SeverityMatchFilter”>
<!– report all violations except ignore –>
<property name=”severity” value=”ignore”/>
<property name=”acceptOnMatch” value=”false”/>
</module>

<!– https://checkstyle.org/config_filters.html#SuppressionFilter –>
<module name=”SuppressionFilter”>
<property name=”file” value=”${org.checkstyle.google.suppressionfilter.config}”
default=”style_check/checkstyle-suppressions.xml”/>
</module>

<!– ++++++++++++++++Regexp+++++++++++++++++ –>
<!– Headers –>
<module name=”Header”>
<!–property name=”headerFile” value=”${checkstyle.header.file}” –>
<property name=”fileExtensions” value=”java”/>
<property name=”id” value=”header”/>
</module>
<module name=”RegexpHeader”>
<property name=”fileExtensions” value=”java”/>
</module>

<module name=”RegexpSingleline”>
<property name=”format” value=”^(?!(.*http|import)).{120,}$”/>
<property name=”fileExtensions” value=”g, g4″/>
<property name=”message” value=”Line should not be longer then 100 symbols”/>
</module>

<module name=”RegexpOnFilename”>
<property name=”folderPattern” value=”[\\/]src[\\/]xdocs[\\/]”/>
<property name=”fileNamePattern” value=”\.(xml)|(vm)$”/>
<property name=”match” value=”false”/>
<message key=”regexp.filepath.mismatch”
value=”All files in the ”src/xdocs” folder should have the ”xml” or ”vm” extension.”/>
</module>
<module name=”RegexpOnFilename”>
<property name=”folderPattern” value=”[\\/]src[\\/]it[\\/]java[\\/]”/>
<property name=”fileNamePattern” value=”^((\w+Test)|(Abstract\w+))\.java$”/>
<property name=”match” value=”false”/>
<message key=”regexp.filepath.mismatch”
value=”All files in the ”src/it/java” folder should be named ”*Test.java” or ”Abstract*.java”.”/>
</module>
<!– ++++++++++++++++Regexp+++++++++++++++++ –>

<!–++++++++++++++++++Length+++++++++++++++++++++–>
<!– 文件长度不超过1500 –>
<module name=”FileLength”>
<property name=”max” value=”1500″/>
</module>
<!–++++++++++++++++++Length+++++++++++++++++++++–>

<!–行内是否含有制表符–>
<module name=”FileTabCharacter”>
<property name=”eachLine” value=”false”/>
</module>

<!– 每个java文件一个语法树 –>
<module name=”TreeWalker”>

<module name=”PackageAnnotation”/>
<module name=”IllegalType”/>
<module name=”InnerAssignment”/>
<module name=”ModifiedControlVariable”/>
<module name=”MultipleVariableDeclarations”/>

<!–++++++++++++++++++ Length ++++++++++++++++++++++++–>
<!–tab
空格键–>
<property name=”tabWidth” value=”4″/>
<!–
每行不超过140个字符 –>
<module name=”LineLength”>
<property name=”max” value=”140″/>
</module>
<!–
方法不超过50 –>
<module name=”MethodLength”>
<property name=”tokens” value=”METHOD_DEF”/>
<property name=”max” value=”50″/>
</module>
<!–
方法的参数个数不超过5个。
并且不对构造方法进行检查–>
<module name=”ParameterNumber”>
<property name=”max” value=”10″/>
<property name=”ignoreOverriddenMethods” value=”true”/>
</module>
<!–++++++++++++++++++ Length ++++++++++++++++++++++++–>

<!–+++++++++++++++++++代码编写检查+++++++++++++++++++–>
<!– String
的比较不能用!= == –>
<module name=”StringLiteralEquality”/>
<module name=”SuperClone”/>
<!– finalize
必须调用了super.finalize() –>
<module name=”SuperFinalize”/>
<!–
一个方法中最多有3return –>
<!–<module name=”ReturnCount”>–>
<!–<property name=”max” value=”3″/>–>
<!–<property name=”format” value=”^$”/>–>
<!–</module>–>
<!–
检查数组类型定义的样式 –>
<module name=”ArrayTypeStyle”/>
<!–
检查long型定义是否有大写的“L” –>
<module name=”UpperEll”/>

<!–指定每个块类型语句(例如if,else,for)必须具有开括号和右大括号–>
<module name=”NeedBraces”/>
<module name=”NeedBraces”>
<property name=”tokens” value=”LAMBDA”/>
<property name=”allowSingleLineStatement” value=”true”/>
</module>
<!–
禁止使用System.out.println –>
<module name=”Regexp”>
<property name=”format” value=”System\.out\.println”/>
<property name=”illegalPattern” value=”true”/>
</module>
<module name=”OneTopLevelClass”/>
<module name=”NoLineWrap”>
<property name=”tokens” value=”PACKAGE_DEF, IMPORT, STATIC_IMPORT”/>
</module>
<!–
检查For周围的空白–>
<module name=”EmptyForInitializerPad”/>
<!–
检查空的迭代位置的空白–>
<module name=”EmptyForIteratorPad”/>
<module name=”GenericWhitespace”/>
<!–
允许方法名后紧跟左边圆括号“(” –>
<module name=”MethodParamPad”/>
<module name=”NoLineWrap”/>
<module name=”NoWhitespaceBefore”/>
<module name=”NoWhitespaceAfter”/>
<module name=”ParenPad”/>

<module name=”OneStatementPerLine”/>
<module name=”MultipleVariableDeclarations”/>
<module name=”ArrayTypeStyle”/>
<module name=”FallThrough”/>

<module name=”EqualsAvoidNull”/>
<!–+++++++++++++++++++
代码编写检查+++++++++++++++++++–>

<!–++++++++++++++++++ Depth ++++++++++++++++++++++++–>
<module name=”NestedForDepth”>
<property name=”max” value=”3″/>
</module>
<module name=”NestedIfDepth”>
<property name=”max” value=”5″/>
</module>
<module name=”NestedTryDepth”>
<property name=”max” value=”2″/>
</module>
<!–++++++++++++++++++ Depth ++++++++++++++++++++++++–>

<!–+++++++++++++++++++++Name+++++++++++++++++++++++++–>
<!–
每个关键字都有正确的出现顺序。比如 public static final XXX 是对一个常量的声明。如果使用 static
public final
就是错误的
–>
<module name=”ModifierOrder”/>
<!–
包名的检查(只允许小写字母),默认^[a-z]+(\.[a-zA-Z_][a-zA-Z_0-9_]*)*$ –>
<module name=”PackageName”/>
<module name=”InterfaceTypeParameterName”/>
<!– Class
Interface名检查,默认^[A-Z][a-zA-Z0-9]*$–>
<module name=”TypeName”/>
<!–
方法的参数名 –>
<module name=”ClassTypeParameterName”/>
<!–
static型变量的检查 –>
<module name=”MemberName”/>
<!–
方法名的检查 –>
<module name=”MethodName”/>
<!–
方法的参数名 –>
<module name=”ParameterName “/>
<module name=”MethodTypeParameterName”/>
<!–
常量名的检查(只允许大写),默认^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$ –>
<!–<module name=”ConstantName”/>–>
<module name=”LocalVariableName”>
<property name=”format” value=”^[a-z]([a-z0-9][a-zA-Z0-9]*)?$”/>
<message key=”name.invalidPattern”
value=”Local variable name ”{0}” must match pattern ”{1}”.”/>
</module>
<module name=”AvoidEscapedUnicodeCharacters”>
<property name=”allowEscapesForControlCharacters” value=”true”/>
<property name=”allowByTailComment” value=”true”/>
<property name=”allowNonPrintableEscapes” value=”true”/>
</module>
<!–+++++++++++++++++++++Name+++++++++++++++++++++++++–>

<!–++++++++++++++++++++++++++import+++++++++++++++++++++++++++++–>
<!–避免*型导入–>
<module name=”AvoidStarImport”/>
<!–
检查是否从非法的包中导入了类 –>
<module name=”IllegalImport”/>
<!–
检查是否导入了多余的包 –>
<module name=”RedundantImport”/>
<!–
没用的import检查,比如:1.没有被用到2.重复的3.import java.lang4.import 与该类在同一个package –>
<module name=”UnusedImports”/>
<!–++++++++++++++++++++++++++import+++++++++++++++++++++++++++++–>

<!– +++++++++++++++++++ Block +++++++++++++++++++ –>
<!– 多余的括号 –>
<module name=”AvoidNestedBlocks”>
<property name=”allowInSwitchCase” value=”true”/>
</module>
<module name=”EmptyBlock”>
<property name=”tokens” value=”LITERAL_CATCH”/>
<property name=”tokens” value=”ARRAY_INIT”/>
<property name=”tokens” value=”LITERAL_DEFAULT”/>
<property name=”tokens” value=”LITERAL_CASE”/>
<property name=”tokens” value=”INSTANCE_INIT”/>
<property name=”tokens” value=”LITERAL_DO”/>
<property name=”tokens” value=”LITERAL_ELSE”/>
<property name=”tokens” value=”LITERAL_FINALLY”/>
<property name=”tokens” value=”LITERAL_FOR”/>
<property name=”tokens” value=”LITERAL_IF”/>
<property name=”tokens” value=”LITERAL_SWITCH”/>
<property name=”tokens” value=”LITERAL_SYNCHRONIZED”/>
<property name=”tokens” value=”LITERAL_TRY”/>
<property name=”tokens” value=”LITERAL_WHILE”/>
<property name=”tokens” value=”STATIC_INIT”/>
<property name=”option” value=”text”/>
</module>
<module name=”EmptyCatchBlock”/>
<!–
不许出现空语句 –>
<module name=”EmptyStatement”/>
<!– +++++++++++++++++++ Block +++++++++++++++++++ –>

<!– +++++++++++++++++++注解++++++++++++++++++ –>
<module name=”AnnotationLocation”>
<property name=”tokens” value=”ANNOTATION_DEF”/>
<property name=”tokens” value=”ANNOTATION_FIELD_DEF”/>
<property name=”allowSamelineSingleParameterlessAnnotation” value=”false”/>
</module>
<module name=”AnnotationLocation”>
<property name=”tokens” value=”PARAMETER_DEF”/>
<property name=”allowSamelineMultipleAnnotations” value=”true”/>
</module>
<module name=”AnnotationOnSameLine”>
<!– we can not use it as it conflicts with AnnotationLocation –>
<property name=”severity” value=”ignore”/>
<property name=”tokens” value=”METHOD_DEF”/>
<property name=”tokens” value=”CTOR_DEF”/>
<property name=”tokens” value=”TYPECAST”/>
<property name=”tokens” value=”DOT”/>
<property name=”tokens” value=”CLASS_DEF”/>
<property name=”tokens” value=”ENUM_DEF”/>
<property name=”tokens” value=”INTERFACE_DEF”/>
<property name=”tokens” value=”TYPE_ARGUMENT”/>
<property name=”tokens” value=”ANNOTATION_DEF”/>
<property name=”tokens” value=”LITERAL_NEW”/>
<property name=”tokens” value=”LITERAL_THROWS”/>
<property name=”tokens” value=”VARIABLE_DEF”/>
<property name=”tokens” value=”PARAMETER_DEF”/>
<property name=”tokens” value=”IMPLEMENTS_CLAUSE”/>
<property name=”tokens” value=”ANNOTATION_FIELD_DEF”/>
</module>
<module name=”AnnotationUseStyle”>
<property name=”elementStyle” value=”ignore”/>
</module>
<module name=”PackageAnnotation”/>
<!– +++++++++++++++++++
注解++++++++++++++++++ –>

<!– +++++++++++++++++++Missing++++++++++++++++++ –>
<module name=”MissingSwitchDefault”/>
<module name=”MissingDeprecated”/>
<module name=”MissingOverride”>
<property name=”javaFiveCompatibility” value=”true”/>
</module>
<!– +++++++++++++++++++Missing++++++++++++++++++ –>

<!– +++++++++++++++++javadoc检查+++++++++++++++++++ –>
<!–<module name=”JavadocType”>–>
<!–<property name=”allowUnknownTags” value=”false”/>–>
<!–<message key=”javadoc.missing” value=”
类注释:缺少Javadoc注释。“/>–>
<!–</module>–>
<!– +++++++++++++++++javadoc
检查+++++++++++++++++++ –>

<!–+++++++++++++++++++++++whitespace+++++++++++++++++++++–>
<!–检查是否有Tab字符–>
<module name=”WhitespaceAfter”/>
<module name=”WhitespaceAround”/>
<!–+++++++++++++++++++++++whitespace+++++++++++++++++++++–>

<module name=”SeparatorWrap”>
<property name=”id” value=”SeparatorWrapDot”/>
<property name=”tokens” value=”DOT”/>
<property name=”option” value=”nl”/>
</module>
<module name=”SeparatorWrap”>
<property name=”id” value=”SeparatorWrapComma”/>
<property name=”tokens” value=”COMMA”/>
<property name=”option” value=”EOL”/>
</module>
<module name=”SeparatorWrap”>
<!– ELLIPSIS is EOL until https://github.com/google/styleguide/issues/258 –>
<property name=”id” value=”SeparatorWrapEllipsis”/>
<property name=”tokens” value=”ELLIPSIS”/>
<property name=”option” value=”EOL”/>
</module>
<module name=”SeparatorWrap”>
<!– ARRAY_DECLARATOR is EOL until https://github.com/google/styleguide/issues/259 –>
<property name=”id” value=”SeparatorWrapArrayDeclarator”/>
<property name=”tokens” value=”ARRAY_DECLARATOR”/>
<property name=”option” value=”EOL”/>
</module>
<module name=”SeparatorWrap”>
<property name=”id” value=”SeparatorWrapMethodRef”/>
<property name=”tokens” value=”METHOD_REF”/>
<property name=”option” value=”nl”/>
</module>

</module>
</module>

发表评论

邮箱地址不会被公开。 必填项已用*标注