Class ReturnCountCheck.Context

    • Field Detail

      • checking

        private final boolean checking
        Whether we should check this method or not.
      • count

        private int count
        Counter for return statements.
      • maxAllowed

        private Integer maxAllowed
        Maximum allowed number of return statements.
      • isVoidContext

        private boolean isVoidContext
        Identifies if context is void.
    • Constructor Detail

      • Context

        private Context​(boolean checking)
        Creates new method context.
        Parameters:
        checking - should we check this method or not
    • Method Detail

      • visitLiteralReturn

        public void visitLiteralReturn​(int maxAssigned,
                                       Boolean voidReturn)
        Increase the number of return statements and set context return type.
        Parameters:
        maxAssigned - Maximum allowed number of return statements.
        voidReturn - Identifies if context is void.
      • checkCount

        public void checkCount​(DetailAST ast)
        Checks if number of return statements in the method are more than allowed.
        Parameters:
        ast - method def associated with this context.