Class JavaNCSSCheck

  • All Implemented Interfaces:
    Configurable, Contextualizable

    public class JavaNCSSCheck
    extends AbstractCheck
    This check calculates the Non Commenting Source Statements (NCSS) metric for java source files and methods. The check adheres to the JavaNCSS specification and gives the same results as the JavaNCSS tool.

    The NCSS-metric tries to determine complexity of methods, classes and files by counting the non commenting lines. Roughly said this is (nearly) equivalent to counting the semicolons and opening curly braces.

    Author:
    Lars Ködderitzsch
    • Method Detail

      • getAcceptableTokens

        public int[] getAcceptableTokens()
        Description copied from class: AbstractCheck
        The configurable token set. Used to protect Checks against malicious users who specify an unacceptable token set in the configuration file. The default implementation returns the check's default tokens.
        Specified by:
        getAcceptableTokens in class AbstractCheck
        Returns:
        the token set this check is designed for.
        See Also:
        TokenTypes
      • beginTree

        public void beginTree​(DetailAST rootAST)
        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:
        rootAST - the root of the tree
      • finishTree

        public void finishTree​(DetailAST rootAST)
        Description copied from class: AbstractCheck
        Called after finished processing a tree. Ideal place to report on information collected whilst processing a tree.
        Overrides:
        finishTree in class AbstractCheck
        Parameters:
        rootAST - the root of the tree
      • setFileMaximum

        public void setFileMaximum​(int fileMaximum)
        Sets the maximum ncss for a file.
        Parameters:
        fileMaximum - the maximum ncss
      • setClassMaximum

        public void setClassMaximum​(int classMaximum)
        Sets the maximum ncss for a class.
        Parameters:
        classMaximum - the maximum ncss
      • setMethodMaximum

        public void setMethodMaximum​(int methodMaximum)
        Sets the maximum ncss for a method.
        Parameters:
        methodMaximum - the maximum ncss