<?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
        "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
        "https://checkstyle.org/dtds/configuration_1_3.dtd">

 <module name="Checker">
 
    <!--
            Checkstyle configuration that checks the sun coding conventions from:

    - the Java Language Specification at
      https://docs.oracle.com/javase/specs/jls/se11/html/index.html

    - the Sun Code Conventions at https://www.oracle.com/java/technologies/javase/codeconventions-contents.html

    - the Javadoc guidelines at
      https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html

    - the JDK Api documentation https://docs.oracle.com/en/java/javase/11/

    - some best practices

    Checkstyle is very configurable. Be sure to read the documentation at
    https://checkstyle.org (or in your downloaded distribution).

    Most Checks are configurable, be sure to consult the documentation.

    To completely disable a check, just comment it out or delete it from the file.
    To suppress certain violations please review suppression filters.

    Finally, it is worth reading the documentation. 
    -->
 
    <property name="severity" value="warning"/>
    <property name="localeCountry" value="US" />
    <property name="localeLanguage" value="en" />

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

    <module name="SuppressionFilter">
        <property name="file" value="${checkstyle.suppressions.file}"/>
    </module>

    <!--
      Checks that a package documentation exists for each package.
    -->
    <!-- See https://checkstyle.sourceforge.io/config_javadoc.html -->
    <module name="JavadocPackage">
        <property name="allowLegacy" value="true"/>
    </module>


    <!-- Checks whether files end with a new line.                        -->
    <!-- See https://checkstyle.sourceforge.io/config_misc.html#NewlineAtEndOfFile -->
    <module name="NewlineAtEndOfFile">
        <property name="lineSeparator" value="lf"/>
    </module>

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

    <!-- Checks for Headers                              -->
    <!-- See https://checkstyle.sourceforge.io/config_header.html -->
    <module name="Header">
        <!-- The follow property value demonstrates the ability     -->
        <!-- to have access to ANT properties. In this case it uses -->
        <!-- the ${basedir} property to allow Checkstyle to be run  -->
        <!-- from any directory within a project.                   -->
        <property name="headerFile" value="${checkstyle.header.file}"/>
        <property name="ignoreLines" value="1"/>
    </module>

    <!-- Checks for Size Violations.                    -->
    <!-- See https://checkstyle.sourceforge.io/config_sizes.html -->
    <module name="FileLength"/>

    <!-- Checks for whitespace                               -->
    <!-- See https://checkstyle.sourceforge.io/config_whitespace.html -->
    <module name="FileTabCharacter"/>

    <module name="LineLength">
        <property name="ignorePattern" value="^(import.*|(\*|\s)*@version.*)$"/>
        <property name="max" value="132"/>
    </module>


    <module name="TreeWalker">

        <!-- ************************************************************** -->
        <!-- Checks that are different from the sun coding conventions ones -->
        <!-- ************************************************************** -->

        <module name="LeftCurly">
            <property name="option" value="nl"/>
        </module>
        <module name="RightCurly">
            <property name="option" value="alone"/>
        </module>
        <module name="MemberName">
            <property name="format" value="^[a-z]+_*[a-zA-Z0-9]*$"/>
        </module>
        <module name="StaticVariableName">
            <property name="format" value="^[a-z]+_*[a-zA-Z0-9]*$"/>
        </module>
        <module name="ConstantName">
            <property name="format" value="^(([A-Z][A-Z0-9]*(_[A-Z0-9]+)*)|log)$"/>
        </module>
        <module name="ParameterName">
            <property name="format" value="^[a-z]+_*[a-zA-Z0-9]*$"/>
        </module>

        <!-- ************************************************************** -->
        <!-- Default Sun coding conventions checks                          -->
        <!-- ************************************************************** -->

        <!-- Checks for Javadoc comments.                     -->
        <!-- See https://checkstyle.sourceforge.io/config_javadoc.html -->
        <module name="JavadocMethod">
        </module>

        <module name="JavadocStyle">
            <property name="excludeScope" value="private"/>
        </module>

        <module name="JavadocType"/>
        <module name="JavadocVariable"/>


        <!-- Checks for Naming Conventions.                  -->
        <!-- See https://checkstyle.sourceforge.io/config_naming.html -->
        <module name="LocalFinalVariableName"/>
        <module name="LocalVariableName"/>
        <module name="MethodName"/>
        <module name="PackageName"/>
        <module name="TypeName"/>


        <!-- Checks for imports                              -->
        <!-- See https://checkstyle.sourceforge.io/config_import.html -->
        <module name="AvoidStarImport"/>
        <module name="IllegalImport"/> <!-- defaults to sun.* packages -->
        <module name="RedundantImport"/>
        <module name="UnusedImports"/>


        <!-- Checks for Size Violations.                    -->
        <!-- See https://checkstyle.sourceforge.io/config_sizes.html -->
        <module name="MethodLength"/>
        <module name="ParameterNumber"/>


        <!-- Checks for whitespace                               -->
        <!-- See https://checkstyle.sourceforge.io/config_whitespace.html -->
        <module name="EmptyForIteratorPad"/>
        <module name="NoWhitespaceAfter"/>
        <module name="NoWhitespaceBefore"/>
        <module name="OperatorWrap"/>
        <module name="ParenPad"/>
        <module name="WhitespaceAfter"/>
        <module name="WhitespaceAround"/>
        <module name="GenericWhitespace"/>


        <!-- Modifier Checks                                    -->
        <!-- See https://checkstyle.sourceforge.io/config_modifiers.html -->
        <module name="ModifierOrder"/>
        <module name="RedundantModifier"/>


        <!-- Checks for blocks. You know, those {}'s         -->
        <!-- See https://checkstyle.sourceforge.io/config_blocks.html -->
        <module name="EmptyBlock"/>
        <module name="NeedBraces"/>


        <!-- Checks for common coding problems               -->
        <!-- See https://checkstyle.sourceforge.io/config_coding.html -->
        <module name="EmptyStatement"/>
        <module name="EqualsHashCode"/>
        <module name="FallThrough"/>
        <module name="HiddenField">
            <property name="tokens" value="VARIABLE_DEF"/>
        </module>
        <module name="IllegalInstantiation"/>
        <module name="InnerAssignment"/>
        <module name="MagicNumber"/>
        <module name="MissingSwitchDefault"/>
        <!--        <module name="OneMethodPrivateField" /> -->
        <!--        <module name="RedundantThrows"/>        -->
        <module name="SimplifyBooleanExpression"/>
        <module name="SimplifyBooleanReturn"/>

        <!-- Checks for class design                         -->
        <!-- See https://checkstyle.sourceforge.io/config_design.html -->
        <module name="FinalClass"/>
        <module name="HideUtilityClassConstructor"/>
        <module name="VisibilityModifier">
            <property name="protectedAllowed" value="true"/>
        </module>


        <!-- Miscellaneous other checks.                   -->
        <!-- See https://checkstyle.sourceforge.io/config_misc.html -->
        <module name="ArrayTypeStyle"/>
        <module name="Regexp">
            <property name="format" value="[ \t]+$"/>
            <property name="illegalPattern" value="true"/>
            <property name="message" value="Line has trailing spaces."/>
        </module>
        <module name="TodoComment"/>
        <module name="UpperEll"/>

    </module>

</module>