public static boolean isDetectorEnabled ( IFindBugsEngine findBugs , DetectorFactory factory , int rankThreshold ) { if ( ! findBugs . getUserPreferences ( ) . isDetectorEnabled ( factory ) ) { return false ; } if ( ! factory . isEnabledForCurrentJRE ( ) ) { return false ; } // Slow first pass detectors are usually disabled, but may be explicitly // enabled if ( ! AnalysisContext . currentAnalysisContext ( ) . getBoolProperty ( FindBugsAnalysisFeatures . INTERPROCEDURAL_ANALYSIS ) && factory . isDetectorClassSubtypeOf ( InterproceduralFirstPassDetector . class ) ) { return false ; } int maxRank = Integer . MAX_VALUE ; Set < BugPattern > reportedBugPatterns = factory . getReportedBugPatterns ( ) ; boolean isNonReportingDetector = factory . isDetectorClassSubtypeOf ( FirstPassDetector . class ) ; if ( ! isNonReportingDetector && ! reportedBugPatterns . isEmpty ( ) ) { for ( BugPattern b : reportedBugPatterns ) { int rank = BugRanker . findRank ( b , factory ) ; if ( maxRank > rank ) { maxRank = rank ; } } if ( maxRank > rankThreshold ) { return false ; } } // Training detectors are enabled if, and only if, we are emitting // training output boolean isTrainingDetector = factory . isDetectorClassSubtypeOf ( TrainingDetector . class ) ; if ( findBugs . emitTrainingOutput ( ) ) { return isTrainingDetector || isNonReportingDetector ; } return ! isTrainingDetector ; }
Determines whether or not given DetectorFactory should be enabled .