Standard Checks

The Standard Checkstyle Checks are applicable to general Java coding style and require no external libraries. The standard checks are included in the base distribution.

The site navigation menu lets you browse the individual checks by functionality.

Checkstyle provides many checks that you can apply to your source code. Below is an alphabetical reference, the site navigation menu provides a reference organized by functionality.

AbbreviationAsWordInName Validates abbreviations (consecutive capital letters) length in identifier name, it also allows to enforce camel case naming.
AbstractClassName Ensures that the names of abstract classes conforming to some pattern and check that abstract modifier exists.
AnnotationLocation Checks location of annotation on language elements.
AnnotationOnSameLine Checks that annotations are located on the same line with their targets.
AnnotationUseStyle Checks the style of elements in annotations.
AnonInnerLength Checks for long anonymous inner classes.
ArrayTrailingComma Checks that array initialization contains a trailing comma.
ArrayTypeStyle Checks the style of array type definitions.
AtclauseOrder Checks the order of javadoc block-tags or javadoc tags.
AvoidDoubleBraceInitialization Detects double brace initialization.
AvoidEscapedUnicodeCharacters Restricts using Unicode escapes (such as \u221e).
AvoidInlineConditionals Detects inline conditionals.
AvoidNestedBlocks Finds nested blocks (blocks that are used freely in the code).
AvoidNoArgumentSuperConstructorCall Checks if call to superclass constructor without arguments is present.
AvoidStarImport Checks that there are no import statements that use the * notation.
AvoidStaticImport Checks that there are no static import statements.
BooleanExpressionComplexity Restricts the number of boolean operators (&&, ||, &, | and ^) in an expression.
CatchParameterName Checks that catch parameter names conform to a specified pattern.
ClassDataAbstractionCoupling Measures the number of distinct classes that are instantiated within the given class or record.
ClassFanOutComplexity Checks the number of other types a given class/record/interface/enum/annotation relies on.
ClassMemberImpliedModifier Checks for implicit modifiers on nested types in classes and records.
ClassTypeParameterName Checks that class type parameter names conform to a specified pattern.
CommentsIndentation Controls the indentation between comments and surrounding code.
ConstantName Checks that constant names conform to a specified pattern.
ConstructorsDeclarationGrouping Checks that all constructors are grouped together.
CovariantEquals Checks that classes and records which define a covariant equals() method also override method equals(Object).
CustomImportOrder Checks that the groups of import declarations appear in the order specified by the user.
CyclomaticComplexity Checks cyclomatic complexity against a specified limit.
DeclarationOrder 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.
DefaultComesLast Check that the default is after all the cases in a switch statement.
DescendantToken Checks for restricted tokens beneath other tokens.
DesignForExtension Checks that classes are designed for extension (subclass creation).
EmptyBlock Checks for empty blocks.
EmptyCatchBlock Checks for empty catch blocks.
EmptyForInitializerPad 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.
EmptyForIteratorPad 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.
EmptyLineSeparator Checks for empty line separators before package, all import declarations, fields, constructors, methods, nested classes, static initializers and instance initializers.
EmptyStatement Detects empty statements (standalone ";" semicolon).
EqualsAvoidNull Checks that any combination of String literals is on the left side of an equals() comparison.
EqualsHashCode Checks that classes that either override equals() or hashCode() also overrides the other.
ExecutableStatementCount Restricts the number of executable statements to a specified limit.
ExplicitInitialization 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.
FallThrough Checks for fall-through in switch statements.
FileLength Checks for long source files.
FileTabCharacter Checks that there are no tab characters ('\t') in the source code.
FinalClass Ensures that identifies classes that can be effectively declared as final are explicitly marked as final.
FinalLocalVariable Checks that local variables that never have their values changed are declared final.
FinalParameters Checks that parameters for methods, constructors, catch and for-each blocks are final.
GenericWhitespace Checks that the whitespace around the Generic tokens (angle brackets) "<" and ">" are correct to the typical convention.
Header Checks that a source file begins with a specified header.
HiddenField Checks that a local variable or a parameter does not shadow a field that is defined in the same class.
HideUtilityClassConstructor Makes sure that utility classes (classes that contain only static methods or fields in their API) do not have a public constructor.
IllegalCatch Checks that certain exception types do not appear in a catch statement.
IllegalIdentifierName Checks identifiers with a pattern for a set of illegal names, such as those that are restricted or contextual keywords.
IllegalImport Checks for imports from a set of illegal packages.
IllegalInstantiation Checks for illegal instantiations where a factory method is preferred.
IllegalThrows Checks that specified types are not declared to be thrown.
IllegalToken Checks for illegal tokens.
IllegalTokenText Checks specified tokens text for matching an illegal pattern.
IllegalType Checks that particular classes or interfaces are never used.
ImportControl Controls what can be imported in each package and file.
ImportOrder Checks the ordering/grouping of imports.
Indentation Checks correct indentation of Java code.
InnerAssignment Checks for assignments in subexpressions, such as in String s = Integer.toString(i = 2);.
InnerTypeLast 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.
InterfaceIsType Implements Joshua Bloch, Effective Java, Item 17 - Use Interfaces only to define types.
InterfaceMemberImpliedModifier Checks for implicit modifiers on interface members and nested types.
InterfaceTypeParameterName Checks that interface type parameter names conform to a specified pattern.
InvalidJavadocPosition Checks that Javadocs are located at the correct position.
JavadocBlockTagLocation Checks that a javadoc block tag appears only at the beginning of a line, ignoring leading asterisks and white space.
JavadocContentLocation Checks that the Javadoc content begins from the same position for all Javadoc comments in the project.
JavadocLeadingAsteriskAlign Checks the alignment of leading asterisks in a Javadoc comment.
JavadocMethod Checks the Javadoc of a method or constructor.
JavadocMissingLeadingAsterisk Checks if the javadoc has leading asterisks on each line.
JavadocMissingWhitespaceAfterAsterisk Checks that there is at least one whitespace after the leading asterisk.
JavadocPackage Checks that each Java package has a Javadoc file used for commenting.
JavadocParagraph Checks the Javadoc paragraph.
JavadocStyle Validates Javadoc comments to help ensure they are well formed.
JavadocTagContinuationIndentation Checks the indentation of the continuation lines in block tags.
JavadocType Checks the Javadoc comments for type definitions.
JavadocVariable Checks that a variable has a Javadoc comment.
JavaNCSS Determines complexity of methods, classes and files by counting the Non Commenting Source Statements (NCSS).
LambdaBodyLength Checks lambda body length.
LambdaParameterName Checks lambda parameter names.
LeftCurly Checks for the placement of left curly braces ('{') for code blocks.
LineLength Checks for long lines.
LocalFinalVariableName Checks that local final variable names conform to a specified pattern.
LocalVariableName Checks that local, non-final variable names conform to a specified pattern.
MagicNumber Checks that there are no "magic numbers" where a magic number is a numeric literal that is not defined as a constant.
MatchXpath Evaluates Xpath query and report violation on all matching AST nodes.
MemberName Checks that instance variable names conform to a specified pattern.
MethodCount Checks the number of methods declared in each type declaration by access modifier or total count.
MethodLength Checks for long methods and constructors.
MethodName Checks that method names conform to a specified pattern.
MethodParamPad Checks the padding between the identifier of a method definition, constructor definition, method call, constructor invocation, record, or record pattern; and the left parenthesis of the parameter list.
MethodTypeParameterName Checks that method type parameter names conform to a specified pattern.
MissingCtor Checks that classes (except abstract ones) define a constructor and don't rely on the default one.
MissingDeprecated Verifies that the annotation @Deprecated and the Javadoc tag @deprecated are both present when either of them is present.
MissingJavadocMethod Checks for missing Javadoc comments for a method or constructor.
MissingJavadocPackage Checks for missing package definition Javadoc comments in package-info.java files.
MissingJavadocType Checks for missing Javadoc comments for class, enum, interface, and annotation interface definitions.
MissingOverride Verifies that the @Override annotation is present when the @inheritDoc javadoc tag is present.
MissingNullCaseInSwitch Checks that a given switch statement or expression that use a reference type in its selector expression has a null case label.
MissingSwitchDefault Checks that switch statement has a default clause.
ModifiedControlVariable Checks that for loop control variables are not modified inside the for block.
ModifierOrder 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.
MultipleStringLiterals Checks for multiple occurrences of the same string literal within a single file.
MultipleVariableDeclarations Checks that each variable declaration is in its own statement and on its own line.
MutableException 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.
NeedBraces Checks for braces around code blocks.
NestedForDepth Restricts nested for blocks to a specified depth.
NestedIfDepth Restricts nested if-else blocks to a specified depth.
NestedTryDepth Restricts nested try-catch-finally blocks to a specified depth.
NewlineAtEndOfFile Checks whether files end with a line separator.
NoArrayTrailingComma Checks that array initialization do not contain a trailing comma.
NoClone Checks that the clone method is not overridden from the Object class.
NoCodeInFile Checks whether file contains code.
NoFinalizer Checks that there is no method finalize with zero parameters.
NoLineWrap Checks that chosen statements are not line-wrapped.
NonEmptyAtclauseDescription Checks that the block tag is followed by description.
NoEnumTrailingComma Checks that enum definition does not contain a trailing comma.
NoWhitespaceAfter Checks that there is no whitespace after a token.
NoWhitespaceBefore Checks that there is no whitespace before a token.
NoWhitespaceBeforeCaseDefaultColon Checks that there is no whitespace before the colon in a switch block.
NPathComplexity Checks the NPATH complexity against a specified limit.
OneStatementPerLine Checks that there is only one statement per line.
OneTopLevelClass Checks that each top-level class, interface, enum or annotation resides in a source file of its own.
OperatorWrap Checks the policy on how to wrap lines on operators.
OrderedProperties Detects if keys in properties files are in correct order.
OuterTypeFilename Checks that the outer type name and the file name match.
OuterTypeNumber Checks for the number of types declared at the outer (or root) level in a file.
OverloadMethodsDeclarationOrder Checks that overloaded methods are grouped together.
PackageAnnotation Checks that all package annotations are in the package-info.java file.
PackageDeclaration Ensures that a class has a package declaration, and (optionally) whether the package name matches the directory name for the source file.
PackageName Checks that package names conform to a specified pattern.
ParameterAssignment Disallows assignment of parameters.
ParameterName Checks that method parameter names conform to a specified pattern.
ParameterNumber Checks the number of parameters of a method or constructor.
ParenPad 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.
PatternVariableName Checks that pattern variable names conform to a specified pattern.
RecordComponentNumber Checks the number of record components in the header of a record definition.
RecordComponentName Checks that record component names conform to a specified pattern.
RecordTypeParameterName Checks that record type parameter names conform to a specified pattern.
RedundantImport Checks for redundant import statements.
RedundantModifier Checks for redundant modifiers.
Regexp Checks that a specified pattern exists, exists less than a set number of times, or does not exist in the file.
RegexpHeader Checks the header of a source file against a header that contains a pattern for each line of the source header.
RegexpMultiline Checks that a specified pattern matches across multiple lines in any file type.
RegexpOnFilename Checks that a specified pattern matches based on file and/or folder path.
RegexpSingleline Checks that a specified pattern matches a single-line in any file type.
RegexpSinglelineJava Checks that a specified pattern matches a single-line in Java files.
RequireThis 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.
ReturnCount Restricts the number of return statements in methods, constructors and lambda expressions.
RightCurly Checks the placement of right curly braces ('}') for code blocks.
SeparatorWrap Checks line wrapping with separators.
SimplifyBooleanExpression Checks for over-complicated boolean expressions.
SimplifyBooleanReturn Checks for over-complicated boolean return or yield statements.
SingleLineJavadoc Checks that a Javadoc block can fit in a single-line and doesn't contain block tags.
RequireEmptyLineBeforeBlockTagGroup Checks that one blank line before the block tag if it is present in Javadoc.
SingleSpaceSeparator Checks that non-whitespace characters are separated by no more than one whitespace.
StaticVariableName Checks that static, non-final variable names conform to a specified pattern.
StringLiteralEquality Checks that string literals are not used with == or !=.
SummaryJavadoc Checks that Javadoc summary sentence does not contain phrases that are not recommended to use.
SuperClone Checks that an overriding clone() method invokes super.clone().
SuperFinalize Checks that an overriding finalize() method invokes super.finalize().
SuppressWarnings Allows to specify what warnings that @SuppressWarnings is not allowed to suppress.
SealedShouldHavePermitsList Checks that sealed classes and interfaces have a permits list.
ThrowsCount Restricts throws statements to a specified count.
TodoComment Checks for TODO: comments.
TrailingComment The check to ensure that lines with code do not end with comment.
Translation Ensures the correct translation of code by checking property files for consistency regarding their keys.
TypecastParenPad Checks the policy on the padding of parentheses for typecasts.
TypeName Checks that type names conform to a specified pattern.
UncommentedMain Detects uncommented main methods.
UniqueProperties Detects duplicated keys in properties files.
UnnecessaryParentheses Checks if unnecessary parentheses are used in a statement or expression.
UnnecessarySemicolonInEnumeration Checks if unnecessary semicolon is in enum definitions.
UnnecessarySemicolonInTryWithResources Checks if unnecessary semicolon is used in last resource declaration.
UnnecessarySemicolonAfterOuterTypeDeclaration Checks if unnecessary semicolon is used after type declaration.
UnnecessarySemicolonAfterTypeMemberDeclaration Checks if unnecessary semicolon is used after type member declaration.
UnusedImports Checks for unused import statements.
UpperEll Checks that long constants are defined with an upper ell.
UnusedCatchParameterShouldBeUnnamed Ensures that catch parameters that are not used are declared as an unnamed variable.
UnusedLambdaParameterShouldBeUnnamed Ensures that lambda parameters that are not used are declared as an unnamed variable.
UnusedLocalVariable Checks that a local variable is declared and/or assigned, but not used.
VariableDeclarationUsageDistance Checks the distance between declaration of variable and its first usage.
WhenShouldBeUsed Ensures that when is used instead of a single if statement inside a case block.
VisibilityModifier Checks visibility of class members.
WhitespaceAfter 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.
WhitespaceAround Checks that a token is surrounded by whitespace.
WriteTag Requires user defined Javadoc tag to be present in Javadoc comment with defined format.

Holder Checks

These checks aren't normal checks and are usually associated with a specialized filter to gather information the filter can't get on its own.

SuppressWarningsHolder Maintains a set of check suppressions from @SuppressWarnings annotations.