Miscellaneous Checks |
![]() |
GenericIllegalRegexpDescriptionA 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
ExamplesTo configure the check for calls to System.out.println: <module name="GenericIllegalRegexp"> <!-- . matches any character, so we need to escape it and use \. to match dots. --> <property name="format" value="System\.out\.println"/> </module> To configure the check to find trailing whitespace at the end of a line: <module name="GenericIllegalRegexp"> <!-- \s matches whitespace character, $ matches end of line. --> <property name="format" value="\s$"/> </module> To configure the check to find case-insensitive occurrences of "debug": <module name="GenericIllegalRegexp"> <property name="format" value="debug"/> <property name="ignoreCase" value="true"/> </module> Packagecom.puppycrawl.tools.checkstyle.checks Parent ModuleNewlineAtEndOfFileDescriptionChecks whether files end with a new line. Rationale: Any source files and text files in general should end with a newline character, especially when using SCM systems such as CVS. CVS will even print a warning when it encounters a file that doesn't end with a newline. Properties
ExamplesTo configure the check: <module name="NewlineAtEndOfFile"/> To configure the check to always use Unix-style line separators: <module name="NewlineAtEndOfFile"> <property name="lineSeparator" value="lf"/> </module> Packagecom.puppycrawl.tools.checkstyle.checks Parent ModuleTodoCommentDescriptionA 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
NotesUsing 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. ExamplesTo configure the check: <module name="TodoComment"/> To configure the check for comments that contain WARNING: <module name="TodoComment"> <property name="format" value="WARNING"/> </module> Packagecom.puppycrawl.tools.checkstyle.checks Parent ModuleTranslationDescriptionA FileSetCheck that ensures 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. Consider the following properties file in the same directory: #messages.properties hello=Hello cancel=Cancel #messages_de.properties hell=Hallo ok=OK The Translation check will find the typo in the german hello key, the missing ok key in the default resource file and the missing cancel key in the german resource file: messages_de.properties: Key 'hello' missing. messages_de.properties: Key 'cancel' missing. messages.properties: Key 'hell' missing. messages.properties: Key 'ok' missing. Properties
ExampleTo configure the check: <module name="Translation"/> Packagecom.puppycrawl.tools.checkstyle.checks Parent ModuleUpperEllDescriptionChecks 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. ExamplesTo configure the check: <module name="UpperEll"/> Packagecom.puppycrawl.tools.checkstyle.checks Parent ModuleArrayTypeStyleDescription
Checks the style of array type definitions.
Some like Java-style: Properties
ExamplesTo configure the check to enforce Java style: <module name="ArrayTypeStyle"/> To configure the check to enforce C style: <module name="ArrayTypeStyle"> <property name="javaStyle" value="false"/> </module> Packagecom.puppycrawl.tools.checkstyle.checks Parent ModuleFinalParametersDescriptionCheck that method/constructor parameters are final. Interface methods are not checked - the final keyword does not make sense for interface method parameters as there is no code that could modify the parameter. Rationale: Changing the value of parameters during the execution of the method's algorithm can be confusing and should be avoided. A great way to let the Java compiler prevent this coding style is to declare parameters final. Properties
ExamplesTo configure the check to enforce final parameters for methods and constructors: <module name="FinalParameters"/> To configure the check to enforce final parameters only for constructors: <module name="FinalParameters"> <property name="tokens" value="CTOR_DEF"/> </module> Packagecom.puppycrawl.tools.checkstyle.checks Parent Module |
Copyright © 2002-2003 Oliver Burn. All rights Reserved.