Checkstyle检查规则文档

Checkstyle检查规则文档

检查规则

一、 Annotations:注解。

比如deprecad、override、Suppress Warnings等注解符号以及注解风格使用等。

1. 注解位置检查:AnnotationLocation

【Since Checkstyle 6.0】

Checks location of annotation on language elements.

注解在语言元素上的位置。

2. 注解位于同一行:AnnotationOnSameLine

【Since Checkstyle 8.2】

Checks that annotations are located on the same line with their targets.

检查注解是否与其目标位于同一行。

3. 注解使用样式:AnnotationUseStyle

【Since Checkstyle 5.0】

Checks the style of elements in annotations.

注解使用样式

4. 缺失@Deprecated注解:MissingDeprecated

【Since Checkstyle 5.0】

Verifies that the annotation @Deprecated and the Javadoc tag @deprecated are both present when either of them is present.

验证注解@Deprecated和Javadoc标记@deprecated是否都存在。

5. 缺失@Override:MissingOverride

【Since Checkstyle 5.0】

Verifies that the @Override annotation is present when the @inheritDoc javadoc tag is present.

验证@inheritDoc javadoc标记存在时是否存在@Override注解。

6. 包注解:PackageAnnotation

【Since Checkstyle 5.0】

Checks that all package annotations are in the package-info.java file.

检查所有包注解是否位于package-info.java文件中。

7. @SuppressWarnings注解:SuppressWarnings

【Since Checkstyle 5.0】

Allows to specify what warnings that @SuppressWarnings is not allowed to suppress.

允许指定不允许@SuppressWarnings抑制的警告。

8. SuppressWarningsHolder

【Since Checkstyle 5.7】

allows to prevent Checkstyle from reporting violations from parts of code that were annotated with @SuppressWarnings and using name of the check to be excluded. It is possible to suppress all the checkstyle warnings with the argument “all”.

允许防止Checkstyle报告带有@SuppressWarnings注释的代码部分的违规,并使用被排除的检查的名称。使用参数"all"可以抑制所有的检查样式警告。

二、 Block Checks:代码块检测。

比如代码块嵌套、空代码块等代码块问题。

1. 避免嵌套块查找嵌套块:AvoidNestedBlocks

【Since Checkstyle 3.1】

Finds nested blocks (blocks that are used freely in the code).

避免嵌套块查找嵌套块(代码中可以自由使用的块)。

2. 空区块:EmptyBlock

【Since Checkstyle 3.0】

Checks for empty blocks.

查空区块。

3. 空捕获块:EmptyCatchBlock

【Since Checkstyle 6.4】

Checks for empty catch blocks.

检查是否有空的捕获块。

4. 左大括号:LeftCurly

【Since Checkstyle 3.0】

Checks for the placement of left curly braces (‘{’) for code blocks.

检查代码块的左大括号(“{”)的位置。

5. 需要大括号:NeedBraces

【Since Checkstyle 3.0】

Checks for braces around code blocks.

检查代码块周围的大括号。

6. 右大括号:RightCurly

【Since Checkstyle 3.0】

Checks the placement of right curly braces (‘}’) for code blocks.

检查代码块的右大括号(“}”)的位置。

三、 Class Design:类设计。

比如类的修饰符,设计扩展性,构造函数等相关的问题。

1. 扩展设计:DesignForExtension

【Since Checkstyle 3.1】

Checks that classes are designed for extension (subclass creation).

检查类是否为扩展(子类创建)而设计。

2. final类:FinalClass

【Since Checkstyle 3.1】

Checks that a class that has only private constructors and has no descendant classes is declared as final.

检查只有私有构造方法且没有子类的类是否声明为final。

3. 隐藏工具类构造方法:HideUtilityClassConstructor

【Since Checkstyle 3.1】

Makes sure that utility classes (classes that contain only static methods or fields in their API) do not have a public constructor.

确保工具类(在其API中仅包含静态方法或字段的类)没有公共构造方法。

4. 内部类型声明在后面:InnerTypeLast

【Since Checkstyle 5.2】

Checks nested (internal) classes/interfaces are declared at the bottom of the primary (top-level) class after all init and static init blocks, method, constructor and field declarations.

检查嵌套(内部)类/接口是否在所有init和静态init块、方法、构造方法和字段声明之后在主(顶级)类的底部声明。

5. 接口定义类型:InterfaceIsType

【Since Checkstyle 3.1】

Implements Joshua Bloch, Effective Java, Item 17 - Use Interfaces only to define types.

实现Joshua Bloch,有效Java,第17项-仅使用接口定义类型。

6. 可变异常:MutableException

【Since Checkstyle 3.2】

Ensures that exception classes (classes with names conforming to some pattern and explicitly extending classes with names conforming to other pattern) are immutable, that is, that they have only final fields.

确保异常类(名称符合某种模式的类和名称符合其他模式的显式扩展类)是不可变的,即它们只有final字段。

7. 一个顶级类:OneTopLevelClass

【Since Checkstyle 5.8】

Checks that each top-level class, interface, enum or annotation resides in a source file of its own.

检查每个顶级类、接口、枚举或注解是否驻留在自己的源文件中。

8. throws计数:ThrowsCount

【Since Checkstyle 3.2】

Restricts throws statements to a specified count.

限制throws语句的数量。

9. 可见性修饰符:VisibilityModifier

【Since Checkstyle 3.0】

Checks visibility of class members.

检查类成员的可见性。

四、 Coding:编码问题。

代码中出现的漏洞,性能,冗余等代码相关的问题。

1. 数组尾部逗号:ArrayTrailingComma

【Since Checkstyle 3.2】

Checks that array initialization contains a trailing comma.

检查数组初始化是否包含尾部逗号。

2. 避免双大括号初始化:AvoidDoubleBraceInitialization

【Since Checkstyle 8.30】

Detects double brace initialization.

检测双大括号初始化。

3. 避免内联条件:AvoidInlineConditionals

【Since Checkstyle 3.1】

Detects inline conditionals.

检测内联条件。

4. 避免无参数父构造方法调用:AvoidNoArgumentSuperConstructorCall

【Since Checkstyle 8.29】

Checks if call to superclass constructor without arguments is present.

检查是否存在对无参数的父构造方法的调用。

5. 重写equals方法:CovariantEquals

【Since Checkstyle 3.2】

Checks that classes and records which define a covariant equals() method also override method equals(Object).

检查重写equals()方法的类和记录是否也重写了equals(Object)方法。

6. 声明顺序:DeclarationOrder

【Since Checkstyle 3.2】

Checks that the parts of a class, record, or interface declaration appear in the order suggested by the Code Conventions for the Java Programming Language.

检查类、记录或接口声明的部分是否按Java编程语言代码惯例建议的顺序排列。

7. default最后出现:DefaultComesLast

【Since Checkstyle 3.4】

Check that the default is after all the cases in a switch statement.

检查default是否在switch语句中的所有case之后。

8. 空语句:EmptyStatement

【Since Checkstyle 3.1】

Detects empty statements (standalone “;” semicolon).

检测空语句(独立的";"分号)。

9. equals比较时避免null:EqualsAvoidNull

【Since Checkstyle 5.0】

Checks that any combination of String literals is on the left side of an equals() comparison.

检查字符串文本的任何组合是否位于equals()比较的左侧。

10. equals和hashCode方法:EqualsHashCode

【Since Checkstyle 3.0】

Checks that classes that either override equals() or hashCode() also overrides the other.

检查重写equals()的类是否也重写了hashCode()方法。

11. 显式初始化:ExplicitInitialization

【Since Checkstyle 3.2】

Checks if any class or object member is explicitly initialized to default for its type value (null for object references, zero for numeric types and char and false for boolean.)

检查是否将任何类或对象成员显式初始化为其类型值的默认值(对象引用为null,数字类型为0,布尔值为false)。

12. 漏写:FallThrough

【Since Checkstyle 3.4】

Checks for fall-through in switch statements.

检查switch语句中的漏写。

13. final局部变量:FinalLocalVariable

【Since Checkstyle 3.2】

Checks that local variables that never have their values changed are declared final.

检查从未更改其值的局部变量是否声明为final。

14. 隐藏字段:HiddenField

【Since Checkstyle 3.0】

Checks that a local variable or a parameter does not shadow a field that is defined in the same class.

检查局部变量或参数是否覆盖在同一类中定义的字段。

15. 非法捕获:IllegalCatch

【Since Checkstyle 3.2】

Checks that certain exception types do not appear in a catch statement.

检查某些异常类型是否未出现在catch语句中。

16. 非法实例化:IllegalInstantiation

【Since Checkstyle 3.0】

Checks for illegal instantiations where a factory method is preferred.

检查首选工厂方法的非法实例化。

17. 非法抛出异常:IllegalThrows

【Since Checkstyle 4.0】

Checks that specified types are not declared to be thrown.

检查指定的类型是否未声明为可抛出异常。

18. 非法令牌:IllegalToken

【Since Checkstyle 3.2】

Checks for illegal tokens.

检查非法令牌。

19. 非法令牌文本:IllegalTokenText

【Since Checkstyle 3.2】

Checks specified tokens text for matching an illegal pattern.

检查指定的标记文本是否与非法模式匹配。

20. 非法类型:IllegalType【

Since Checkstyle 3.2】

Checks that particular classes or interfaces are never used.

检查是否从未使用特定的类或接口。

21. 内部赋值:InnerAssignment

【Since Checkstyle 3.0】

Checks for assignments in subexpressions, such as in String s = Integer.toString(i = 2);.

检查子表达式中的赋值,例如String s = Integer.toString(i = 2);中的赋值。

22. 魔法数字:MagicNumber

【Since Checkstyle 3.1】

Checks that there are no “magic numbers” where a magic number is a numeric literal that is not defined as a constant.

检查是否没有“魔法数字”,其中魔法数字是未定义为常量的数字。

23. 匹配Xpath:MatchXpath

【Since Checkstyle 8.39】

Evaluates Xpath query and report violation on all matching AST nodes.

评估所有匹配AST节点上的Xpath查询和报告冲突。

24. 缺失构造方法:MissingCtor

【Since Checkstyle 3.4】

Checks that classes (except abstract ones) define a constructor and don’t rely on the default one.

检查类(抽象类除外)是否定义构造方法,并且不依赖默认构造方法。

25. switch中缺失default:MissingSwitchDefault

【Since Checkstyle 3.1】

Checks that switch statement has a default clause.

检查switch语句是否具有default子句。

26. 修改的控制变量:ModifiedControlVariable

【Since Checkstyle 3.5】

Checks that for loop control variables are not modified inside the for block.

检查for循环控制变量是否未在for块内修改。

27. 多个字符串字面值:MultipleStringLiterals

【Since Checkstyle 3.5】

Checks for multiple occurrences of the same string literal within a single file.

检查同一字符串字面值在单个文件中是否多次出现。

28. 多个变量声明:MultipleVariableDeclarations

【Since Checkstyle 3.4】

Checks that each variable declaration is in its own statement and on its own line.

检查每个变量声明是否在其自己的语句中并位于其自己的行上。

29. 嵌套的深度:NestedForDepth

【Since Checkstyle 5.3】

Restricts nested for blocks to a specified depth.

将块的嵌套限制为指定深度。

30. 嵌套if深度:NestedIfDepth

【Since Checkstyle 3.2】

Restricts nested if-else blocks to a specified depth.

将嵌套的if-else块限制为指定的深度。

31. 嵌套try深度:NestedTryDepth

【Since Checkstyle 3.2】

Restricts nested try-catch-finally blocks to a specified depth.

将嵌套的try-catch-finally块限制到指定的深度。

32. 无数组尾随逗号:NoArrayTrailingComma

【Since Checkstyle 8.28】

Checks that array initialization do not contain a trailing comma.

检查数组初始化是否不包含尾随逗号。

33. 不克隆:NoClone

【Since Checkstyle 5.0】

Checks that the clone method is not overridden from the Object class.

检查克隆方法是否未从Object类重写。

34. 无枚举尾随逗号:NoEnumTrailingComma

【Since Checkstyle 8.29】

Checks that enum definition does not contain a trailing comma.

检查枚举定义是否不包含尾随逗号。

35. 无finalize():NoFinalizer

【Since Checkstyle 5.0】

Checks that there is no method finalize with zero parameters.

检查文件中是否没有方法finalize()。

36. 每行一个语句:OneStatementPerLine

【Since Checkstyle 5.3】

Checks that there is only one statement per line.

检查每行只有一条语句。

37. 重载方法声明顺序:OverloadMethodsDeclarationOrder

【Since Checkstyle 5.8】

Checks that overloaded methods are grouped together.

检查重载方法是否分组在一起。

38. 包声明:PackageDeclaration

【Since Checkstyle 3.2】

Ensures that a class has a package declaration, and (optionally) whether the package name matches the directory name for the source file.

确保类具有包声明,以及(可选)包名称是否与源文件的目录名称匹配。

39. 参数赋值:ParameterAssignment

【Since Checkstyle 3.2】

Disallows assignment of parameters.

不允许给参数赋值。

40. 需要this关键字:RequireThis

【Since Checkstyle 3.4】

Checks that references to instance variables and methods of the present object are explicitly of the form “this.varName” or “this.methodName(args)” and that those references don’t rely on the default behavior when “this.” is absent.

检查对当前对象的实例变量和方法的引用是否显式采用“this.varName”或“this.methodName(args)”的形式,并且当缺少“this.”时,这些引用不依赖默认行为。

41. 返回计数:ReturnCount

【Since Checkstyle 3.2】

Restricts the number of return statements in methods, constructors and lambda expressions.

限制方法、构造方法和lambda表达式中返回语句的数量。

42. 简化布尔表达式:SimplifyBooleanExpression

【Since Checkstyle 3.0】

Checks for over-complicated boolean expressions.

检查过于复杂的布尔表达式。

43. 简化布尔返回:SimplifyBooleanReturn

【Since Checkstyle 3.0】

Checks for over-complicated boolean return statements.

检查过于复杂的布尔返回语句。

44. 字符串文字相等:StringLiteralEquality

【Since Checkstyle 3.2】

Checks that string literals are not used with == or !=.

检查字符串文字是否未与==或!=一起使用。

45. super.clone()方法:SuperClone

【Since Checkstyle 3.2】

Checks that an overriding clone() method invokes super.clone().

检查重写clone()方法时是否调用了super.clone()。

46. super.finalize()方法:SuperFinalize

【Since Checkstyle 3.2】

Checks that an overriding finalize() method invokes super.finalize().

检查重写finalize()方法时是否调用了super.finalize()。

47. 不必要的小括号:UnnecessaryParentheses

【Since Checkstyle 3.4】

Checks if unnecessary parentheses are used in a statement or expression.

检查语句或表达式中是否使用了不必要的小括号。

48. 外部类型声明后不必要的分号:UnnecessarySemicolonAfterOuterTypeDeclaration

【Since Checkstyle 8.31】

Checks if unnecessary semicolon is used after type declaration.

检查类型声明后是否使用了不必要的分号。

49. 类型成员声明后不必要的分号:UnnecessarySemicolonAfterTypeMemberDeclaration

【Since Checkstyle 8.24】

Checks if unnecessary semicolon is used after type member declaration.

检查类型成员声明后是否使用了不必要的分号。

50. 枚举中不必要的分号:UnnecessarySemicolonInEnumeration

【Since Checkstyle 8.22】

Checks if unnecessary semicolon is in enum definitions.

检查枚举定义中是否存在不必要的分号。

51. try资源时不必要的分号:UnnecessarySemicolonInTryWithResources

【Since Checkstyle 8.22】

Checks if unnecessary semicolon is used in last resource declaration.

检查最后一个资源声明中是否使用了不必要的分号。

52. 未使用的局部变量:UnusedLocalVariable

【Since Checkstyle 9.3】

Checks that a local variable is declared and/or assigned, but not used.

检查是否声明和/或分配了局部变量,但未使用。

53. 变量声明使用距离:VariableDeclarationUsageDistance

【Since Checkstyle 5.8】

Checks the distance between declaration of variable and its first usage.

检查变量声明与其首次使用之间的距离。

五、 Headers:头文件。
1. 标头Header

【Since Checkstyle 6.9】

Checks that a source file begins with a specified header.

检查源文件是否以指定的标头开头。

2. 正则表达式标头RegexpHeader

【Since Checkstyle 6.9】

Checks the header of a source file against a header that contains a pattern for each line of the source header.

根据正则表达式检查源文件的标头。

六、 Imports:包的导入问题。
1. 避免星号(*)导入:AvoidStarImport

【Since Checkstyle 3.0】

Checks that there are no import statements that use the * notation.

检查是否没有使用*符号的导入语句。

2. 避免静态导入:AvoidStaticImport

【Since Checkstyle 5.0】

Checks that there are no static import statements.

检查是否没有静态导入语句。

3. 自定义导入顺序:CustomImportOrder

【Since Checkstyle 5.8】

Checks that the groups of import declarations appear in the order specified by the user.

检查导入声明组是否按用户指定的顺序排列。

4. 非法导入:IllegalImport

【Since Checkstyle 3.0】

Checks for imports from a set of illegal packages.

从一组非法包中检查导入。

5. 导入控制:ImportControl

【Since Checkstyle 4.0】

Controls what can be imported in each package and file.

控制每个包和文件中可以导入的内容。

6. 导入顺序:ImportOrder

【Since Checkstyle 3.2】

Checks the ordering/grouping of imports.

检查导入的顺序/分组。

7. 冗余导入:RedundantImport

【Since Checkstyle 3.0】

Checks for redundant import statements.

检查冗余的导入语句。

8. 未使用的导入:UnusedImports

【Since Checkstyle 3.0】

Checks for unused import statements.

检查未使用的导入语句。

七、 Javadoc Comments:文档注释。
1. javadoc标记(以@开头的元素)的顺序:AtclauseOrder

【Since Checkstyle 6.0】

Checks the order of javadoc block-tags or javadoc tags.

检查javadoc块标记或javadoc标记的顺序。

2. 无效的javadoc位置:InvalidJavadocPosition

【Since Checkstyle 8.23】

Checks that Javadocs are located at the correct position.

检查javadoc是否位于正确位置。

3. Javadoc块标记位置:JavadocBlockTagLocation

【Since Checkstyle 8.24】

Checks that a javadoc block tag appears only at the beginning of a line, ignoring leading asterisks and white space.

检查javadoc块标记是否仅出现在行的开头,忽略前导星号和空格。

4. Javadoc内容位置:JavadocContentLocation

【Since Checkstyle 8.27】

Checks that the Javadoc content begins from the same position for all Javadoc comments in the project.

检查Javadoc内容是否从项目中所有Javadoc注释的相同位置开始。

5. Javadoc方法: JavadocMethod

【Since Checkstyle 3.0】

Checks the Javadoc of a method or constructor.

检查方法或构造方法的Javadoc。

6. Javadoc缺失前导星号:JavadocMissingLeadingAsterisk

【Since Checkstyle 8.38】

Checks if the javadoc has leading asterisks on each line.

检查javadoc是否每行都有前导星号。

7. Javadoc星号后缺少空格:JavadocMissingWhitespaceAfterAsterisk

【Since Checkstyle 8.32】

Checks that there is at least one whitespace after the leading asterisk.

检查前导星号后是否至少有一个空格。

8. Javadoc包:JavadocPackage

【Since Checkstyle 5.0】

Checks that each Java package has a Javadoc file used for commenting.

检查每个Java包是否有一个用于注释的Javadoc文件。

9. Javadoc段落:JavadocParagraph

【Since Checkstyle 6.0】

Checks the Javadoc paragraph.

检查Javadoc段落。

10. Javadoc样式:JavadocStyle

【Since Checkstyle 3.2】

Validates Javadoc comments to help ensure they are well formed.

验证Javadoc注释,以帮助确保它们格式正确。

11. Javadoc标记连续缩进:JavadocTagContinuationIndentation

【Since Checkstyle 6.0】

Checks the indentation of the continuation lines in block tags.

检查块标记中连续行的缩进。

12. Javadoc类型:JavadocType

【Since Checkstyle 3.0】

Checks the Javadoc comments for type definitions.

检查Javadoc注释中的类型定义。

13. Javadoc变量:JavadocVariable

【Since Checkstyle 3.0】

Checks that a variable has a Javadoc comment.

检查变量是否具有Javadoc注释。

14. 缺失Javadoc的方法:MissingJavadocMethod

【Since Checkstyle 8.21】

Checks for missing Javadoc comments for a method or constructor.

检查方法或构造方法是否缺少Javadoc注释。

15. 缺失包的Javadoc:MissingJavadocPackage

【Since Checkstyle 8.22】

Checks for missing package definition Javadoc comments in package-info.java files.

检查package-info.java文件中是否缺少包定义的Javadoc注释。

16. 缺失Javadoc的类型:MissingJavadocType

【Since Checkstyle 8.20】

Checks for missing Javadoc comments for class, enum, interface, and annotation interface definitions.

检查类、枚举、接口和注解接口定义是否缺少Javadoc注释。

17. 非空标记说明:NonEmptyAtclauseDescription

【Since Checkstyle 6.0】

Checks that the block tag is followed by description.

检查块标记后面是否有描述。

18. 块标记组之前需要空行:RequireEmptyLineBeforeBlockTagGroup

【Since Checkstyle 8.36】

Checks that one blank line before the block tag if it is present in Javadoc.

检查Javadoc中的块标记前是否有一个空行。

19. 单行Javadoc:SingleLineJavadoc

【Since Checkstyle 6.0】

Checks that a Javadoc block can fit in a single-line and doesn’t contain block tags.

检查Javadoc块是否可以放在一行中,并且不包含块标记。

20. 摘要Javadoc:SummaryJavadoc

【Since Checkstyle 6.0】

Checks that Javadoc summary sentence does not contain phrases that are not recommended to use.

检查Javadoc摘要句子是否包含不建议使用的短语。

21. 写入标记:WriteTag

【Since Checkstyle 4.2】

Requires user defined Javadoc tag to be present in Javadoc comment with defined format.

要求用户定义的Javadoc标记以定义的格式出现在Javadoc注释中。

八、 Metrics:度量
1. 布尔表达式复杂度:BooleanExpressionComplexity

【Since Checkstyle 3.4】

Restricts the number of boolean operators (&&, ||, &, | and ^) in an expression.

限制表达式中布尔运算符(&&、||、&、|、^)的数量。

2. 类数据抽象耦合:ClassDataAbstractionCoupling

【Since Checkstyle 3.4】

Measures the number of instantiations of other classes within the given class or record.

测量给定类或记录中其他类的实例化数量。

3. 类依赖复杂度:ClassFanOutComplexity

【Since Checkstyle 3.4】

Checks the number of other types a given class/record/interface/enum/annotation relies on.

检查给定类/记录/接口/枚举/注解所依赖的其他类型的数量。

4. 循环复杂度:CyclomaticComplexity

【Since Checkstyle 3.2】

Checks cyclomatic complexity against a specified limit.

根据指定的限制检查圈复杂度。

5. Java NCSS:JavaNCSS

【Since Checkstyle 3.5】

Determines complexity of methods, classes and files by counting the Non Commenting Source Statements (NCSS).

通过计算非注释源语句(NCSS)来确定方法、类和文件的复杂度。

6. NPATH复杂度:NPathComplexity

【Since Checkstyle 3.4】

Checks the NPATH complexity against a specified limit.

根据指定的限制检查NPATH复杂度。

九、 Miscellaneous:杂项。
1. 数组类型样式:ArrayTypeStyle

【Since Checkstyle 3.1】

Checks the style of array type definitions.

检查数组类型定义的样式。

2. 避免转义Unicode字符:AvoidEscapedUnicodeCharacters

【Since Checkstyle 5.8】

Restricts using Unicode escapes (such as \u221e).

限制使用Unicode转义符(如\u221e)。

3. 注释缩进:CommentsIndentation

【Since Checkstyle 6.10】

Controls the indentation between comments and surrounding code.

控制注释和周围代码之间的缩进。

4. 后代令牌:DescendantToken

【Since Checkstyle 3.2】

Checks for restricted tokens beneath other tokens.

检查其他令牌下的受限令牌。

5. final参数:FinalParameters

【Since Checkstyle 3.0】

Checks that parameters for methods, constructors, catch and for-each blocks are final.

检查方法、构造方法、catch和for-each块的参数是否为final。

6. 缩进:Indentation

【Since Checkstyle 3.1】

Checks correct indentation of Java code.

检查Java代码的正确缩进。

7. 文件末尾的换行符:NewlineAtEndOfFile

【Since Checkstyle 3.1】

Checks whether files end with a line separator.

检查文件是否以行分隔符结尾。

8. 文件中无代码:NoCodeInFile

【Since Checkstyle 8.33】

Checks whether file contains code.

检查文件是否包含代码。

9. 有序属性:OrderedProperties

【Since Checkstyle 8.22】

Detects if keys in properties files are in correct order.

检测属性文件中的键的顺序是否正确。

10. 外部类型文件名:OuterTypeFilename

【Since Checkstyle 5.3】

Checks that the outer type name and the file name match.

检查外部类型名称和文件名是否匹配。

11. TODO注释:TodoComment

【Since Checkstyle 3.0】

Checks for TODO: comments.

检查TODO:注释。

12. 尾部注释:TrailingComment

【Since Checkstyle 3.4】

The check to ensure that lines with code do not end with comment.

检查以确保代码行不以注释结尾。

13. 翻译:Translation

【Since Checkstyle 3.0】

Ensures the correct translation of code by checking property files for consistency regarding their keys.

通过检查属性文件的一致性,确保代码的正确翻译。

14. 未注释的main方法:UncommentedMain

【Since Checkstyle 3.2】

Detects uncommented main methods.

检测未注释的main方法。

15. 唯一属性:UniqueProperties

【Since Checkstyle 5.7】

Detects duplicated keys in properties files.

检测属性文件中的重复属性。

16. 大写L:UpperEll

【Since Checkstyle 3.0】

Checks that long constants are defined with an upper ell.

检查long常量是否使用大写L定义。

十、 Modifiers:修饰符。
1. 类成员隐含修饰符:ClassMemberImpliedModifier

【Since Checkstyle 8.16】

Checks for implicit modifiers on nested types in classes and records.

检查类和记录中嵌套类型的隐式修饰符。

2. 接口成员隐含修饰符:InterfaceMemberImpliedModifier

【Since Checkstyle 8.12】

Checks for implicit modifiers on interface members and nested types.

检查接口成员和嵌套类型上的隐含修饰符。

3. 修饰符顺序:ModifierOrder

【Since Checkstyle 3.0】

Checks that the order of modifiers conforms to the suggestions in the Java Language specification, § 8.1.1, 8.3.1, 8.4.3 and 9.4.

检查修饰符的顺序是否符合Java语言规范§8.1.1、8.3.1、8.4.3和9.4中的建议。

4. 冗余修饰符:RedundantModifier

【Since Checkstyle 3.0】

Checks for redundant modifiers.

检查冗余的修饰符。

十一、 Naming Conventions:命名约定。
1. 标识符名称中的缩写:AbbreviationAsWordInName

【Since Checkstyle 5.8】

Validates abbreviations (consecutive capital letters) length in identifier name, it also allows to enforce camel case naming.

验证标识符名称中的缩写(连续大写字母)长度,它还允许强制使用骆驼大小写命名。

2. 抽象类名称:AbstractClassName

【Since Checkstyle 3.2】

Ensures that the names of abstract classes conforming to some pattern and check that abstract modifier exists.

确保抽象类的名称符合某种模式,并检查抽象修饰符是否存在。

检查注解中元素的样式。

3. 捕获参数名称:CatchParameterName

【Since Checkstyle 6.14】

Checks that catch parameter names conform to a specified pattern.

检查捕获参数名称是否符合指定模式。

4. 类类型参数名称:ClassTypeParameterName

【Since Checkstyle 5.0】

Checks that class type parameter names conform to a specified pattern.

检查类类型参数名称是否符合指定的模式。

5. 常量名称:ConstantName

【Since Checkstyle 3.0】

Checks that constant names conform to a specified pattern.

检查常量名称是否符合指定的模式。

6. 非法标识符名称:IllegalIdentifierName

【Since Checkstyle 8.36】

Checks identifiers with a pattern for a set of illegal names, such as those that are restricted or contextual keywords.

使用一组非法名称的模式检查标识符,例如受限制的名称或上下文关键字。

7. 接口类型参数名称:InterfaceTypeParameterName

【Since Checkstyle 5.8】

Checks that interface type parameter names conform to a specified pattern.

检查接口类型参数名称是否符合指定模式。

8. Lambda参数名称:LambdaParameterName

【Since Checkstyle 8.11】

Checks lambda parameter names.

检查lambda参数名称。

9. 局部final变量名称:LocalFinalVariableName

【Since Checkstyle 3.0】

Checks that local final variable names conform to a specified pattern.

检查局部final变量名是否符合指定模式。

10. 局部变量名称:LocalVariableName

【Since Checkstyle 3.0】

Checks that local, non-final variable names conform to a specified pattern.

检查局部非final变量名是否符合指定模式。

11. 成员名称:MemberName

【Since Checkstyle 3.0】

Checks that instance variable names conform to a specified pattern.

检查实例变量名称是否符合指定的模式。

12. 方法名称:MethodName

【Since Checkstyle 3.0】

Checks that method names conform to a specified pattern.

检查方法名称是否符合指定的模式。

13. 方法类型参数名称:MethodTypeParameterName

【Since Checkstyle 5.0】

Checks that method type parameter names conform to a specified pattern.

检查方法类型参数名称是否符合指定模式。

14. 包名称:PackageName

【Since Checkstyle 3.0】

Checks that package names conform to a specified pattern.

检查包名称是否符合指定的模式。

15. 参数名称:ParameterName

【Since Checkstyle 3.0】

Checks that method parameter names conform to a specified pattern.

检查方法参数名称是否符合指定模式。

16. 模式变量名称:PatternVariableName

【Since Checkstyle 8.36】

Checks that pattern variable names conform to a specified pattern.

检查模式变量名称是否符合指定的模式。

17. 记录组件名称:RecordComponentName

【Since Checkstyle 8.40】

Checks that record component names conform to a specified pattern.

检查记录组件名称是否符合指定的模式。

18. 记录类型参数名称RecordTypeParameterName

【Since Checkstyle 8.36】

Checks that record type parameter names conform to a specified pattern.

检查记录类型参数名称是否符合指定模式。

19. 静态变量名称:StaticVariableName

【Since Checkstyle 3.0】

Checks that static, non-final variable names conform to a specified pattern.

检查静态非final变量名是否符合指定模式。

20. 类型名:TypeName

【Since Checkstyle 3.0】

Checks that type names conform to a specified pattern.

检查类型名称是否符合指定的模式。

十二、 Regexp:正则表达式。
1. 正则表达式:Regexp

【Since Checkstyle 4.0】

Checks that a specified pattern exists, exists less than a set number of times, or does not exist in the file.

检查指定的模式是否存在、存在的次数是否少于设置的次数或文件中是否不存在。

2. 正则表达式多行:RegexpMultiline

【Since Checkstyle 5.0】

Checks that a specified pattern matches across multiple lines in any file type.

根据正则表达式检查任何文件类型的多行文本。

3. 正则表达式文件名:RegexpOnFilename

【Since Checkstyle 6.15】

Checks that a specified pattern matches based on file and/or folder path.

根据正则表达式检查文件或目录名称。

4. 正则表达式单行:RegexpSingleline

【Since Checkstyle 5.0】

Checks that a specified pattern matches a single-line in any file type.

根据正则表达式检查任何文件类型中的单行。

5. 正则表达式单行Java:RegexpSinglelineJava

【Since Checkstyle 6.0】

Checks that a specified pattern matches a single-line in Java files.

根据正则表达式检查java文件中的单行。

十三、 Size Violations:尺寸超标。
1. 匿名内部类长度:AnonInnerLength

【Since Checkstyle 3.2】

Checks for long anonymous inner classes.

检查匿名内部类的长度。

2. 可执行语句计数:ExecutableStatementCount

【Since Checkstyle 3.2】

Restricts the number of executable statements to a specified limit.

将可执行语句的数量限制为指定值。

3. 文件长度:FileLength

【Since Checkstyle 5.0】

Checks for long source files.

检查长的源文件。

4. Lambda body长度:LambdaBodyLength

【Since Checkstyle 8.37】

Checks lambda body length.

检查lambda body长度。

5. 行字符数:LineLength

【Since Checkstyle 3.0】

Checks for long lines.

检查每行字符数。

6. 方法计数:MethodCount

【Since Checkstyle 5.3】

Checks the number of methods declared in each type declaration by access modifier or total count.

检查每个类型声明中声明的方法数。

7. 方法长度:MethodLength

【Since Checkstyle 3.0】

Checks for long methods and constructors.

检查长方法和构造方法。

8. 外部类型数量:OuterTypeNumber

【Since Checkstyle 5.0】

Checks for the number of types declared at the outer (or root) level in a file.

检查文件中在外部(或根)级别声明的类型的数量。

9. 参数数量:ParameterNumber

【Since Checkstyle 3.0】

Checks the number of parameters of a method or constructor.

检查方法或构造方法的参数数量。

10. 记录组件数量:RecordComponentNumber

【Since Checkstyle 8.36】

Checks the number of record components in the header of a record definition.

检查记录定义标题中记录组件的数量。

十四、 Whitespace:空格。
1. for初始化的空填充:EmptyForInitializerPad

【Since Checkstyle 3.4】

Checks the padding of an empty for initializer; that is whether a white space is required at an empty for initializer, or such white space is forbidden.

检查初始值设定项的空填充;也就是说,在空的for初始值设定项中是否需要空格,或者是否禁止这样的空格。

2. 迭代器的空填充:EmptyForIteratorPad

【Since Checkstyle 3.0】

Checks the padding of an empty for iterator; that is whether a white space is required at an empty for iterator, or such white space is forbidden.

检查迭代器的空填充;也就是说,在空的for迭代器中是否需要空格,或者禁止这样的空格。

3. 空行分隔符:EmptyLineSeparator

【Since Checkstyle 5.8】

Checks for empty line separators before package, all import declarations, fields, constructors, methods, nested classes, static initializers and instance initializers.

检查包声明、所有导入声明、字段、构造方法、方法、嵌套类、静态初始化器和实例初始化器之前的空行分隔符。

4. 文件制表符:FileTabCharacter

【Since Checkstyle 5.0】

Checks that there are no tab characters (‘\t’) in the source code.

检查源代码中是否没有制表符(‘\t’)。

5. 通用空白:GenericWhitespace

【Since Checkstyle 5.0】

Checks that the whitespace around the Generic tokens (angle brackets) “<” and “>” are correct to the typical convention.

检查泛型标记(尖括号)“<”和“>”周围的空格是否符合典型惯例。

6. 方法参数填充:MethodParamPad

【Since Checkstyle 3.4】

Checks the padding between the identifier of a method definition, constructor definition, method call, or constructor invocation; and the left parenthesis of the parameter list.

检查方法定义、构造方法定义、方法调用或构造方法调用的标识符之间的填充;以及参数列表的左括号。

7. 无换行符:NoLineWrap

【Since Checkstyle 5.8】

Checks that chosen statements are not line-wrapped.

检查所选语句是否不换行。

8. 后面没有空格:NoWhitespaceAfter

【Since Checkstyle 3.0】

Checks that there is no whitespace after a token.

检查标记后面是否没有空格。

9. 前面没有空格:NoWhitespaceBefore

【Since Checkstyle 3.0】

Checks that there is no whitespace before a token.

检查标记前面是否没有空格。

10. 在case和default冒号前没有空格:NoWhitespaceBeforeCaseDefaultColon

【Since Checkstyle 8.45】

Checks that there is no whitespace before the colon in a switch block.

检查switch块中冒号前是否没有空格。

11. 运算符换行:OperatorWrap

【Since Checkstyle 3.0】

Checks the policy on how to wrap lines on operators.

检查有关如何换行运算符的策略。

12. 小括号填充:ParenPad

【Since Checkstyle 3.0】

Checks the policy on the padding of parentheses; that is whether a space is required after a left parenthesis and before a right parenthesis, or such spaces are forbidden.

检查括号填充的策略;也就是说,左小括号之后和右小括号之前是否需要空格,或者禁止使用此类空格。

13. 分隔符换行:SeparatorWrap

【Since Checkstyle 5.8】

Checks line wrapping with separators.

检查带分隔符的换行。

14. 单空格分隔符:SingleSpaceSeparator

【Since Checkstyle 6.19】

Checks that non-whitespace characters are separated by no more than one whitespace.

检查非空白字符之间的空格数是否超过一个。

15. 类型转换的小括号填充:TypecastParenPad

【Since Checkstyle 3.2】

Checks the policy on the padding of parentheses for typecasts.

检查类型转换的小括号填充策略。

16. 后面的空格:WhitespaceAfter

【Since Checkstyle 3.0】

Checks that a token is followed by whitespace, with the exception that it does not check for whitespace after the semicolon of an empty for iterator.

检查标记后面是否有空格,但不检查空for迭代器的分号后面是否有空白。

17. 空格包裹:WhitespaceAround

【Since Checkstyle 3.0】

Checks that a token is surrounded by whitespace.

检查指定标记的是否被空格包裹。

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值