com.puppycrawl.tools.checkstyle.checks.coding |
Contains the Coding checks that are bundled with the main distribution.
|
Java Source File Name | Type | Comment |
AbstractIllegalCheck.java | Class | Support for checks that look for usage of illegal types. |
AbstractNestedDepthCheck.java | Class | Abstract class which provides helpers functionality for nestedchecks. |
AbstractSuperCheck.java | Class |
Abstract class for checking that an overriding method with no parameters
invokes the super method. |
AllTests.java | Class | |
ArrayTrailingCommaCheck.java | Class |
Checks if array initialization contains optional trailing comma. |
ArrayTrailingCommaCheckTest.java | Class | |
AvoidInlineConditionalsCheck.java | Class | Detects inline conditionals. |
AvoidInlineConditionalsCheckTest.java | Class | |
CovariantEqualsCheck.java | Class | Checks that if a class defines a covariant method equals,
then it defines method equals(java.lang.Object). |
CovariantEqualsCheckTest.java | Class | |
DeclarationOrderCheck.java | Class |
Checks that the parts of a class or interface declaration
appear in the order suggested by the
Code Conventions for the Java Programming Language.
- Class (static) variables.
|
DeclarationOrderCheckTest.java | Class | |
DefaultComesLastCheck.java | Class |
Check that the default is after all the case s
in a switch statement.
Rationale: Java allows default anywhere within the
switch statement. |
DefaultComesLastCheckTest.java | Class | |
DoubleCheckedLockingCheck.java | Class | Detect the double-checked locking idiom, a technique that tries to avoid
synchronization overhead but is incorrect because of subtle artifacts of
the java memory model. |
DoubleCheckedLockingCheckTest.java | Class | |
EmptyStatementCheck.java | Class |
Detects empty statements (standalone ';'). |
EmptyStatementCheckTest.java | Class | |
EqualsHashCodeCheck.java | Class |
Checks that classes that override equals() also override hashCode().
Rationale: The contract of equals() and hashCode() requires that
equal objects have the same hashCode. |
EqualsHashCodeCheckTest.java | Class | |
ExplicitInitializationCheck.java | Class |
Checks 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 .
Rationale: each instance variable gets
initialized twice, to the same value. |
ExplicitInitializationCheckTest.java | Class | |
FallThroughCheck.java | Class | Checks for fall through in switch statements
Finds locations where a case contains Java code -
but lacks a break, return, throw or continue statement.
The check honors special comments to suppress warnings about
the fall through. |
FallThroughCheckTest.java | Class | |
FinalLocalVariableCheck.java | Class |
Ensures that local variables that never get their values changed,
must be declared final. |
FinalLocalVariableCheckTest.java | Class | |
HiddenFieldCheck.java | Class | Checks that a local variable or a parameter does not shadow
a field that is defined in the same class. |
HiddenFieldCheckTest.java | Class | |
IllegalCatchCheck.java | Class | Catching java.lang.Exception, java.lang.Error or java.lang.RuntimeException
is almost never acceptable. |
IllegalCatchCheckTest.java | Class | |
IllegalInstantiationCheck.java | Class |
Checks for illegal instantiations where a factory method is preferred. |
IllegalInstantiationCheckTest.java | Class | |
IllegalThrowsCheck.java | Class | Throwing java.lang.Error or java.lang.RuntimeException
is almost never acceptable. |
IllegalThrowsCheckTest.java | Class | |
IllegalTokenCheck.java | Class |
Checks for illegal tokens.
Rational: Certain language features are often lead to hard to
maintain code or are non-obvious to novice developers. |
IllegalTokenCheckTest.java | Class | |
IllegalTokenTextCheck.java | Class |
Checks for illegal token text. |
IllegalTokenTextCheckTest.java | Class | |
IllegalTypeCheck.java | Class |
Checks that particular class are never used as types in variable
declarations, return values or parameters. |
IllegalTypeCheckTest.java | Class | |
InnerAssignmentCheck.java | Class |
Checks for assignments in subexpressions, such as in
String s = Integer.toString(i = 2); . |
InnerAssignmentCheckTest.java | Class | |
InputIllegalCatchCheck.java | Class | |
InputIllegalThrowsCheck.java | Class | |
InputIllegalType.java | Class | |
InputJUnitTest.java | Class | |
InputParameterAssignment.java | Class | |
InputReturnCount.java | Class | |
JUnitTestCaseCheck.java | Class | Ensures that the setUp(), tearDown()methods are named correctly,
have no arguments, return void and are either public or protected. |
JUnitTestCaseCheckTest.java | Class | |
MagicNumberCheck.java | Class |
Checks for magic numbers. |
MagicNumberCheckTest.java | Class | |
MissingCtorCheck.java | Class |
Checks that classes (except abstract one) define a ctor and don't rely
on the default one. |
MissingCtorCheckTest.java | Class | |
MissingSwitchDefaultCheck.java | Class |
Checks that switch statement has "default" clause.
Rationale: It's usually a good idea to introduce a
default case in every switch statement. |
MissingSwitchDefaultCheckTest.java | Class | |
ModifiedControlVariableCheck.java | Class | Check for ensuring that for loop control variables are not modified
inside the for block. |
ModifiedControlVariableCheckTest.java | Class | |
MultipleStringLiteralsCheck.java | Class | Checks for multiple occurrences of the same string literal within a
single file. |
MultipleStringLiteralsCheckTest.java | Class | |
MultipleVariableDeclarationsCheck.java | Class |
Checks that each variable declaration is in its own statement
and on its own line. |
MultipleVariableDeclarationsCheckTest.java | Class | |
NestedIfDepthCheck.java | Class | Restricts nested if-else blocks to a specified depth (default = 1). |
NestedIfDepthCheckTest.java | Class | |
NestedTryDepthCheck.java | Class | Restricts nested try-catch-finally blocks to a specified depth (default = 1). |
NestedTryDepthCheckTest.java | Class | |
PackageDeclarationCheck.java | Class | Ensures there is a package declaration.
Rationale: Classes that live in the null package cannot be
imported. |
PackageDeclarationCheckTest.java | Class | |
ParameterAssignmentCheck.java | Class |
Disallow assignment of parameters.
Rationale:
Parameter assignment is often considered poor
programming practice. |
ParameterAssignmentCheckTest.java | Class | |
RedundantThrowsCheck.java | Class | Checks for redundant exceptions declared in throws clause
such as duplicates, unchecked exceptions or subclasses of
another declared exception. |
RedundantThrowsCheckTest.java | Class | |
RequireThisCheck.java | Class | Checks that code doesn't rely on the "this" default.
That is references to instance variables and methods of the present
object are explicitly of the form "this.varName" or
"this.methodName(args)".
Examples of use:
<module name="RequireThis"/>
An example of how to configure to check this qualifier for
methods only:
<module name="RequireThis">
<property name="checkFields" value="false"/>
<property name="checkMethods" value="true"/>
</module>
Limitations: I'm not currently doing anything about static variables
or catch-blocks. |
RequireThisCheckTest.java | Class | |
ReturnCountCheck.java | Class |
Restricts return statements to a specified count (default = 2). |
ReturnCountCheckTest.java | Class | |
SimplifyBooleanExpressionCheck.java | Class |
Checks for overly complicated boolean expressions. |
SimplifyBooleanExpressionCheckTest.java | Class | |
SimplifyBooleanReturnCheck.java | Class |
Checks for overly complicated boolean return statements. |
SimplifyBooleanReturnCheckTest.java | Class | |
StringLiteralEqualityCheck.java | Class | Checks that string literals are not used with
== or != . |
StringLiteralEqualityCheckTest.java | Class | |
SuperCloneCheck.java | Class |
Checks that an overriding clone() method invokes super.clone(). |
SuperCloneCheckTest.java | Class | |
SuperFinalizeCheck.java | Class |
Checks that an overriding finalize() method invokes super.finalize(). |
SuperFinalizeCheckTest.java | Class | |
UnnecessaryParenthesesCheck.java | Class |
Checks if unnecessary parentheses are used in a statement or expression.
The check will flag the following with warnings:
return (x); // parens around identifier
return (x + 1); // parens around return value
int x = (y / 2 + 1); // parens around assignment rhs
for (int i = (0); i < 10; i++) { // parens around literal
t -= (z + 1); // parens around assignment rhs
The check is not "type aware", that is to say, it can't tell if parentheses
are unnecessary based on the types in an expression. |
UnnecessaryParenthesesCheckTest.java | Class | Test fixture for the UnnecessaryParenthesesCheck.
author: Eric K. |