<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Hibernate Validator, declare and validate application constraints
  ~
  ~ License: Apache License, Version 2.0
  ~ See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
  -->
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
        "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">

<module name="Checker">

    <module name="RegexpHeader">
        <property name="headerFile" value="/java.header"/>
        <property name="fileExtensions" value="java"/>
    </module>

    <module name="RegexpHeader">
        <property name="headerFile" value="/xml.header"/>
        <property name="fileExtensions" value="xml"/>
    </module>

    <module name="TreeWalker">
        <property name="cacheFile" value="${checkstyle.cache.file}"/>

        <module name="RegexpSinglelineJava">
            <!-- do not allow a package declaration that contains ".target." or "target;"  -->
            <property name="format" value="^package .*\.target[\.;]"/>
            <property name="message" value="Do not use &quot;target&quot; as package name element"/>
        </module>

        <!-- Use tabs -->
        <module name="RegexpSinglelineJava">
            <property name="format" value="^ +\t*\S" />
            <property name="message" value="Line has leading space characters; indentation should be performed with tabs only." />
            <property name="ignoreComments" value="true" />
        </module>

        <!-- Check parentheses padding -->
        <module name="RegexpSinglelineJava">
            <property name="format" value="^\t+(if|for|while|catch)([^ ])\(" />
            <property name="message" value="Left parentheses should be preceeded by 1 whitespace" />
            <property name="ignoreComments" value="true" />
        </module>

        <module name="RegexpSinglelineJava">
            <property name="format" value="^\t+(if|for|while) \( .+[^ ]\) \{$" />
            <property name="message" value="Right parentheses should be preceeded by 1 white space" />
            <property name="ignoreComments" value="true" />
        </module>

        <module name="RegexpSinglelineJava">
            <property name="format" value="^\t+(if|for|while) \([^ $]" />
            <property name="message" value="Left parentheses should be followed by 1 whitespace" />
            <property name="ignoreComments" value="true" />
        </module>

        <module name="RegexpSinglelineJava">
            <property name="format" value="\)([^ ])\{$" />
            <property name="message" value="Right parentheses should be followed by 1 white space" />
            <property name="ignoreComments" value="true" />
        </module>

        <module name="RegexpSinglelineJava">
            <property name="format" value="catch \([^\w]" />
            <property name="message" value="'catch' clause does not require white space after left parentheses" />
            <property name="ignoreComments" value="true" />
        </module>

        <module name="RegexpSinglelineJava">
            <property name="format" value="catch \(.*\s\) \{" />
            <property name="message" value="'catch' clause does not require white space before right parentheses" />
            <property name="ignoreComments" value="true" />
        </module>

        <module name="RegexpSinglelineJava">
            <property name="format" value="\)\s+;$" />
            <property name="message" value="Unecessary whitespace after parentheses" />
            <property name="ignoreComments" value="true" />
        </module>

        <!-- Checks for imports -->
        <module name="AvoidStarImport"/>
        <module name="RedundantImport"/>
        <module name="UnusedImports"/>

        <!-- Checks for common coding problems -->
        <module name="EqualsHashCode" />
        <module name="IllegalInstantiation" />

        <!-- Miscellaneous other checks. -->
        <module name="ModifierOrder" />
        <module name="GenericWhitespace" />
        <module name="PackageAnnotation" />
        <module name="CovariantEquals" />
        <module name="ModifiedControlVariable" />
        <module name="NeedBraces" />
        <module name="OneStatementPerLine" />
        <module name="EmptyStatement" />
        <module name="DefaultComesLast" />
        <module name="WhitespaceAround" />
        <module name="TypecastParenPad" />
        <module name="HideUtilityClassConstructor"/>
        <module name="MutableException"/>
        <module name="CovariantEquals" />
        <module name="EqualsAvoidNull" />
        <module name="UpperEll"/>
        <module name="ArrayTypeStyle"/>

        <!-- not checking for Constructor here: -->
        <module name="RedundantModifier">
            <property name="tokens"
                      value="METHOD_DEF, VARIABLE_DEF, ANNOTATION_FIELD_DEF, INTERFACE_DEF, CLASS_DEF, ENUM_DEF"/>
        </module>
        <module name="MissingOverride" />

        <module name="MethodParamPad">
            <property name="option" value="nospace" />
            <property name="allowLineBreaks" value="false" />
        </module>

        <!-- Checks for blocks. You know, those {}'s, not doing this for methods because of 1 line getters/setters-->
        <module name="LeftCurly">
            <property name="option" value="eol"/>
            <property name="tokens" value="INTERFACE_DEF, CLASS_DEF, ANNOTATION_DEF, ENUM_DEF, CTOR_DEF,
                        ENUM_CONSTANT_DEF, LITERAL_WHILE, LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY,
                        LITERAL_SYNCHRONIZED, LITERAL_SWITCH, LITERAL_DO, LITERAL_IF, LITERAL_ELSE, LITERAL_FOR,
                        STATIC_INIT, OBJBLOCK" />
        </module>
        <!-- not doing this for methods because of 1 line getters/setters -->
        <module name="RightCurly">
            <property name="option" value="alone"/>
            <property name="tokens" value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF,
                        LITERAL_ELSE, CLASS_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE,
                        STATIC_INIT, INSTANCE_INIT" />
        </module>

        <!-- METHOD_CALL breaks inline casts
            (i.e. Iterable<?> collection = ((Map<?,?>) value).values();)
            in 6.15-->
        <module name="ParenPad">
            <property name="tokens" value="CTOR_CALL, SUPER_CTOR_CALL"/>
            <property name="option" value="space"/>
        </module>

        <module name="RegexpSinglelineJava">
            <property name="format" value="System\.(out)|(err)\.print(ln)?\(" />
            <!-- The last sentence of the message is a keyword to trigger exclusion: see ExcludeTestPackages -->
            <property name="message" value="Not allowed to print to System.out: if you're damn sure you want it, disable Checkstyle on this line. [not required for tests]" />
            <property name="ignoreComments" value="true" />
        </module>

        <!-- Nobody should be using StringBuffer anymore -->
        <module name="RegexpSinglelineJava">
            <property name="format" value=" StringBuffer" />
            <!-- The last sentence of the message is a keyword to trigger exclusion: see ExcludeTestPackages -->
            <property name="message" value="Nobody should be using StringBuffer anymore" />
        </module>

        <!-- Required to get SuppressionCommentFilter to work -->
        <module name="FileContentsHolder" />

        <!--  Avoid some import statements -->
        <module name="IllegalImport">
            <property name="illegalPkgs" value="java.awt, sun, org.slf4j, junit.framework"/>
        </module>

    </module>

    <module name="RegexpSingleline">
        <property name="format" value="\s+$" />
        <property name="message" value="White spaces at the end of line" />
    </module>

    <module name="SuppressionCommentFilter" />

    <module name="SuppressionFilter">
        <property name="file" value="/suppressions.xml" />
    </module>

    <!-- Checks that a file ends with a new line  -->
    <module name="NewlineAtEndOfFile"/>

</module>
