Package com.puppycrawl.tools.checkstyle.checks.coding
package com.puppycrawl.tools.checkstyle.checks.coding
Contains the Coding checks that are
bundled with the main distribution.
-
ClassDescriptionAbstract class for checking that an overriding method with no parameters invokes the super method.Stack node for a method definition and a record of whether the method has a call to the super method.Checks that array initialization contains a trailing comma.Detects double brace initialization.Detects inline conditionals.Checks if call to superclass constructor without arguments is present.Checks that all constructors are grouped together.Checks that classes and records which define a covariant
equals()
method also override methodequals(Object)
.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.Private class to encapsulate the state.Check that thedefault
is after all the cases in aswitch
statement.Detects empty statements (standalone";"
semicolon).Checks that any combination of String literals is on the left side of anequals()
comparison.Holds the names of fields of a type.Checks that classes that either overrideequals()
orhashCode()
also overrides the other.Checks if any class or object member is explicitly initialized to default for its type value (null
for object references, zero for numeric types andchar
andfalse
forboolean
.Checks for fall-through inswitch
statements.Checks that local variables that never have their values changed are declared final.Represents information about final local variable candidate.Holder for the scope data.Checks that a local variable or a parameter does not shadow a field that is defined in the same class.Holds the names of static and instance fields of a type.Checks that certain exception types do not appear in acatch
statement.Checks for illegal instantiations where a factory method is preferred.Checks that specified types are not declared to be thrown.Checks for illegal tokens.Checks specified tokens text for matching an illegal pattern.Checks that particular classes or interfaces are never used.Checks for assignments in subexpressions, such as inString s = Integer.toString(i = 2);
.Checks that there are no "magic numbers" where a magic number is a numeric literal that is not defined as a constant.Evaluates Xpath query and report violation on all matching AST nodes.Checks that classes (except abstract ones) define a constructor and don't rely on the default one.Checks that a given switch statement or expression that use a reference type in its selector expression has anull
case label.Checks that switch statement has adefault
clause.Checks that for loop control variables are not modified inside the for block.Checks for multiple occurrences of the same string literal within a single file.Checks that each variable declaration is in its own statement and on its own line.Restricts nestedfor
blocks to a specified depth.Restricts nested if-else blocks to a specified depth.Restricts nested try-catch-finally blocks to a specified depth.Checks that array initialization do not contain a trailing comma.Checks that the clone method is not overridden from the Object class.Checks that enum definition does not contain a trailing comma.Checks that there is no methodfinalize
with zero parameters.Checks that there is only one statement per line.Checks that overloaded methods are grouped together.Ensures that a class has a package declaration, and (optionally) whether the package name matches the directory name for the source file.Disallows assignment of parameters.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.A declaration frame.An anonymous class frame; holds instance variable names.A frame initiated on entering a statement list; holds local variable names.A frame initiated on entering a catch block; holds local catch variable names.A frame initiated at class, enum or interface definition; holds instance variable names.A frame initiated at constructor definition.A frame initiated on entering a for block; holds local for variable names.An AbstractFrame type.A frame initiated at method definition; holds a method definition token.A frame initiated on entering a try-with-resources construct; holds local resources for the try block.Restricts the number of return statements in methods, constructors and lambda expressions.Checks for over-complicated boolean expressions.Checks for over-complicated boolean return or yield statements.Checks that string literals are not used with==
or!=
.Checks that an overridingclone()
method invokessuper.clone()
.Checks that an overridingfinalize()
method invokessuper.finalize()
.Checks if unnecessary parentheses are used in a statement or expression.Checks if unnecessary semicolon is used after type declaration.Checks if unnecessary semicolon is used after type member declaration.Checks if unnecessary semicolon is in enum definitions.Checks if unnecessary semicolon is used in last resource declaration.Ensures that catch parameters that are not used are declared as an unnamed variable.Maintains information about the catch parameter.Ensures that lambda parameters that are not used are declared as an unnamed variable.Maintains information about the lambda parameter.Checks that a local variable is declared and/or assigned, but not used.Maintains information about the type declaration.Maintains information about the variable.Checks the distance between declaration of variable and its first usage.Ensures thatwhen
is used instead of a singleif
statement inside a case block.