a-maze-ing / CSE 373 PT / config / checkstyle / checkstyle(1).xml
checkstyle(1).xml
Raw
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">

<!--
    # CSE 373 checkstyle rules

    ## About

    This document contains config information for the
    checkstyle tool for CSE 373.


    ## Overall summary

    These rules are calibrated to:

    1.  Enforce mainly common sense things/instincts that should be
        ingrained after completing 14x.

    2.  Enforce metrics that encourage students to refactor their code

    3.  Not enforce things people have strong opinions about (e.g. we
        don't care about the brace style people use, or tabs vs spaces)

    4.  Not care about comments

    5.  Be generous regarding maximum line width (currently set to 120
        characters wide)

    6.  Be somewhat nitpicky about whitespacing
-->

<module name="Checker">
    <property name="fileExtensions" value="java"/>

    <module name="SuppressionFilter">
        <property name="file" value="${config_loc}/suppressions.xml"/>
        <property name="optional" value="false"/>
    </module>

    <!--
        Checks for Size Violations.
        See http://checkstyle.sf.net/config_sizes.html
    -->
    <module name="LineLength">
        <property name="id" value="MainLineLength" />
        <property name="max" value="120"/>
    </module>
    <module name="LineLength">
        <property name="id" value="TestLineLength" />
        <property name="max" value="120"/>
        <!-- ignore test method definitions -->
        <property name="ignorePattern" value="^ *void.*\(.*\) \{$"/>
    </module>

    <module name="TreeWalker">
        <!--
            Checks for annotations
            See http://checkstyle.sf.net/config_annotation.html

            Suppressed checks:
                AnnotationOnSameLine                (not relevant)
                various SuppressWarning shenanigans (not relevant)
        -->
        <module name="AnnotationLocation"/>
        <module name="AnnotationUseStyle"/>
        <module name="MissingDeprecated"/>
        <module name="MissingOverride"/>
        <module name="SuppressWarnings"/>

        <!--
            Checks for blocks.
            See http://checkstyle.sf.net/config_blocks.html
        -->
        <module name="AvoidNestedBlocks"/>
        <module name="EmptyBlock"/>
        <module name="EmptyCatchBlock"/>
        <module name="NeedBraces"/>

        <!--
            Checks for class design
            See http://checkstyle.sf.net/config_design.html
        -->
        <module name="FinalClass"/>
        <module name="InterfaceIsType"/>
        <module name="OneTopLevelClass"/>
        <module name="ThrowsCount"/>
        <!--<module name="VisibilityModifier"/>-->

        <!--
            Checks for common coding problems
            See http://checkstyle.sf.net/config_coding.html
        -->
        <module name="CovariantEquals"/>
        <module name="DefaultComesLast"/>
        <module name="EmptyStatement"/>
        <module name="EqualsHashCode"/>
        <module name="HiddenField">
            <property name="ignoreConstructorParameter" value="true"/>
            <property name="ignoreSetter" value="true"/>
            <property name="setterCanReturnItsClass" value="true"/>
        </module>
        <module name="IllegalInstantiation"/>
        <module name="InnerAssignment"/>
        <module name="MissingSwitchDefault"/>
        <module name="MultipleVariableDeclarations"/>
        <module name="NestedForDepth">
            <property name="max" value="2"/>
            <message key="nested.for.depth"
                     value="Loops are too heavily nested; code should either be simplified or refactored"/>
        </module>
        <module name="NestedIfDepth">
            <property name="max" value="3"/>
            <message key="nested.if.depth"
                     value="If statements are too heavily nested; code should either be simplified or refactored"/>
        </module>
        <module name="NestedTryDepth"/>
        <module name="NoClone"/>
        <module name="NoFinalizer"/>
        <module name="OneStatementPerLine"/>
        <module name="SimplifyBooleanExpression">
            <message key="simplify.expression"
                     value="Boolean expression can be simplified (poor boolean zen)"/>
        </module>
        <module name="SimplifyBooleanReturn">
            <message key="simplify.boolreturn"
                     value="Boolean return code can be simplified (poor boolean zen)"/>
        </module>
        <module name="SuperClone"/>
        <module name="SuperFinalize"/>

        <!--
            Checks for imports
            See http://checkstyle.sf.net/config_import.html
        -->
        <module name="AvoidStarImport">
            <property name="excludes" value="javax.swing, java.awt, org.junit.Assert"/>
        </module>
        <module name="RedundantImport"/>
        <module name="UnusedImports"/>

        <!--
            Checks for metrics
            See http://checkstyle.sf.net/config_metrics.html
        -->
        <module name="BooleanExpressionComplexity">
            <property name="max" value="4"/>
        </module>
        <module name="CyclomaticComplexity">
            <property name="max" value="20"/>

            <message key="cyclomaticComplexity"
                     value="Method is too complex: simplify the control flow or refactor into helper methods."/>
        </module>
        <!--<module name="NPathComplexity"/>-->

        <!--
            Miscellaneous other checks.
            See http://checkstyle.sf.net/config_misc.html
        -->
        <module name="ArrayTypeStyle"/>
        <module name="CommentsIndentation"/>
        <!--<module name="Indentation"/>   Note: default settings are generous -->
        <!--<module name="OuterTypeFilename"/>-->
        <module name="TodoComment">
            <property name="format" value="(TODO)|(todo)|(FIXME)|(fixme)" />

            <message key="todo.match"
                     value="Found a stray TODO/FIXME comment" />
        </module>
        <module name="UpperEll"/>

        <!--
            Modifier Checks
            See http://checkstyle.sf.net/config_modifiers.html
        -->
        <module name="ModifierOrder"/>

        <!--
            Checks for Naming Conventions.
            See http://checkstyle.sf.net/config_naming.html
        -->
        <module name="ConstantName">
          <property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
          <message key="name.invalidPattern"
                  value="Constant ''{0}'' must be in ALL_CAPS." />
        </module>
        <module name="LocalFinalVariableName">
          <property name="format" value="^([A-Z][0-9]*|[a-z][a-zA-Z0-9]*)$"/>
          <message key="name.invalidPattern"
                   value="Local final variable ''{0}'' must be in camelCase, or consist of a single upper-case letter." />
        </module>
        <module name="LocalVariableName">
          <property name="format" value="^([A-Z][0-9]*|[a-z][a-zA-Z0-9]*)$"/>
          <message key="name.invalidPattern"
                  value="Local variable ''{0}'' must be in camelCase, or consist of a single upper-case letter." />
        </module>
        <module name="MemberName">
          <property name="format" value="^_?[a-z][a-zA-Z0-9]*$|_?[A-Z]$"/>
          <message key="name.invalidPattern"
                  value="Instance variable ''{0}'' must be in camelCase, and may start with an underscore."/>
        </module>
        <module name="MethodName">
          <property name="format" value="^([A-Z][0-9]*|[a-z][a-zA-Z0-9]*)$"/>
          <message key="name.invalidPattern"
                   value="Method name ''{0}'' must be in camelCase, or consist of a single upper-case letter." />
        </module>
        <module name="PackageName">
          <property name="format"
                    value="^[a-z][a-z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*$" />
          <message key="name.invalidPattern"
                   value="Package name ''{0}'' must start with a lower-case letter."/>
        </module>
        <module name="ParameterName">
          <property name="format" value="^([A-Z][0-9]*|[a-z][a-zA-Z0-9]*)$"/>
          <message key="name.invalidPattern"
                   value="Parameter ''{0}'' must be in camelCase, or consist of a single upper-case letter." />
        </module>
        <module name="StaticVariableName">
          <property name="format" value="^_?[a-z][a-zA-Z0-9]*$|_?[A-Z]$"/>
          <message key="name.invalidPattern"
                   value="Static variable ''{0}'' must be in camelCase, or consist of a single upper-case letter, and may start with an underscore." />
        </module>
        <module name="TypeName">
          <property name="format" value="^[A-Z][A-Za-z0-9]*$"/>
          <message key="name.invalidPattern"
                   value="Type (class) name ''{0}'' must start with a capital letter."/>
        </module>
        <module name="ClassTypeParameterName">
          <property name="format" value="^[A-Z][A-Za-z0-9]*$"/>
          <message key="name.invalidPattern"
                   value="Type parameter ''{0}'' must start with a capital letter."/>
        </module>
        <module name="MethodTypeParameterName">
          <property name="format" value="^[A-Z][A-Za-z0-9]*$"/>
          <message key="name.invalidPattern"
                   value="Type parameter ''{0}'' must start with a capital letter."/>
        </module>

        <!--
            Checks for Size Violations.
            See http://checkstyle.sf.net/config_sizes.html
        -->
        <module name="ParameterNumber">
            <property name="max" value="8"/>
        </module>

        <!--
            Checks for whitespace
            See http://checkstyle.sf.net/config_whitespace.html
        -->
        <module name="EmptyForInitializerPad"/>
        <module name="EmptyForIteratorPad"/>
        <module name="GenericWhitespace"/>
        <module name="MethodParamPad"/>
<!--          ,  INDEX_OP. -->
        <module name="NoWhitespaceAfter">
            <property name="tokens" value="AT"/>
            <property name="tokens" value="BNOT"/>
            <property name="tokens" value="DEC"/>
            <property name="tokens" value="DOT"/>
            <property name="tokens" value="INC"/>
            <property name="tokens" value="LNOT"/>
            <property name="tokens" value="UNARY_MINUS"/>
            <property name="tokens" value="UNARY_PLUS"/>
            <property name="tokens" value="ARRAY_DECLARATOR"/>
            <property name="tokens" value="INDEX_OP"/>
            <property name="tokens" value="METHOD_REF"/>
        </module>
        <module name="NoWhitespaceBefore"/>
        <module name="NoWhitespaceBefore">
            <property name="tokens" value="DOT"/>
            <property name="tokens" value="METHOD_REF"/>
            <property name="allowLineBreaks" value="true"/>
        </module>
        <module name="ParenPad"/>
        <module name="TypecastParenPad"/>
        <module name="WhitespaceAfter"/>
        <module name="WhitespaceAround">
            <property name="allowEmptyConstructors" value="true"/>
            <property name="allowEmptyLambdas" value="true"/>
            <property name="allowEmptyMethods" value="true"/>
            <property name="allowEmptyTypes" value="true"/>
            <property name="allowEmptyLoops" value="true"/>
            <property name="tokens" value="COLON, DO_WHILE, LAMBDA, LCURLY, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, QUESTION, RCURLY, SLIST, LITERAL_ASSERT, TYPE_EXTENSION_AND"/>
        </module>
    </module>
</module>