How to use Checkstyle

Checkstyle can be used by uploading an XML configuration file, which details which checks are to be performed. Detailed documentation can be found on the Checkstyle website. At the moment, the Praktomat only supports Checkstyle version 4.4.

The checks are

Example of a configuration file:

<?xml version="1.0"?>
    "-//Puppy Crawl//DTD Check Configuration 1.1//EN"
<module name="Checker">
    <module name="TreeWalker">
        <!-- Checks for common coding problems               -->
        <module name="MissingSwitchDefault"/>
        <module name="IllegalThrows"/>-->

        <!-- Checks for Naming Conventions.                  -->
        <module name="ConstantName"/>
        <module name="MemberName"/>
        <module name="MethodName"/>
        <module name="ParameterName"/>

        <!-- Checks for Size Violations.                     -->
        <module name="FileLength">
            <property name="max" value="1000"/>
        <module name="LineLength"/>
        <module name="MethodLength"/>

        <!-- Checks for formatting of blocks.                -->
        <module name="AvoidNestedBlocks"/>
        <module name="EmptyBlock"/>
        <module name="LeftCurly"/>
        <module name="NeedBraces"/>
        <module name="RightCurly"/>

A check that is provided without properties either has no properties (such as 'AvoidNestedBlocks') or has default values (for example the default value of 'LineLength' is 80). Default values can be overwritten by using a <property name="..." value="..."/> tag.

Using 'RegExp', checks can be written for any textual pattern. This can be single-line, multi-line and can be inclusive or exclusive of comments. It can be specified how many matches are allowed.