CheckStyle:Checks之标准Checks

标准Checks

标准Checkstyle Checks适用于常规Java编码样式,并且不需要外部库。
Checkstyle提供了许多可应用于源代码的检查。以下是按字母顺序排列的参考。

Checkers描述
AbbreviationAsWordInNameThe Check validate abbreviations(consecutive capital letters) length in identifier name, it also allow in enforce camel case naming. Check会在标识符名称中验证缩写(连续的大写字母)的长度,还允许在强制驼峰式命名中使用。
AbstractClassNameEnsures that the names of abstract classes conforming to some regular expression and check that abstract modifier exists. 确保抽象类的名称符合某些正则表达式,并检查abstract修饰符是否存在。
AnnotationLocationCheck location of annotation on language elements. 检查语言元素上注释的位置。
AnnotationOnSameLineThe check does verifying that annotations are located on the same line with their targets. 该检查确实会验证注释与其目标位于同一行。
AnnotationUseStyleThis check controls the style with the usage of annotations. 此检查通过使用注释来控制样式。
AnonInnerLengthChecks for long anonymous inner classes. 检查长的匿名内部类。
ArrayTrailingCommaChecks if array initialization contains optional trailing comma. 检查数组初始化是否包含可选的结尾逗号。
ArrayTypeStyleChecks the style of array type definitions. 检查数组类型定义的样式。
AtclauseOrderChecks the order of at-clauses. 检查子句的顺序。
AvoidEscapedUnicodeCharactersRestrict using Unicode escapes. 限制使用Unicode转义。
AvoidInlineConditionalsDetects inline conditionals. 检测内联条件。
AvoidNestedBlocksFinds nested blocks. 查找嵌套块。
AvoidStarImportCheck that finds import statements that use the * notation. 检查以查找使用*符号的导入语句。
AvoidStaticImportCheck that finds static imports. 检查找到静态导入。
BooleanExpressionComplexityRestricts nested boolean operators (&&, ||, &, | and ^) to a specified depth (default = 3). 将嵌套的布尔运算符(&&,||,&,|和^)限制为指定的深度(默认= 3)。
CatchParameterNameChecks that catch parameter names conform to a format specified by the format property. 检查catch参数名称是否符合format属性指定的格式。
ClassDataAbstractionCouplingThis metric measures the number of instantiations of other classes within the given class. 此度量标准度量给定类中其他类的实例化数量。
ClassFanOutComplexityThe number of other classes a given class relies on. 给定类所依赖的其他类的数量。
ClassMemberImpliedModifierChecks for implicit modifiers on class members and nested types. 检查类成员和嵌套类型上的隐式修饰符。
ClassTypeParameterNameChecks that class type parameter names conform to a format specified by the format property. 检查类类型参数名称是否符合format属性指定的格式。
CommentsIndentationControls the indentation between comments and surrounding code. 控制注释和周围代码之间的缩进。
ConstantNameChecks that constant names conform to a format specified by the format property. 检查常量名称是否符合format属性指定的格式。
CovariantEqualsChecks that if a class defines a covariant method equals, then it defines method equals(java.lang.Object). 检查是否一个类定义了一个等于的协变方法,然后它定义了方法equals(java.lang.Object)。
CustomImportOrderChecks that the groups of import declarations appear in the order specified by the user. 检查导入声明组是否按用户指定的顺序显示。
CyclomaticComplexityChecks cyclomatic complexity against a specified limit. 根据指定的限制检查圈复杂度。
DeclarationOrderChecks that the parts of a class or interface declaration appear in the order suggested by the Code Conventions for the Java Programming Language. 检查类或接口声明的部分是否以Java编程语言的代码约定建议的顺序出现。
DefaultComesLastCheck that the default is after all the cases in a switch statement. 在switch语句中检查所有情况后的默认值。
DescendantTokenChecks for restricted tokens beneath other tokens. 检查其他令牌下方的受限令牌。
DesignForExtensionChecks that classes are designed for inheritance. 检查类是否为继承而设计。
EmptyBlockChecks for empty blocks but does not validate sequential blocks. 检查空块,但不验证顺序块。
EmptyCatchBlockChecks for empty catch blocks with few options to skip violation. 检查空的捕获块,几乎没有跳过冲突的选项。
EmptyForInitializerPadChecks the padding of an empty for initializer; that is whether a space is required at an empty for initializer, or such spaces are forbidden. 检查用于初始值设定项的空白填充;这就是说初始化程序的空白处是否需要一个空格,还是禁止使用这些空格。
EmptyForIteratorPadChecks the padding of an empty for iterator; that is whether a space is required at an empty for iterator, or such spaces are forbidden. 检查空白是否为迭代器;这就是说迭代器的空白处是否需要一个空格,还是禁止使用此类空格。
EmptyLineSeparatorChecks for blank line separators. 检查空白行分隔符。
EmptyStatementDetects empty statements (standalone ‘;’). 检测空语句(独立的“;”)。
EqualsAvoidNullChecks that any combination of String literals is on the left side of an equals() comparison. 检查String文字的任何组合是否在equals()比较的左侧。
EqualsHashCodeChecks that classes that override equals() also override hashCode(). 检查覆盖equals()的类是否也覆盖hashCode()。
ExecutableStatementCountRestricts the number of executable statements to a specified limit (default = 30). 将可执行语句的数量限制为指定的限制(默认值= 30)。
ExplicitInitializationChecks if any class or object member explicitly initialized to default for its type value (null for object references, zero for numeric types and char and false for boolean. 检查是否有任何类或对象成员的类型值显式初始化为默认值(对象引用为null,数字类型为零,char为布尔值,布尔值为false。
FallThroughChecks for fall through in switch statements Finds locations where a case contains Java code - but lacks a break, return, throw or continue statement. 检查switch语句中的失败找到包含Java代码的案例,但是缺少break,return,throw或Continue语句的位置。
FileLengthChecks for long source files. 检查长源文件。
FileTabCharacterChecks to see if a file contains a tab character. 检查文件是否包含制表符。
FinalClassChecks that class which has only private constructors is declared as final. 检查只有私有构造函数的类被声明为final。
FinalLocalVariableEnsures that local variables that never get their values changed, must be declared final. 确保永不更改其值的局部变量必须声明为final。
FinalParametersCheck that method/constructor/catch/foreach parameters are final. 检查method / constructor / catch / foreach参数是否为最终参数。
GenericWhitespaceChecks that the whitespace around the Generic tokens < and > are correct to the typical convention. 检查通用标记<和>周围的空格是否与典型约定正确。
HeaderChecks the header of the source against a fixed header file. 根据固定的头文件检查源头。
HiddenFieldChecks that a local variable or a parameter does not shadow a field that is defined in the same class. 检查局部变量或参数是否不遮盖同一类中定义的字段。
HideUtilityClassConstructorMake sure that utility classes (classes that contain only static methods) do not have a public constructor. 确保实用程序类(仅包含静态方法的类)没有公共构造函数。
IllegalCatchCatching java.lang.Exception, java.lang.Error or java.lang.RuntimeException is almost never acceptable. 捕获java.lang.Exception,java.lang.Error或java.lang.RuntimeException几乎是不可接受的。
IllegalImportChecks for imports from a set of illegal packages. 检查一组非法包装的进口。
IllegalInstantiationChecks for illegal instantiations where a factory method is preferred. 检查首选工厂方法的非法实例。
IllegalThrowsThrowing java.lang.Error or java.lang.RuntimeException is almost never acceptable. 几乎永远不会抛出java.lang.Error或java.lang.RuntimeException。
IllegalTokenChecks for illegal tokens. 检查非法令牌。
IllegalTokenTextChecks for illegal token text. 检查非法令牌文本。
IllegalTypeChecks that particular classes or interfaces are never used. 检查是否从未使用过特定的类或接口。
ImportControlCheck that controls what can be imported in each package and file. 检查控件是否可以导入每个包和文件中。
ImportOrderEnsures that groups of imports come in a specific order. 确保进口组按特定顺序进货。
IndentationChecks correct indentation of Java Code. 检查Java代码的正确缩进。
InnerAssignmentChecks for assignments in subexpressions, such as in String s = Integer.toString(i = 2);. 检查子表达式中的赋值,例如String s = Integer.toString(i = 2);。
InnerTypeLastCheck nested (internal) classes/interfaces are declared at the bottom of the class after all method and field declarations. 在所有方法和字段声明之后,检查嵌套(内部)类/接口是否在类的底部声明。
InterfaceIsTypeImplements Bloch, Effective Java, Item 17 - Use Interfaces only to define types. 实现Bloch,有效Java,条款17-仅使用接口定义类型。
InterfaceMemberImpliedModifierChecks for implicit modifiers on interface members and nested types. 检查接口成员和嵌套类型上的隐式修饰符。
InterfaceTypeParameterNameChecks that interface type parameter names conform to a format specified by the format property. 检查接口类型参数名称是否符合format属性指定的格式。
InvalidJavadocPositionChecks that Javadocs are located at the correct position. 检查Javadocs是否位于正确的位置。
JavadocBlockTagLocationChecks that a javadoc block tag appears only at the beginning of a line. 检查javadoc块标记是否仅出现在行的开头。
JavadocMethodChecks the Javadoc of a method or constructor. 检查方法或构造函数的Javadoc。
JavadocPackageChecks that all packages have a package documentation. 检查所有软件包是否都具有软件包文档。
JavadocParagraphChecks Javadoc paragraphs. 检查Javadoc段落。
JavadocStyleCustom Checkstyle Check to validate Javadoc. 自定义Checkstyle检查以验证Javadoc。
JavadocTagContinuationIndentationChecks the indentation of the continuation lines in at-clauses. 检查子句中连续线的缩进。
JavadocTypeChecks the Javadoc of a type. 检查类型的Javadoc。
JavadocVariableChecks that a variable has Javadoc comment. 检查变量是否具有Javadoc注释。
JavaNCSSThis check calculates the Non Commenting Source Statements (NCSS) metric for Java source files and methods. 此检查将计算Java源文件和方法的“非注释源语句(NCSS)”度量标准。
LambdaParameterNameCheck to verify lambda parameter names. 检查以验证lambda参数名称。
LeftCurlyChecks the placement of left curly braces on types, methods and other blocks: 检查左花括号在类型,方法和其他块上的位置:
LineLengthChecks for long lines. 检查长行。
LocalFinalVariableNameChecks that local final variable names conform to a format specified by the format property. 检查本地最终变量名称是否符合format属性指定的格式。
LocalVariableNameChecks that local, non-final variable names conform to a format specified by the format property. 检查本地非最终变量名称是否符合format属性指定的格式。
MagicNumberChecks for magic numbers. 检查幻数。
MemberNameChecks that instance variable names conform to a format specified by the format property. 检查实例变量名称是否符合format属性指定的格式。
MethodCountChecks the number of methods declared in each type declaration by access modifier or total count. 通过访问修饰符或总数检查每个类型声明中声明的方法的数量。
MethodLengthChecks for long methods. 检查长方法。
MethodNameChecks that method names conform to a format specified by the format property. 检查方法名称是否符合format属性指定的格式。
MethodParamPadChecks the padding between the identifier of a method definition, constructor definition, method call, or constructor invocation; and the left parenthesis of the parameter list. 检查方法定义的标识符,构造函数定义,方法调用或构造函数调用之间的填充;和参数列表的左括号。
MethodTypeParameterNameChecks that class type parameter names conform to a format specified by the format property. 检查类类型参数名称是否符合format属性指定的格式。
MissingCtorChecks that classes (except abstract one) define a ctor and don’t rely on the default one. 检查类(抽象类除外)是否定义了ctor,并且不依赖默认类。
MissingDeprecatedThis class is used to verify that both the java.lang.Deprecated annotation is present and the @deprecated Javadoc tag is present when either is present. 此类用于验证同时存在java.lang.Deprecated注释和存在@deprecated Javadoc标记。
MissingJavadocMethodChecks for missing Javadoc comments for a method or constructor. 检查方法或构造函数的Javadoc注释是否丢失。
MissingJavadocPackageChecks for missing Javadoc comments in package-info.java files. 检查package-info.java文件中是否缺少Javadoc注释。
MissingJavadocTypeChecks for missing Javadoc comments for class, enum, interface, and annotation interface definitions. 检查有关类,枚举,接口和注释接口定义的缺少Javadoc注释。
MissingOverrideThis class is used to verify that the java.lang.Override annotation is present when the {@inheritDoc} javadoc tag is present. 当存在{@inheritDoc} javadoc标记时,此类用于验证是否存在java.lang.Override批注。
MissingSwitchDefaultChecks that switch statement has “default” clause. 检查switch语句是否具有“ default”子句。
ModifiedControlVariableCheck for ensuring that for loop control variables are not modified inside the for block. 检查以确保未在for块内修改for循环控制变量。
ModifierOrderChecks that the order of modifiers conforms to the suggestions in the Java Language specification, sections 8.1.1, 8.3.1 and 8.4.3. 检查修饰符的顺序是否符合 Java语言规范中的建议 8.1.1、8.3.1和8.4.3。
MultipleStringLiteralsChecks for multiple occurrences of the same string literal within a single file. 检查单个文件中是否多次出现同一字符串文字。
MultipleVariableDeclarationsChecks that each variable declaration is in its own statement and on its own line. 检查每个变量声明是否在其自己的语句中和自己的行中。
MutableExceptionEnsures that exceptions (defined as any class name conforming to some regular expression) are immutable. 确保异常(定义为符合某些正则表达式的任何类名)是不可变的。
NeedBracesChecks for braces around code blocks. 检查代码块周围的花括号。
NestedForDepthRestricts nested for blocks to a specified depth (default = 1). 将嵌套块限制为指定深度(默认值= 1)。
NestedIfDepthRestricts nested if-else blocks to a specified depth (default = 1). 将嵌套的if-else块限制为指定的深度(默认值= 1)。
NestedTryDepthRestricts nested try-catch-finally blocks to a specified depth (default = 1). 将嵌套的try-catch-finally块限制为指定的深度(默认= 1)。
NewlineAtEndOfFileChecks that there is a newline at the end of each file. 检查每个文件末尾是否有换行符。
NoCloneChecks that the clone method is not overridden from the Object class. 检查是否从Object类覆盖了clone方法。
NoFinalizerChecks that no method having zero parameters is defined using the name finalize. 检查是否没有使用名称finalize定义具有零参数的方法。
NoLineWrapChecks that chosen statements are not line-wrapped. 检查所选语句是否未换行。
NonEmptyAtclauseDescriptionChecks that the at-clause tag is followed by description . 检查从句标签后面是否有description。
NoWhitespaceAfterChecks that there is no whitespace after a token. 检查令牌后是否没有空格。
NoWhitespaceBeforeChecks that there is no whitespace before a token. 检查令牌前是否没有空格。
NPathComplexityChecks the npath complexity against a specified limit (default = 200). 根据指定的限制检查npath复杂度(默认= 200)。
OneStatementPerLineChecks that there is only one statement per line. 检查每行只有一条语句。
OneTopLevelClassChecks that each top-level class, interfaces or enum resides in a source file of its own. 检查每个顶级类,接口或枚举是否驻留在其自己的源文件中。
OperatorWrapChecks line wrapping for operators. 检查换行符是否为运算符。
OrderedPropertiesDetects if keys in properties files are in correct order. 检测属性文件中的键是否顺序正确。
OuterTypeFilenameChecks that the outer type name and the file name match. 检查外部类型名称和文件名是否匹配。
OuterTypeNumberChecks for the number of defined types at the “outer” level. 在“外部”级别检查已定义类型的数量。
OverloadMethodsDeclarationOrderChecks that overload methods are grouped together. 检查重载方法是否组合在一起。
PackageAnnotationThis check makes sure that all package annotations are in the package-info.java file. 此检查确保所有软件包注释都在package-info.java文件中。
PackageDeclarationEnsures there is a package declaration and (optionally) in the correct directory. 确保在正确的目录中有一个包声明和(可选)。
PackageNameChecks that package names conform to a format specified by the format property. 检查软件包名称是否符合format属性指定的格式。
ParameterAssignmentDisallow assignment of parameters. 禁止分配参数。
ParameterNameChecks that parameter names conform to a format specified by the format property. 检查参数名称是否符合format属性指定的格式。
ParameterNumberChecks the number of parameters that a method or constructor has. 检查方法或构造函数具有的参数数量。
ParenPadChecks 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, with the exception that it does not check for padding of the right parenthesis at an empty for iterator. 检查括号的填充;也就是说,是在左括号之后还是在右括号之前是否需要一个空格,或者是这样的空格,除非它不检查迭代器的空白处是否填充了右括号。
RedundantImportChecks for imports that are redundant. 检查是否有多余的导入。
RedundantModifierChecks for redundant modifiers in interface and annotation definitions, final modifier on methods of final classes, inner interface declarations that are declared as static, non public class constructors and enum constructors, nested enum definitions that are declared as static. 检查接口和批注定义中的冗余修饰符,最终类方法上的最终修饰符,声明为静态的内部接口声明,非公共类构造函数和枚举构造函数,嵌套的枚举定义为静态的枚举。
RegexpA check that makes sure that a specified pattern exists (or not) in the file. 检查以确保文件中存在(或不存在)指定的模式。
RegexpHeaderChecks the header of the source against a header file that contains a 根据包含以下内容的头文件检查源头
RegexpMultilineImplementation of a check that looks that matches across multiple lines in any file type. 看起来与任何文件类型中的多行都匹配的检查的实现。
RegexpOnFilenameImplementation of a check that matches based on file and/or folder path. 实现基于文件和/或文件夹路径匹配的检查。
RegexpSinglelineImplementation of a check that looks for a single line in any file type. 查找任何文件类型中的单行的检查的实现。
RegexpSinglelineJavaImplementation of a check that looks for a single line in Java files. 在Java文件中查找单行的检查的实现。
RequireThisChecks that code doesn’t rely on the “this” default. 检查代码是否不依赖于“ this”默认值。
ReturnCountRestricts return statements to a specified count (default = 2). 将return语句限制为指定的计数(默认= 2)。
RightCurlyChecks the placement of right curly braces. 检查右花括号的位置。
SeparatorWrapChecks line wrapping with separators. 检查带有分隔符的换行。
SimplifyBooleanExpressionChecks for overly complicated boolean expressions. 检查过于复杂的布尔表达式。
SimplifyBooleanReturnChecks for overly complicated boolean return statements. 检查过于复杂的布尔返回语句。
SingleLineJavadocChecks that a JavaDoc block which can fit on a single line and doesn’t contain at-clauses 检查一个JavaDoc块是否可以放在一行上并且不包含子句
SingleSpaceSeparatorChecks that non-whitespace characters are separated by no more than one whitespace. 检查非空格字符之间是否被不超过一个空格分隔。
StaticVariableNameChecks that static, non-final variable names conform to a format specified by the format property. 检查静态非最终变量名称是否符合format属性指定的格式。
StringLiteralEqualityChecks that string literals are not used with == or !=. 检查字符串文字是否不与==或!=一起使用。
SummaryJavadocChecks that Javadoc summary sentence does not contain phrases that are not recommended to use. 检查Javadoc摘要语句是否不包含不建议使用的短语。
SuperCloneChecks that an overriding clone() method invokes super.clone(). 检查重写的clone()方法是否调用super.clone()。
SuperFinalizeChecks that an overriding finalize() method invokes super.finalize(). 检查覆盖的finalize()方法是否调用super.finalize()。
SuppressWarningsThis check allows you to specify what warnings that 此检查使您可以指定哪些警告
ThrowsCountRestricts throws statements to a specified count (default = 4). 将throws语句限制为指定的计数(默认值= 4)。
TodoCommentA check for TODO comments. 检查TODO注释。
TrailingCommentThe check to ensure that requires that comments be the only thing on a line. 检查以确保要求注释是一行中唯一的内容。
TranslationThe TranslationCheck class helps to ensure the correct translation of code by checking property files for consistency regarding their keys. TranslationCheck类通过检查属性文件有关其键的一致性来帮助确保代码的正确翻译。
TypecastParenPadChecks the padding of parentheses for typecasts. 检查括号中是否有类型转换。
TypeNameChecks that type names conform to a format specified by the format property. 检查类型名称是否符合format属性指定的格式。
UncommentedMainDetects uncommented main methods. 检测未注释的主要方法。
UniquePropertiesDetects duplicated keys in properties files. 检测属性文件中的重复键。
UnnecessaryParenthesesChecks if unnecessary parentheses are used in a statement or expression. 检查语句或表达式中是否使用了不必要的括号。
UnnecessarySemicolonInEnumerationChecks if unnecessary semicolon is in enum definitions. 检查枚举定义中是否包含不必要的分号。
UnnecessarySemicolonInTryWithResourcesChecks if unnecessary semicolon is used in last resource declaration. 检查在上一个资源声明中是否使用了不必要的分号。
UnnecessarySemicolonAfterTypeMemberDeclarationChecks if unnecessary semicolon is used after type member declaration. 检查类型成员声明后是否使用了不必要的分号。
UnusedImportsChecks for unused import statements. 检查未使用的导入语句。
UpperEllChecks that long constants are defined with an upper ell. 检查长常量是否使用上限ell定义。
VariableDeclarationUsageDistanceChecks the distance between declaration of variable and its first usage. 检查变量声明与其首次使用之间的距离。
VisibilityModifierChecks visibility of class members. 检查班级成员的可见性。
WhitespaceAfterChecks 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. 检查令牌后面是否有空格,但不检查迭代器的空分号后是否有空格。
WhitespaceAroundChecks that a token is surrounded by whitespace. 检查令牌是否被空白包围。
WriteTagOutputs a JavaDoc tag as information. 输出JavaDoc标记作为信息。

Holder Checks

这些检查不是正常的检查,通常与专门的过滤器相关联,以收集过滤器自身无法获得的信息。

禁止警告持有人 维护来自SuppressWarnings批注的一组检查抑制。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值