@ Override public void visitCode ( Code obj ) { if ( getMethod ( ) . isSynthetic ( ) ) { return ; } String methodName = getMethodName ( ) ; String methodSig = getMethodSig ( ) ; if ( methodName . equals ( methodInfo . methodName ) && methodSig . endsWith ( methodInfo . signatureEnding ) && ( SignatureUtils . getNumParameters ( methodSig ) == methodInfo . argumentCount ) ) { stack . resetForMethodEntry ( this ) ; seenNegative = false ; seenPositive = false ; seenZero = false ; seenUnconditionalNonZero = false ; furthestBranchTarget = - 1 ; sawConstant = null ; try { super . visitCode ( obj ) ; if ( ! seenZero || seenUnconditionalNonZero || ( obj . getCode ( ) . length > 2 ) ) { boolean seenAll = seenNegative & seenPositive & seenZero ; if ( ! seenAll || seenUnconditionalNonZero ) { bugReporter . reportBug ( new BugInstance ( this , BugType . SCRV_SUSPICIOUS_COMPARATOR_RETURN_VALUES . name ( ) , seenAll ? LOW_PRIORITY : NORMAL_PRIORITY ) . addClass ( this ) . addMethod ( this ) . addSourceLine ( this , 0 ) ) ; } } } catch ( StopOpcodeParsingException e ) { // indeterminate } } }
implements the visitor to check to see what Const were returned from a comparator . If no Const were returned it can t determine anything however if only Const were returned it looks to see if negative positive and zero was returned . It also looks to see if a non zero value is returned unconditionally . While it is possible that later check is ok it usually means something is wrong .