<?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.3//EN"
        "http://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">

    <property name="charset" value="UTF-8"/>

    <property name="severity" value="error"/>

    <property name="fileExtensions" value="java, properties, xml"/>

    <module name="NewlineAtEndOfFile">
        <!-- windows can use \r\n vs \n, so enforce the most used one ie UNIx style -->
        <property name="lineSeparator" value="lf"/>
    </module>

    <property name="localeLanguage" value="en"/>

    <module name="FileTabCharacter">
        <property name="eachLine" value="true"/>
    </module>

    <module name="RegexpSingleline">
        <property name="format" value="System\.out\.println"/>
        <property name="message" value="Prohibit invoking System.out.println in source code !"/>
    </module>

    <module name="RegexpSingleline">
        <property name="format" value="^\s*\*\s*@author"/>
        <property name="minimum" value="0"/>
        <property name="maximum" value="0"/>
        <property name="message" value="ASF project doesn't allow @author copyright."/>
    </module>

    <module name="RegexpSingleline">
        <property name="format"
                  value=".*[\u3400-\u4DB5\u4E00-\u9FA5\u9FA6-\u9FBB\uF900-\uFA2D\uFA30-\uFA6A\uFA70-\uFAD9\uFF00-\uFFEF\u2E80-\u2EFF\u3000-\u303F\u31C0-\u31EF]+.*"/>
        <property name="message" value="Not allow chinese character !"/>
    </module>

    <module name="RegexpSingleline">
        <!-- Checks that TODOs don't have stuff in parenthesis, e.g., username. -->
        <property name="format" value="((//.*)|(\*.*))TODO\("/>
        <property name="message" value="TODO comments must not include usernames."/>
        <property name="severity" value="error"/>
    </module>

    <module name="RegexpSingleline">
        <!-- \s matches whitespace character, $ matches end of line. -->
        <property name="format" value="\s+$"/>
        <property name="severity" value="error"/>
        <property name="message" value="No trailing whitespace allowed."/>
    </module>

    <module name="RegexpSingleline">
        <property name="format" value="Throwables.propagate\("/>
        <property name="message" value="Throwables.propagate is deprecated"/>
        <property name="severity" value="error"/>
    </module>

    <module name="FileLength">
        <property name="max" value="3000"/>
    </module>

    <module name="LineLength">
        <property name="max" value="500"/>
        <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
    </module>

    <module name="SuppressionSingleFilter">
        <property name="files" value=".*(IT|Test).java"/>
        <property name="checks" value="MagicNumber"/>
    </module>

    <module name="SuppressWarningsFilter"/>
    <module name="TreeWalker">
        <module name="SuppressWarningsHolder"/>
        <module name="ImportOrder">
            <property name="severity" value="error"/>
            <property name="staticGroups" value="org.apache.seatunnel,org.apache.seatunnel.shade,*,javax,java,scala"/>
            <property name="groups" value="org.apache.seatunnel,org.apache.seatunnel.shade,*,javax,java,scala"/>
            <property name="separated" value="true"/>
            <property name="sortStaticImportsAlphabetically" value="true"/>
            <property name="option" value="top"/>
            <property name="tokens" value="STATIC_IMPORT, IMPORT"/>
            <message key="import.ordering" value="Import {0} appears after other imports that it should precede"/>
        </module>

        <!-- Prohibit T.getT() methods for standard boxed types -->
        <module name="Regexp">
            <property name="format" value="Boolean\.getBoolean"/>
            <property name="illegalPattern" value="true"/>
            <property name="message" value="Use System.getProperties() to get system properties."/>
        </module>

        <module name="Regexp">
            <property name="format" value="Integer\.getInteger"/>
            <property name="illegalPattern" value="true"/>
            <property name="message" value="Use System.getProperties() to get system properties."/>
        </module>

        <module name="Regexp">
            <property name="format" value="Long\.getLong"/>
            <property name="illegalPattern" value="true"/>
            <property name="message" value="Use System.getProperties() to get system properties."/>
        </module>

        <!-- IllegalImport cannot blacklist classes so we have to fall back to Regexp. -->
        <!-- forbid use of commons lang validate -->
        <module name="Regexp">
            <property name="format" value="org\.apache\.commons\.lang3\.Validate"/>
            <property name="illegalPattern" value="true"/>
            <property name="message"
                      value="Use Guava Checks instead of Commons Validate. Please refer to the coding guidelines."/>
        </module>

        <module name="Regexp">
            <property name="format" value="org\.apache\.commons\.lang\."/>
            <property name="illegalPattern" value="true"/>
            <property name="message" value="Use commons-lang3 instead of commons-lang."/>
        </module>

        <module name="Regexp">
            <property name="format" value="org\.codehaus\.jettison"/>
            <property name="illegalPattern" value="true"/>
            <property name="message" value="Use com.fasterxml.jackson instead of jettison."/>
        </module>

        <module name="IllegalImport">
            <property name="regexp" value="true"/>
            <property name="illegalPkgs"
                      value="^com\.google\.api\.client\.repackaged,
                      ^avro\.shaded, ^org\.apache\.hadoop\.hbase\.shaded,
                      ^org\.apache\.hadoop\.shaded,
                      ^javax\.ws\.rs\.ext,
                      ^cc\.concurrent\.mango\.util\.concurrent,
                      ^org\.apache\.curator-test\.shaded,
                      ^com\.sun\.istack,
                      ^org\.jetbrains\.annotations,
                      ^jline\.internal,
                      ^com\.cronutils\.utils,
                      ^javax\.ws\.rs\.ext,
                      ^org\.jboss\.netty\.util\.internal,
                      ^com\.sun\.javafx,
                      ^io\.reactivex\.annotations"/>
            <property name="illegalClasses"
                      value="^java\.util\.logging\.Logging,
                      ^sun\.misc\.BASE64Encoder,
                      ^sun\.misc\.BASE64Decoder,
                      ^jdk\.internal\.jline\.internal\.Nullable,
                      ^org\.junit\.(?!jupiter\.).+"/>
        </module>

        <module name="OuterTypeFilename">
            <property name="severity" value="error"/>
        </module>

        <module name="OneTopLevelClass">
            <property name="severity" value="error"/>
        </module>

        <module name="NoLineWrap">
            <property name="severity" value="error"/>
        </module>

        <!-- Checks for braces around if and else blocks -->
        <module name="NeedBraces">
            <property name="severity" value="error"/>
            <property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/>
        </module>

        <module name="LeftCurly">
            <property name="severity" value="error"/>
        </module>

        <module name="InnerTypeLast"/>
        <module name="IllegalTokenText">
            <property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
            <property name="format"
                      value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
            <property name="message"
                      value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
        </module>

        <module name="AvoidEscapedUnicodeCharacters">
            <property name="allowEscapesForControlCharacters" value="true"/>
            <property name="allowByTailComment" value="true"/>
            <property name="allowNonPrintableEscapes" value="true"/>
        </module>

        <module name="EmptyBlock">
            <property name="option" value="TEXT"/>
            <property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
        </module>

        <module name="OneStatementPerLine"/>

        <module name="MagicNumber">
            <property name="ignoreHashCodeMethod" value="true"/>
        </module>

        <module name="MultipleVariableDeclarations"/>

        <module name="ArrayTypeStyle"/>

        <module name="MissingSwitchDefault"/>

        <module name="FallThrough">
            <!-- Warn about falling through to the next case statement.  Similar to
            javac -Xlint:fallthrough, but the check is suppressed if a single-line comment
            on the last non-blank line preceding the fallen-into case contains 'fall through' (or
            some other variants that we don't publicized to promote consistency).
            -->
            <property name="reliefPattern"
                      value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
            <property name="severity" value="error"/>
        </module>

        <!-- MODIFIERS CHECKS -->
        <module name="ModifierOrder">
            <!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
                 8.4.3.  The prescribed order is:
                 public, protected, private, abstract, static, final, transient, volatile,
                 synchronized, native, strictfp
              -->
            <property name="severity" value="error"/>
        </module>

        <module name="SeparatorWrap">
            <property name="tokens" value="DOT"/>
            <property name="option" value="nl"/>
        </module>

        <module name="SeparatorWrap">
            <property name="tokens" value="COMMA"/>
            <property name="option" value="EOL"/>
        </module>

        <module name="UnusedImports">
            <property name="severity" value="error"/>
            <property name="processJavadoc" value="true"/>
            <message key="import.unused" value="Unused import: {0}."/>
        </module>

        <module name="RedundantImport">
            <!-- Checks for redundant import statements. -->
            <property name="severity" value="error"/>
            <message key="import.redundancy" value="Redundant import {0}."/>
        </module>

        <!-- Require static importing from Preconditions. -->
        <module name="RegexpSinglelineJava">
            <property name="format" value="^import com.google.common.base.Preconditions;$"/>
            <property name="message" value="Static import functions from Guava Preconditions"/>
        </module>

        <!-- Detect multiple consecutive semicolons (e.g. ";;"). -->
        <module name="RegexpSinglelineJava">
            <property name="format" value=";{2,}"/>
            <property name="message" value="Use one semicolon"/>
            <property name="ignoreComments" value="true"/>
        </module>

        <module name="RegexpSinglelineJava">
            <property name="format" value="throw new \w+Error\("/>
            <property name="message" value="Avoid throwing error in application code."/>
        </module>

        <module name="RegexpSinglelineJava">
            <property name="format" value="Objects\.toStringHelper"/>
            <property name="message" value="Avoid using Object.toStringHelper. Use ToStringBuilder instead."/>
        </module>

        <module name="JavadocStyle">
            <property name="severity" value="error"/>
            <property name="checkHtml" value="true"/>
            <property name="endOfSentenceFormat" value=""/>
        </module>

        <module name="RedundantModifier">
            <!-- Checks for redundant modifiers on various symbol definitions.
              See: http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier

              We exclude METHOD_DEF to allow final methods in final classes to make them more future-proof.
            -->
            <property name="tokens" value="VARIABLE_DEF, ANNOTATION_FIELD_DEF, INTERFACE_DEF, CLASS_DEF, ENUM_DEF"/>
        </module>

        <module name="AvoidStarImport"/>

        <module name="NonEmptyAtclauseDescription"/>

        <!--Checks that classes that override equals() also override hashCode()-->
        <module name="EqualsHashCode"/>
        <!--Checks for over-complicated boolean expressions. Currently finds code like if (topic == true), topic || true, !false, etc.-->
        <module name="SimplifyBooleanExpression"/>
        <module name="OneStatementPerLine"/>
        <module name="UnnecessaryParentheses"/>
        <!--Checks for over-complicated boolean return statements. For example the following code-->
        <module name="SimplifyBooleanReturn"/>

        <!--Check that the default is after all the cases in producerGroup switch statement-->
        <module name="DefaultComesLast"/>
        <!--Detects empty statements (standalone ";" semicolon)-->
        <module name="EmptyStatement">
            <property name="severity" value="error"/>
        </module>

        <!--Checks that long constants are defined with an upper ell-->
        <module name="UpperEll">
            <!-- Checks that long constants are defined with an upper ell.-->
            <property name="severity" value="error"/>
        </module>

        <module name="ConstantName">
            <property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)"/>
        </module>
        <!--Checks that local, non-final variable names conform to producerGroup format specified by the format property-->
        <module name="LocalVariableName">
            <!-- Validates identifiers for local variables against the expression "^[a-z][a-zA-Z0-9]*$". -->
            <property name="tokens" value="VARIABLE_DEF"/>
            <property name="format" value="^[a-z]([a-zA-Z0-9]*)?$"/>
            <property name="severity" value="error"/>
            <message key="name.invalidPattern" value="Local variable name ''{0}'' must match pattern ''{1}''."/>
        </module>

        <!--Validates identifiers for local, final variables, including catch parameters-->
        <module name="LocalFinalVariableName">
            <!-- Validates identifiers for local final variables against the expression "^[a-z][a-zA-Z0-9]*$". -->
            <property name="severity" value="error"/>
        </module>

        <!--Validates identifiers for non-static fields-->
        <module name="MemberName">
            <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
            <message key="name.invalidPattern" value="Member name ''{0}'' must match pattern ''{1}''."/>
        </module>

        <!--Validates identifiers for class type parameters-->
        <module name="ClassTypeParameterName">
            <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
            <message key="name.invalidPattern" value="Class type name ''{0}'' must match pattern ''{1}''."/>
        </module>

        <module name="PackageName">
            <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
            <property name="severity" value="error"/>
        </module>

        <module name="ConstantNameCheck">
            <!-- Validates non-private, static, final fields against the supplied public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". -->
            <metadata name="altname" value="ConstantName"/>
            <property name="applyToPublic" value="true"/>
            <property name="applyToProtected" value="true"/>
            <property name="applyToPackage" value="true"/>
            <property name="applyToPrivate" value="false"/>
            <property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$"/>
            <message key="name.invalidPattern"
                     value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/>
            <property name="severity" value="error"/>
        </module>

        <module name="MemberNameCheck">
            <!-- Validates non-static members against the supplied expression. -->
            <metadata name="altname" value="MemberName"/>
            <property name="applyToPublic" value="true"/>
            <property name="applyToProtected" value="true"/>
            <property name="applyToPackage" value="true"/>
            <property name="applyToPrivate" value="true"/>
            <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
            <property name="severity" value="error"/>
        </module>

        <module name="MethodNameCheck">
            <!-- Validates identifiers for method names. -->
            <metadata name="altname" value="MethodName"/>
            <property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/>
            <property name="severity" value="error"/>
        </module>

        <module name="MethodName">
            <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
            <message key="name.invalidPattern" value="Method name ''{0}'' must match pattern ''{1}''."/>
        </module>

        <module name="EmptyCatchBlock">
            <property name="exceptionVariableName" value="expected"/>
        </module>

        <module name="CommentsIndentation"/>

        <module name="ParameterName">
            <!-- Validates identifiers for method parameters against the expression "^[a-z][a-zA-Z0-9]*$". -->
            <property name="format" value="^[a-z]([a-zA-Z0-9]*)?$"/>
            <property name="severity" value="error"/>
            <message key="name.invalidPattern" value="Parameter name ''{0}'' must match pattern ''{1}''."/>
        </module>

        <module name="CatchParameterName">
            <property name="format" value="^[a-z]([a-zA-Z0-9]*)?$"/>
            <message key="name.invalidPattern" value="Catch parameter name ''{0}'' must match pattern ''{1}''."/>
        </module>

        <module name="StaticVariableNameCheck">
            <!-- Validates static, non-final fields against the supplied expression "^[a-z][a-zA-Z0-9]*_?$". -->
            <metadata name="altname" value="StaticVariableName"/>
            <property name="applyToPublic" value="true"/>
            <property name="applyToProtected" value="true"/>
            <property name="applyToPackage" value="true"/>
            <property name="applyToPrivate" value="true"/>
            <property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)"/>
            <property name="severity" value="error"/>
        </module>

        <module name="TypeNameCheck">
            <!-- Validates static, final fields against the expression "^[A-Z][a-zA-Z0-9]*$". -->
            <metadata name="altname" value="TypeName"/>
            <property name="severity" value="error"/>
        </module>

        <module name="TypeName">
            <property name="format" value="(^[A-Z][a-zA-Z0-9]*$)|(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)"/>
            <message key="name.invalidPattern" value="Type name ''{0}'' must match pattern ''{1}''."/>
        </module>
        <module name="MissingOverride"/>

        <!--whitespace-->
        <module name="GenericWhitespace">
            <message key="ws.followed" value="GenericWhitespace ''{0}'' is followed by whitespace."/>
            <message key="ws.preceded" value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
            <message key="ws.illegalFollow" value="GenericWhitespace ''{0}'' should followed by whitespace."/>
            <message key="ws.notPreceded" value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
        </module>

        <module name="Indentation">
            <property name="basicOffset" value="4"/>
            <property name="braceAdjustment" value="0"/>
            <property name="caseIndent" value="4"/>
            <property name="throwsIndent" value="2"/>
            <property name="lineWrappingIndentation" value="4"/>
            <property name="arrayInitIndent" value="4"/>
        </module>

        <module name="NoFinalizer"/>

        <module name="NoWhitespaceAfter">
            <!-- Checks that there is no whitespace after various unary operators.
                 Linebreaks are allowed.
            -->
            <property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS"/>
            <property name="allowLineBreaks" value="true"/>
            <property name="severity" value="error"/>
        </module>

        <module name="WhitespaceAfter">
            <!-- Checks that commas, semicolons and typecasts are followed by
                 whitespace.
            -->
            <property name="tokens" value="COMMA, SEMI, TYPECAST"/>
        </module>

        <module name="WhitespaceAround">
            <!-- Checks that various tokens are surrounded by whitespace.
                 This includes most binary operators and keywords followed
                 by regular or curly braces.
            -->
            <property name="allowEmptyConstructors" value="true"/>
            <property name="allowEmptyMethods" value="true"/>
            <property name="allowEmptyTypes" value="true"/>
            <property name="allowEmptyLoops" value="true"/>
            <property name="severity" value="error"/>
            <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
        BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
        EQUAL, GE, GT, LAMBDA, LAND, LE, 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, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
            <message key="ws.notFollowed"
                     value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
            <message key="ws.notPreceded" value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
        </module>

        <module name="MethodParamPad"/>
        <module name="ParenPad">
            <!-- Checks that there is no whitespace before close parens or after open parens. -->
            <property name="severity" value="error"/>
        </module>

        <module name="NoWhitespaceBefore">
            <!-- Checks that there is no whitespace before various unary operators. Linebreaks are allowed. -->
            <property name="tokens" value="COMMA, SEMI, DOT, POST_DEC, POST_INC, ELLIPSIS, METHOD_REF"/>
            <property name="allowLineBreaks" value="true"/>
            <property name="severity" value="error"/>
        </module>

        <module name="OperatorWrap">
            <!-- Checks that assignment operators are at the end of the line. -->
            <property name="option" value="eol"/>
            <property name="tokens"
                      value="ASSIGN, BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LE, LITERAL_INSTANCEOF, LT, MINUS, MOD, NOT_EQUAL, QUESTION, SL, SR, STAR, METHOD_REF"/>
        </module>

        <module name="AnnotationLocation">
            <property name="allowSamelineMultipleAnnotations" value="false"/>
            <property name="allowSamelineSingleParameterlessAnnotation" value="false"/>
            <property name="allowSamelineParameterizedAnnotation" value="true"/>
            <property name="tokens" value="METHOD_DEF, CTOR_DEF, VARIABLE_DEF, CLASS_DEF, INTERFACE_DEF, ENUM_DEF"/>
        </module>

        <module name="TypecastParenPad"/>

        <module name="EmptyLineSeparator">
            <!-- Checks for empty line separator between tokens. The only
                 excluded token is VARIABLE_DEF, allowing class fields to
                 be declared on consecutive lines.
            -->
            <property name="allowNoEmptyLineBetweenFields" value="true"/>
            <property name="allowMultipleEmptyLines" value="false"/>
            <property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
            <property name="tokens"
                      value="PACKAGE_DEF, IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF, STATIC_INIT, INSTANCE_INIT, METHOD_DEF, CTOR_DEF"/>
        </module>
    </module>
</module>
