diff --git a/docs/config_misc.html b/docs/config_misc.html index 15b83624b..c41d4b384 100644 --- a/docs/config_misc.html +++ b/docs/config_misc.html @@ -1,65 +1,419 @@ - - + + +
Miscellaneous Checks |
+ ![]() |
+
+
|
+
+ EqualsHashCode+Description++ Checks that classes that override equals() also + override hashCode(). + ++ Rationale: The contract of equals() and + hashCode() requires that equal objects have the same hashCode. Hence, + whenever you override equals() you must override + hashCode() to ensure that your class can be used in collections that are + hash based. + -To-do comments+Example++ To configure the check: + ++<module name="EqualsHashCode"/> ++ Package++ com.puppycrawl.tools.checkstyle.checks + +Parent Module++ TreeWalker + +GenericIllegalRegexpDescription++ A generic check for code problems - the user can search for any pattern. This is + similar to a recursive grep, only that it's integrated in checkstyle. + ++ Rationale: This check can be used to prototype checks and to find common bad + practice such as calling ex.printStacktrace(), + System.out.println(), System.exit(), etc. + +Properties+
Example++ To configure the check for calls to System.out.println: + ++<module name="GenericIllegalRegexp"> + <property name="format" value="System\.out\.println"/> +</module> ++ Package++ com.puppycrawl.tools.checkstyle.checks + +Parent Module++ TreeWalker + +HiddenFieldDescription++ Checks that a local variable or a parameter does not shadow a field that is + defined in the same class. + +Properties+
Examples++ To configure the check: + ++<module name="HiddenField"/> ++ + To configure the check so that it checks local variables but not parameters: + ++<module name="HiddenField"> + <property name="tokens" value="VARIABLE_DEF"/> +</module> ++ Package++ com.puppycrawl.tools.checkstyle.checks + +Parent Module++ TreeWalker + +IllegalInstantiationDescription++ Checks for illegal instantiations where a factory method is preferred. + ++ Rationale: Depending on the project, for some classes it might be preferable to + create instances through factory methods rather than calling the constructor. + ++ A simple example is the java.lang.Boolean class. In + order to save memory and CPU cycles, it is preferable to use the predefined + constants + TRUE and FALSE. Constructor invocations should + be replaced by calls to Boolean.valueOf(). + ++ Some extremely performance sensitive projects may require the use of factory + methods for other classes as well, to enforce the usage of number caches or + object pools. + +Notes++ There is a limitation that it is currently not possible to specify array classes. + +Example++ To configure the check: + ++<module name="IllegalInstantiation"/> +- The property checkstyle.pattern.todo specifies -the pattern to match for to-do comments. The property type is -regular expression and defaults to -TODO:. - -
-
-
-
-Tip- -Using to-do comments is a great way to keep track of tasks that need to be -done. By having them reported by Checkstyle makes it very hard to forget about -them. - -Integer Literals- -The property checkstyle.ignore.longell specifies -whether to not require that long integer literals use an uppercase -L. For example 40L instead -of 40l. This is in accordance to the Java Language -Specification, -Section 3.10.1. -The property type is boolean and -defaults to false. - - -illegal Instantiations- -The property checkstyle.illegal.instantiations -contains the set of classes that should not be instantiated directly. The -property type is string set and -defaults to an empty set. - -
-
-
-Tip- -A common mistake is to create new instances of java.lang.Boolean instead of using the constants TRUE and FALSE or the Boolean.valueOf() factory methods. This increases the -program's memory requirements and wastes CPU cycles during memory allocation -and garbage collection. To find this error automatically, include java.lang.Boolean in the list of illegal -instantiations. - -- Copyright © 2002 Oliver Burn. All rights Reserved. +Package++ com.puppycrawl.tools.checkstyle.checks + +Parent Module++ TreeWalker + +InnerAssignmentDescription++ Checks for assignments in subexpressions, such as in String s + = Integer.toString(i = 2);. + ++ Rationale: With the exception of for iterators, all + assignments should occur in their own toplevel statement to increase readability. + With inner assignments like the above it is difficult to see all places where a + variable is set. + +Properties+
Examples++ To configure the check: + ++<module name="InnerAssignment"/> ++ + To configure the check for only =, + +=, and -= operators: + ++<module name="InnerAssignment"> + <property name="tokens" value="ASSIGN,PLUS_ASSIGN,MINUS_ASSIGN"/> +</module> ++ Package++ com.puppycrawl.tools.checkstyle.checks + +Parent Module++ TreeWalker + +SimplifyBooleanExpression+Description++ Checks for overly complicated boolean expressions. Currently finds code like + if (b == true), b || true, !false, etc. + ++ Rationale: Complex boolean logic makes code hard to understand and maintain. + +Example++ To configure the check: + ++<module name="SimplifyBooleanExpression"/> ++ Package++ com.puppycrawl.tools.checkstyle.checks + +Parent Module++ TreeWalker + +SimplifyBooleanReturnDescription++ Checks for overly complicated boolean return statements. Idea shamelessly stolen + from the equivalent PMD rule. + +Example++ To configure the check: + ++<module name="SimplifyBooleanReturn"/> ++ Package++ com.puppycrawl.tools.checkstyle.checks + +Parent Module++ TreeWalker + +TodoCommentDescription++ A check for TODO: comments. Actually it is a generic regular + expression matcher on Java comments. To check for other patterns in Java + comments, set property format. + +Properties+
Notes++ Using TODO: comments is a great way to keep track of + tasks that need to be done. Having them reported by Checkstyle makes it very + hard to forget about them. + +Examples++ To configure the check: + ++<module name="TodoComment"/> ++ + To configure the check for comments that contain WARNING: + ++<module name="TodoComment"> + <property name="format" value="WARNING"/> +</module> ++ Package++ com.puppycrawl.tools.checkstyle.checks + +Parent Module++ TreeWalker + +TranslationDescription++ A FileSetCheck that ensure the correct + translation of code by checking property files for consistency regarding their + keys. Two property files describing one and the same context are consistent if + they contain the same keys. + +Example++ To configure the check: + ++<module name="Translation"/> ++ Package++ com.puppycrawl.tools.checkstyle.checks + +Parent Module++ Checker + +UpperEllDescription++ Checks that long constants are defined with an upper ell. That is ' + L' and +not 'l'. This is in accordance to the Java Language +Specification, +Section + 3.10.1. + +Rationale: The letter l looks a lot +like 1. + +Examples++ To configure the check: + + ++<module name="UpperEll"/> ++ Package++ com.puppycrawl.tools.checkstyle.checks + + +Parent Module++ TreeWalker + + + |
+
+Copyright © 2002 Oliver Burn. All rights Reserved. +
\ No newline at end of file