Class CheckstyleTestMakeupCheck

  • All Implemented Interfaces:
    com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.Contextualizable

    public class CheckstyleTestMakeupCheck
    extends com.puppycrawl.tools.checkstyle.api.AbstractCheck

    Custom check to ensure Checkstyle tests are designed correctly.

    Rationale: This check was made to ensure tests follow a specific design implementation so 3rd party utilities like the regression utility can parse the tests for information used in creating regression reports.

    Check have following options:

    • createMethodRegexp - Regular expression for matching a create configuration method by name. This is the name of the method that starts creating a custom module configuration to be used for verifying results for regression purposes. Default value is create(Root|Module)Config|getModuleConfig.
    • verifyMethodRegexp - Regular expression for matching a verify method by name. This is the name of the method that verifies the execution results of the custom configuration created for regression. As such, it should accept the custom configuration as a parameter. Default value is verify(Warns|Suppressed)?.

    To configure the check to report incorrectly made checkstyle tests:

     <module name="CheckstyleTestMakeup"/>
     
    Since:
    1.25.0
    Author:
    Richard Veach
    • Field Detail

      • MSG_KEY_CONFIG_NOT_ASSIGNED

        public static final String MSG_KEY_CONFIG_NOT_ASSIGNED
        Violations message.
        See Also:
        Constant Field Values
      • MSG_KEY_CONFIG_NOT_ASSIGNED_WITH

        public static final String MSG_KEY_CONFIG_NOT_ASSIGNED_WITH
        Violations message.
        See Also:
        Constant Field Values
      • MSG_KEY_CONFIG_NOT_ASSIGNED_PROPERLY

        public static final String MSG_KEY_CONFIG_NOT_ASSIGNED_PROPERLY
        Violations message.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CheckstyleTestMakeupCheck

        public CheckstyleTestMakeupCheck()
    • Method Detail

      • setCreateMethodRegexp

        public void setCreateMethodRegexp​(Pattern createMethodRegexp)
        Setter for createMethodRegexp.
        Parameters:
        createMethodRegexp - The value to set.
      • setVerifyMethodRegexp

        public void setVerifyMethodRegexp​(Pattern verifyMethodRegexp)
        Setter for verifyMethodRegexp.
        Parameters:
        verifyMethodRegexp - The value to set.
      • getDefaultTokens

        public int[] getDefaultTokens()
        Specified by:
        getDefaultTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • getAcceptableTokens

        public int[] getAcceptableTokens()
        Specified by:
        getAcceptableTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • getRequiredTokens

        public int[] getRequiredTokens()
        Specified by:
        getRequiredTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • beginTree

        public void beginTree​(com.puppycrawl.tools.checkstyle.api.DetailAST rootAST)
        Overrides:
        beginTree in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • visitToken

        public void visitToken​(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
        Overrides:
        visitToken in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • leaveToken

        public void leaveToken​(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
        Overrides:
        leaveToken in class com.puppycrawl.tools.checkstyle.api.AbstractCheck