@After public void tearDown() { Global.setAnalysisCacheForCurrentThread(null); }
@Before public void setUp () { Global.setAnalysisCacheForCurrentThread(new NoopAnalysisCache()); }
/** * Create the analysis cache object and register it for current execution thread. * <p> * This method is protected to allow clients override it and possibly reuse * some previous analysis data (for Eclipse interactive re-build) * * @throws IOException * if error occurs registering analysis engines in a plugin */ protected IAnalysisCache createAnalysisCache() throws IOException { IAnalysisCache analysisCache = ClassFactory.instance().createAnalysisCache(classPath, bugReporter); // Register the "built-in" analysis engines registerBuiltInAnalysisEngines(analysisCache); // Register analysis engines in plugins registerPluginAnalysisEngines(detectorFactoryCollection, analysisCache); // Install the DetectorFactoryCollection as a database analysisCache.eagerlyPutDatabase(DetectorFactoryCollection.class, detectorFactoryCollection); Global.setAnalysisCacheForCurrentThread(analysisCache); return analysisCache; } /**
/** * Create the analysis cache object and register it for current execution thread. * <p> * This method is protected to allow clients override it and possibly reuse * some previous analysis data (for Eclipse interactive re-build) * * @throws IOException * if error occurs registering analysis engines in a plugin */ protected IAnalysisCache createAnalysisCache() throws IOException { IAnalysisCache analysisCache = ClassFactory.instance().createAnalysisCache(classPath, bugReporter); // Register the "built-in" analysis engines registerBuiltInAnalysisEngines(analysisCache); // Register analysis engines in plugins registerPluginAnalysisEngines(detectorFactoryCollection, analysisCache); // Install the DetectorFactoryCollection as a database analysisCache.eagerlyPutDatabase(DetectorFactoryCollection.class, detectorFactoryCollection); Global.setAnalysisCacheForCurrentThread(analysisCache); return analysisCache; } /**
private static void setUpStaticDependenciesWithinFindBugs(BugReporter bugReporter) throws Exception { bugReporter.setPriorityThreshold(Priorities.LOW_PRIORITY); ClassPathImpl classPath = new ClassPathImpl(); IAnalysisCache analysisCache = ClassFactory.instance().createAnalysisCache(classPath, bugReporter); new ClassContextClassAnalysisEngine().registerWith(analysisCache); new edu.umd.cs.findbugs.classfile.engine.asm.EngineRegistrar().registerAnalysisEngines(analysisCache); new edu.umd.cs.findbugs.classfile.engine.bcel.EngineRegistrar().registerAnalysisEngines(analysisCache); new edu.umd.cs.findbugs.classfile.engine.EngineRegistrar().registerAnalysisEngines(analysisCache); registerUserDefined(analysisCache); Global.setAnalysisCacheForCurrentThread(analysisCache); ICodeBaseLocator codeBaseLocator = new FilesystemCodeBaseLocator("."); ICodeBase codeBase = new DirectoryCodeBase(codeBaseLocator, new File(CODEBASE_DIRECTORY)); codeBase.setApplicationCodeBase(true); classPath.addCodeBase(codeBase); addAuxCodeBasesFromClassPath(classPath); IClassFactory classFactory = ClassFactory.instance(); IClassPathBuilder builder = classFactory.createClassPathBuilder(bugReporter); builder.addCodeBase(codeBaseLocator, true); builder.scanNestedArchives(true); IClassPathBuilderProgress progress = new NoOpFindBugsProgress(); builder.build(classPath, progress); List<ClassDescriptor> appClassList = builder.getAppClassList(); AnalysisCacheToAnalysisContextAdapter analysisContext = new AnalysisCacheToAnalysisContextAdapter(); AnalysisContext.setCurrentAnalysisContext(analysisContext); analysisContext.setAppClassList(appClassList); analysisContext.setFieldSummary(new FieldSummary()); }