Configuring checkstyle

Checkstyle results can be incorporated in the TICS output for Java files. Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. By default it supports the Sun Code Conventions, but is highly configurable. Information on Checkstyle can be found at the Checkstyle website.

Checkstyle version

The integration of checkstyle with TICS is based on checkstyle version 5.0. This version is downloadable via the TICS download site. It is not recommended to use another version than this version.


For a successful checkstyle integration, the following prerequisites must be met:

Configuring which rules should be checked

Checkstyle can detect many different rules. All these rules are listed in the checkstyle installation in the following file: checkstyle/docs/availablechecks.html. One can choose any set of rules that should be reported by TICS. As with other codecheckers, this is done by editing the RULES.txt and the IMPL.txt files within the cfg/codingstandards directory on the TICS FileServer. The rule's identifier, severity level, category and synopsis can be modified in the RULES.txt. The checkstyle rules invoked by TICS are configured in the IMPL.txt. In this file, the check name of checkstyle rules should be used as impl ID. These check names are the strings in the first column in the availablechecks.html page.

Note: the checkstyle rules have a parent-child relation. This information should also be provided to TICS. This is done by specifying the parent name in front of the check name. The two are separated by an "_". The parent-child relation can be found in the Parent Module section of the check's explanation. If the parent of a check name is "Checker", which is the root of all checks, then this parent relation does not need to be specified. A short example of the IMPL.txt file is given further down below.

Tweaking checkstyle rules

It is possible to set specific parameters for some rules. This is done by adding arguments to the rule configuration in the IMPL.txt file. An impl ID and its parameters are separated by an "=". All rule parameters are in the form of property-value pairs and should be specified as property:value. All property-value pairs are separated by a ",". File locations are resolved relative to the directory containing the IMPL.txt file.

An example of an IMPL.txt file is given below:

CS#001	checkstyle	FileTabCharacter
CS#002	checkstyle	TreeWalker_AnnotationUseStyle
CS#003	checkstyle	RegexpHeader=headerFile:$(CFGPATH)/checkstyle/regexpheader.txt
CS#004	checkstyle	TreeWalker_MissingDeprecated
CS#005	checkstyle	TreeWalker_MissingOverride
CS#006	checkstyle	FileLength
CS#007	checkstyle	RegexpSingleline=format:debug,minimum:0,maximum:1

A standard checkstyle rule configuration is available in the form of a IMPL.txt, RULES.txt pair.

See the checkstyle website for a list of all checkstyle rules.