Class MethodReturnCheck

All Implemented Interfaces:
Detector, Priorities, UseAnnotationDatabase, org.apache.bcel.classfile.Visitor

public class MethodReturnCheck extends OpcodeStackDetector implements UseAnnotationDatabase
Look for calls to methods where the return value is erroneously ignored. This detector is meant as a simpler and faster replacement for BCPMethodReturnCheck.
  • Field Details

  • Constructor Details

    • MethodReturnCheck

      public MethodReturnCheck(BugReporter bugReporter)
  • Method Details

    • visitClassContext

      public void visitClassContext(ClassContext classContext)
      Description copied from interface: Detector
      Visit the ClassContext for a class which should be analyzed for instances of bug patterns.
      Specified by:
      visitClassContext in interface Detector
      Overrides:
      visitClassContext in class BytecodeScanningDetector
      Parameters:
      classContext - the ClassContext
    • visitAfter

      public void visitAfter(org.apache.bcel.classfile.Code code)
      Description copied from class: PreorderVisitor
      Called after visiting a code attribute
      Overrides:
      visitAfter in class PreorderVisitor
      Parameters:
      code - Code that was just visited
    • badUseOfCompareResult

      private boolean badUseOfCompareResult(OpcodeStack.Item left, OpcodeStack.Item right)
    • sawOpcode

      public void sawOpcode(int seen)
      Description copied from class: OpcodeStackDetector

      By default, this method will not be called when stack is TOP. To change this behavior, override #beforeOpcode(int) and change to return true even if stack is TOP.

      see Using FindBugs for Research to learn lattice and what TOP means.

      Specified by:
      sawOpcode in class OpcodeStackDetector
      See Also:
    • isCallMockitoVerifyInvocation

      private boolean isCallMockitoVerifyInvocation(XMethod method)
    • sawMethodCallWithIgnoredReturnValue

      private void sawMethodCallWithIgnoredReturnValue()
    • isPop

      private boolean isPop(int seen)