<?xml version="1.0" encoding="UTF-8"?>
<!--

    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<!DOCTYPE module PUBLIC
    "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
    "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">

<!--
Checks to make sure the code meets the Camel coding guidelines which

It also enforces a bunch of other "BestPractices like method
lengths, if/try depths, etc...
-->

<module name="Checker">
    <property name="fileExtensions" value="java,groovy,scala,xml,properties"/>

    <!-- Checks whether files end with a new line.                        -->
    <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
    <!--
    <module name="NewlineAtEndOfFile"/>
    -->

    <!-- Checks that property files contain the same keys.         -->
    <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
    <module name="Translation"/>

    <!--<module name="StrictDuplicateCode"/>-->
    
    <!-- Header checks -->
    <!--
         The values for `header-*` are inserted at build time by Maven
         from the corresponding `header-*.txt` files. We need to do
         this instead of using `headerFile` property as Maven
         Checkstyle plugin has support for one `headerLocation`
         property. This also might help IDEs not to search for header
         files.
    -->
    <module name="Header">
        <!-- the `header-java` is replaced during build -->
        <property name="header" value="${header-java}"/>
        <property name="fileExtensions" value="java,groovy,scala"/>
    </module>

    <module name="Header">
        <!-- the `header-properties` is replaced during build -->
        <property name="header" value="${header-properties}"/>
        <property name="fileExtensions" value="properties"/>
    </module>
   
    <module name="RegexpHeader">
        <!-- the `header-xml` is replaced during build -->
        <property name="header" value="^&lt;\?xml.*&gt;\n${header-xml}"/>
        <property name="fileExtensions" value="xml,xsd"/>
    </module>

    <module name="RegexpMultiline">
        <property name="format" value="(\bgpl\b)|(\bgplv2\b)|(\bgnu\sgeneral\spublic\s*license\b)|(\bwww\.gnu\.org\/licenses\/gpl\.txt\b)"/>
        <property name="ignoreCase"  value="true"/>
    </module>
    
    <module name="FileLength">
        <property name="max" value="10000"/>
    </module>
    
    <module name="FileTabCharacter">
        <property name="fileExtensions" value="java"/>
    </module>
    
    <!-- 
	<module name="RegexpSingleline">
		<property name="format" value="\s+$"/>
		<property name="minimum" value="0"/>
		<property name="maximum" value="0"/>
	</module>
	 -->

    <module name="LineLength">
        <property name="max" value="250"/>
    </module>

    <module name="SuppressWithPlainTextCommentFilter">
        <property name="offCommentFormat" value="CHECKSTYLE\:OFF"/>
        <property name="onCommentFormat" value="CHECKSTYLE\:ON"/>
    </module>
    <module name="SuppressWithPlainTextCommentFilter">
        <property name="offCommentFormat" value="CHECKSTYLE.OFF\:([\w\|]+)"/>
        <property name="onCommentFormat" value="CHECKSTYLE.ON\:([\w\|]+)"/>
        <property name="checkFormat" value="$1"/>
    </module>

    <module name="TreeWalker">
        <!-- Checks for Javadoc comments.                     -->
        <!-- See http://checkstyle.sf.net/config_javadoc.html -->
        <!--
        <module name="PackageHtml"/>
        <module name="JavadocMethod"/>
        <module name="JavadocType"/>
        <module name="JavadocVariable"/>
        <module name="JavadocStyle"/>
        -->


        <!-- Checks for Naming Conventions.                  -->
        <!-- See http://checkstyle.sf.net/config_naming.html -->
        <module name="ConstantName"/>
        <module name="LocalFinalVariableName"/>
        <module name="LocalVariableName"/>
        <module name="MemberName"/>
        <module name="MethodName"/>
        <module name="PackageName"/>
        <module name="ParameterName"/>
        <module name="StaticVariableName"/>
        <module name="TypeName"/>

        <!-- <module name="RegexpHeader"/> -->


        <!-- Checks for imports                              -->
        <!-- See http://checkstyle.sf.net/config_import.html -->
        <module name="AvoidStarImport">
            <property name="excludes" value="java.io,java.util,java.net,java.nio,java.nio.channels,java.lang.reflect,org.w3c.dom,org.xml.sax,java.awt,javax.swing,junit.framework"/>
            <property name="allowStaticMemberImports" value="true"/>
        </module>
        <!-- 
        <module name="ConstantName"/>
         -->
        <module name="IllegalImport"/> <!-- defaults to sun.* packages -->
        <module name="RedundantImport"/>

        <module name="UnusedImports"/>

        <module name="ImportOrder">
            <property name="groups" value="java,javax,org.w3c,org.xml,junit"/>
            <property name="ordered" value="true"/>
            <property name="option" value="bottom"/>
            <property name="separated" value="true"/>
            <property name="separatedStaticGroups" value="true"/>
        </module>
        <!--
        <module name="ImportControl">
            <property name="file" value="etc/import-control.xml"/>
        </module>
        -->

        <!-- Checks for Size Violations.                    -->
        <!-- See http://checkstyle.sf.net/config_sizes.html -->
        <module name="AnonInnerLength">
            <property name="max" value="200"/>
        </module>
        <module name="ExecutableStatementCount">
            <property name="max" value="180"/>
        </module>
        <module name="MethodLength">
            <property name="max" value="250"/>
            <property name="countEmpty" value="false"/>
        </module>
        <!-- We should try to get this enabled soon..
        <module name="ParameterNumber">
            <property name="max" value="7"/>
        </module>
        -->

        <!-- Checks for whitespace                               -->
        <!-- See http://checkstyle.sf.net/config_whitespace.html -->
        <module name="EmptyForIteratorPad"/>
        <module name="EmptyForInitializerPad"/>
        <module name="MethodParamPad"/>
        <module name="NoWhitespaceAfter">
            <property name="tokens" value="ARRAY_INIT,BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/>
        </module>
        <module name="NoWhitespaceBefore"/>
        <module name="OperatorWrap"/>
        <module name="ParenPad"/>
        <module name="TypecastParenPad"/>
        <module name="WhitespaceAfter">
            <property name="tokens" value="COMMA, SEMI"/>
        </module>
        <module name="WhitespaceAround">
            <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN,TYPE_EXTENSION_AND"/>
            <!-- <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN,TYPE_EXTENSION_AND"/>-->
        </module>

		<!-- 
		<module name="GenericWhitespace"/>
		 -->

        <!-- Modifier Checks                                    -->
        <!-- See http://checkstyle.sf.net/config_modifiers.html -->
        <module name="ModifierOrder"/>
        <module name="RedundantModifier">
            <property name="tokens" value="METHOD_DEF, ANNOTATION_FIELD_DEF, INTERFACE_DEF, CLASS_DEF, ENUM_DEF"/>
        </module>


        <!-- Checks for blocks. You know, those {}'s         -->
        <!-- See http://checkstyle.sf.net/config_blocks.html -->
        <!--
        <module name="AvoidNestedBlocks">
            <property name="allowInSwitchCase" value="true"/>
        </module>
        -->
        <!-- We use alot of emply blocks..  they can be good too.
        <module name="EmptyBlock">
            <property name="option" value="text"/>
        </module>
        -->
        <module name="LeftCurly"/>
        <module name="NeedBraces"/>
        <module name="RightCurly"/>
        
        <!-- 
        <module name="OuterTypeNumber"/>
         -->


        <!-- Checks for common coding problems               -->
        <!-- See http://checkstyle.sf.net/config_coding.html -->
        <!--<module name="ArrayTrailingComma"/>-->
        <!--<module name="AvoidInlineConditionals"/>-->
        <module name="CovariantEquals"/>
        <module name="EmptyStatement"/>
        <module name="EqualsHashCode"/>
        <!--<module name="FinalLocalVariable"/>-->
        <!--
        <module name="HiddenField">
            <property name="ignoreConstructorParameter" value="true"/>
            <property name="ignoreSetter" value="true"/>
        </module>
        -->
        <!-- 
        <module name="EqualsAvoidNull"/>
         -->
        <module name="IllegalInstantiation"/>
        <!--<module name="IllegalToken"/>-->
        <!--<module name="IllegalTokenText"/>-->
        <!--<module name="InnerAssignment"/>-->
        <!--<module name="MagicNumber"/>-->
        <module name="MissingSwitchDefault"/>
        <!--module name="ModifiedControlVariable"/-->
        <module name="SimplifyBooleanExpression"/>
        <module name="SimplifyBooleanReturn"/>
        <module name="StringLiteralEquality"/>
        <module name="NestedIfDepth">
            <property name="max" value="8"/>
        </module>
        <module name="NestedTryDepth">
            <property name="max" value="8"/>
        </module>
        <!--<module name="SuperClone"/>-->
        <module name="SuperFinalize"/>
        <!--<module name="IllegalCatch"/>-->
    	<module name="IllegalThrows">
      		<property name="illegalClassNames" value="java.lang.Error,java.lang.RuntimeException"/>
    	</module>
        <!--<module name="RedundantThrows"/>-->
        <module name="PackageDeclaration"/>
        <!--
        <module name="JUnitTestCase"/>
        -->
        <module name="ReturnCount">
            <property name="max" value="21"/>
            <property name="maxForVoid" value="25"/>
        </module>

        <!-- Um.. we tend to use these alot.. perhaps enable this check later.
        <module name="IllegalType">
            <property name="format" value="^xxx$"/>
            <property name="illegalClassNames" value="java.util.GregorianCalendar, java.util.Hashtable, java.util.HashSet, java.util.HashMap, java.util.ArrayList, java.util.LinkedList, java.util.LinkedHashMap, java.util.LinkedHashSet, java.util.TreeSet, java.util.TreeMap"/> We use alot of emply blocks..  they can be good too.
        </module>
        -->
        <module name="DeclarationOrder"/>
        <!--<module name="ParameterAssignment"/>-->
        <module name="ExplicitInitialization"/>
        <!-- <module name="AnnotationUseStyle"/> -->
        <!-- <module name="MissingDeprecated"/> -->
        <!-- 
		<module name="MissingOverride">
			<property name="javaFiveCompatibility" value="true"/>
		</module>
         -->
         <!-- <module name="PackageAnnotation"/> -->
         <!-- <module name="SuppressWarnings"/> -->
        <module name="DefaultComesLast"/>
        <!--<module name="MissingCtor"/>-->
        <module name="FallThrough"/>
        <!--<module name="MultipleStringLiterals"/>-->
        <module name="MultipleVariableDeclarations"/>
        <!--<module name="RequireThis"/>-->
        <module name="UnnecessaryParentheses"/>



        <!-- Checks for class design                         -->
        <!-- See http://checkstyle.sf.net/config_design.html -->
        <!--<module name="DesignForExtension"/>-->
        <module name="FinalClass"/>
        <module name="HideUtilityClassConstructor"/>
        <!-- We still do enum style interfaces
        <module name="InterfaceIsType"/>
        -->
        <module name="MutableException">
            <property name="format" value="^.*Exception$"/>
        </module>
        <module name="ThrowsCount">
            <property name="max" value="5"/>
        </module>

        <!-- Ah we do a fair bit of using a class like a struct.. so
             we are not so strict on requirin encapsulation
        <module name="VisibilityModifier">
            <property name="protectedAllowed" value="true"/>
            <property name="packageAllowed" value="true"/>
            <property name="publicMemberPattern" value="resource[12].*"/>
        </module>
        -->


        <!-- Metrics checks.                   -->
        <!-- See http://checkstyle.sf.net/config_metrics.html -->
        <module name="BooleanExpressionComplexity">
            <property name="max" value="6"/>
        </module>
        <!--<module name="ClassDataAbstractionCoupling"/>-->
        <!--<module name="ClassFanOutComplexity"/>-->
        <!--<module name="CyclomaticComplexity"/>-->
        <!--<module name="NPathComplexity"/>-->
        <!-- Ah big methods aint so bad! :)
        <module name="JavaNCSS">
            <property name="methodMaximum" value="75"/>
        </module>
        -->


        <!-- Miscellaneous other checks.                   -->
        <!-- See http://checkstyle.sf.net/config_misc.html -->
        <!--
        <module name="ArrayTypeStyle"/>
        <module name="FinalParameters"/>
        -->
        <!--
        <module name="GenericIllegalRegexp">
            <property name="format" value="\s+$"/>
            <property name="message" value="Line has trailing spaces."/>
        </module>
        -->

        <module name="UpperEll"/>

        <!--Assert statement may have side effects:-->
        <module name="DescendantToken">
            <property name="tokens" value="LITERAL_ASSERT"/>
            <property name="limitedTokens" value="ASSIGN,DEC,INC,POST_DEC,POST_INC,PLUS_ASSIGN,MINUS_ASSIGN,STAR_ASSIGN,DIV_ASSIGN,MOD_ASSIGN,BSR_ASSIGN,SR_ASSIGN,SL_ASSIGN,BAND_ASSIGN,BXOR_ASSIGN,BOR_ASSIGN"/>
            <property name="maximumNumber" value="0"/>
        </module>

        <!--<module name="UncommentedMain"/>-->
        <!--module name="TrailingComment"/-->
        <module name="Indentation">
            <property name="lineWrappingIndentation" value="0"/>
        </module>
        <!--<module name="RequiredRegexp">-->
        <module name="SuppressionCommentFilter">
            <property name="offCommentFormat" value="CHECKSTYLE\:OFF"/>
            <property name="onCommentFormat" value="CHECKSTYLE\:ON"/>
        </module>
        <module name="SuppressionCommentFilter">
            <property name="offCommentFormat" value="CHECKSTYLE.OFF\:([\w\|]+)"/>
            <property name="onCommentFormat" value="CHECKSTYLE.ON\:([\w\|]+)"/>
            <property name="checkFormat" value="$1"/>
        </module>
    </module>
</module>
