Class AbstractClassCouplingCheck

    • Constructor Detail

      • AbstractClassCouplingCheck

        protected AbstractClassCouplingCheck​(int defaultMax)
        Creates new instance of the check.
        Parameters:
        defaultMax - default value for allowed complexity.
    • Method Detail

      • getLogMessageId

        protected abstract String getLogMessageId()
        Returns message key we use for log violations.
        Returns:
        message key we use for log violations.
      • setMax

        public final void setMax​(int max)
        Setter to specify the maximum threshold allowed.
        Parameters:
        max - allowed complexity.
      • setExcludedClasses

        public final void setExcludedClasses​(String... excludedClasses)
        Setter to specify user-configured class names to ignore.
        Parameters:
        excludedClasses - classes to ignore.
      • setExcludeClassesRegexps

        public void setExcludeClassesRegexps​(String... from)
        Setter to specify user-configured regular expressions to ignore classes.
        Parameters:
        from - array representing regular expressions of classes to ignore.
      • setExcludedPackages

        public final void setExcludedPackages​(String... excludedPackages)
        Setter to specify user-configured packages to ignore.
        Parameters:
        excludedPackages - packages to ignore.
        Throws:
        IllegalArgumentException - if there are invalid identifiers among the packages.
      • beginTree

        public final void beginTree​(DetailAST ast)
        Description copied from class: AbstractCheck
        Called before the starting to process a tree. Ideal place to initialize information that is to be collected whilst processing a tree.
        Overrides:
        beginTree in class AbstractCheck
        Parameters:
        ast - the root of the tree
      • visitPackageDef

        private void visitPackageDef​(DetailAST pkg)
        Stores package of current class we check.
        Parameters:
        pkg - package definition.
      • visitClassDef

        private void visitClassDef​(DetailAST classDef)
        Creates new context for a given class.
        Parameters:
        classDef - class definition node.
      • leaveClassDef

        private void leaveClassDef()
        Restores previous context.
      • registerImport

        private void registerImport​(DetailAST imp)
        Registers given import. This allows us to track imported classes.
        Parameters:
        imp - import definition.
      • createNewClassContext

        private void createNewClassContext​(String className,
                                           DetailAST ast)
        Creates new inner class context with given name and location.
        Parameters:
        className - The class name.
        ast - The class ast.
      • visitType

        private void visitType​(DetailAST ast)
        Visits type token for the current class context.
        Parameters:
        ast - TYPE token.
      • visitLiteralNew

        private void visitLiteralNew​(DetailAST ast)
        Visits NEW token for the current class context.
        Parameters:
        ast - NEW token.
      • visitLiteralThrows

        private void visitLiteralThrows​(DetailAST ast)
        Visits THROWS token for the current class context.
        Parameters:
        ast - THROWS token.
      • visitAnnotationType

        private void visitAnnotationType​(DetailAST annotationAST)
        Visit ANNOTATION literal and get its type to referenced classes of context.
        Parameters:
        annotationAST - Annotation ast.