[JAVA] CheckStyle parameters

Introduction

I had the opportunity to review the CheckStyle configuration file in my work, and until now I used the configuration file created by my seniors without thinking about anything, so I checked the parameters again, so I will list it as a memorandum.

Parameter list

name Description
Checker Configuration file root tag
TreeWalker Tags that are parents of various parameters
JavadocType Warn if there are no Javadoc comments in class and interface declarations
JavadocVariable Warn when member variables do not contain Javadoc comments
JavadocMethod Warn if the method declaration does not contain Javadoc comments
Indentation Check the indent. Warn if the value (number of spaces) set in baseOffset does not match
LineLength Check the number of characters described in one line. Warn if the value set in max is exceeded
PackageName Warn if the package name does not match the regular expression set in format
TypeName class,interface,enum,Warn if the annotation name does not match the regular expression set in format. Judgment target can be set in tokens (used when you want to apply another naming convention only to the class)
AbstractClassName Warn if the abstract class name does not match the regular expression set in format
MethodName Warn if the method name does not match the regular expression set in format
ConstantName Warn if the name of the constant does not match the regular expression set in format
MemberName Warn if the name of a member variable does not match the regular expression set in format
LocalVariableName Warn if the name of a local variable does not match the regular expression set in format
CatchParameterName try-Warn when the variable name of the exception caught by catch does not match the regular expression set in format
LocalFinalVariableName Warn if the name of a local constant does not match the regular expression set in format
ParameterName Warn if the argument name does not match the regular expression set in format
StaticVariableName Warn if the name of a static variable does not match the regular expression set in format
MethodLength Warn when the number of lines in one method (also in the constructor) exceeds the value set in max
AvoidStarImport 「*Warn when importing using
RenduntImport Warn if there is a redundant import. Redundant import is below.
-When there are multiple imports of the same class
・ Java.If you are importing a class that belongs to the lang package
-If you are importing a class that belongs to the same package as the target class
UnusedImport Warn if there is an import of unused classes
EmptyBlock 「{}Warn when the inside of "" is empty.
EmptyCatchBlock Warn when processing of catch clause is empty
LeftCurly 「{Check the position where
NeedBraces In the if statement, for statement, etc.{}Warn if the process is not enclosed in
RightCurly 「}Check the position where
EmptyStatement Warn when there are unprocessed statements
EqualAvoidNull In String typeVariable name.equals("aaa")Warn when there is a place like
EqualsHashCode equals()Or hashCode()Warn if only one of them is implemented
HiddenField Warn when a local variable, a field whose argument is defined in the class and a variable name overlap
IllegalCatch Warning if the exception type in the chatch clause uses the type set in illegalClassNames
MagicNumber Warn if you are using a magic number. You can exclude it from the warning by setting ignoreNumbers to a number.
MissingSwitchDefault switch-Warn when default is not described in the case statement
SimplifyBooleanExpression if (variable == true)Warn when there is a description like
SimplifyBooleanReturn if (valid) { return true; } else { return false; }Warn when there is a description like
HideUtilityClassConstructor Warn if a public constructor exists in a utility class (a class with only static members)
InterfaceType Warn when there is no method and there is a variable-only interface
ArrayTypeStyle Warning when the description method of the array declaration is not Java style (C style)
FinalParameter For constructor and method argumentsfinalWarn if is not attached
ToDoComment Warn if a TODO comment exists
UpperEll Add to the end of a number in a long type declarationLWarn if is lowercase
TallThrough switch-Warn if break is missing in the case statement
DeclaretionOrder Check the order of declaration in the class.
The default is static variable, instance variable, constructor, method from the top.
FileTabCharacter Warn if you are using tabs in a file
CyclomaticComplexity Warn when the number of talented chromatics exceeds the value set by max
NPathComplexity Warn when the number of conditional branches exceeds the value set by max
FileLength Warn when the number of lines in the entire file exceeds the value set for max
WhitespaceAfter ,,;,if,else,while,do,for,do-whileWarn if there is no space after
WhitespaceAround A powerful version of Whitespace After.
But,,,;Cannot be detected.
()Check the space before and after.
NoWhitespaceBefore ,,;,++,--,...Warn if there is a space in front of
NoWhitespaceAfter @,++,--,+,-,!,.,Warn if there are spaces after array initialization
OverloadMethodsDeclarationOrder Warn when overloaded methods are not written together in one place
UnnecessarySemicolonEnumeration Warn when an unnecessary semicolon is described in enum
MultipleStringLiterals Warn if there are the same String literals in the file
OuterTypeFilename Warn when the file name and the defined class name are different
ModifierOrder Warn if the order of modifiers does not follow Java standards.
The order is from the toppublic,protected,private,abstract,default,static,final,transient,volatile,synchronaized,native,strictfp
RendundantModifier Warn if there are redundant modifiers
ClassTypeParameterName At the time of class generics declaration<>Check the type name enclosed in

Summary

For the time being, that's all for today. The parameters that are likely to be useful at a glance are selected and described.

The parameters listed in the table are not all, but I will gradually increase them when I have time in the future.

Recommended Posts

CheckStyle parameters
CheckStyle support