Class ReturnCountCheck.Context

java.lang.Object
com.puppycrawl.tools.checkstyle.checks.coding.ReturnCountCheck.Context
Enclosing class:
ReturnCountCheck

private final class ReturnCountCheck.Context extends Object
Class to encapsulate information about one method.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final boolean
    Whether we should check this method or not.
    private int
    Counter for return statements.
    private boolean
    Identifies if context is void.
    private Integer
    Maximum allowed number of return statements.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Context(boolean checking)
    Creates new method context.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Checks if number of return statements in the method are more than allowed.
    void
    visitLiteralReturn(int maxAssigned, Boolean voidReturn)
    Increase the number of return statements and set context return type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • checking

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

      private int count
      Counter for return statements.
    • maxAllowed

      Maximum allowed number of return statements.
    • isVoidContext

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

    • Context

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

    • 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.