use of edu.umd.cs.findbugs.DetectorFactoryCollection in project spotbugs by spotbugs.
the class PlaceholderTest method setup.
@Before
public void setup() {
Project project = new Project();
reporter = new SarifBugReporter(project);
writer = new StringWriter();
reporter.setWriter(new PrintWriter(writer));
reporter.setPriorityThreshold(Priorities.IGNORE_PRIORITY);
DetectorFactoryCollection.resetInstance(new DetectorFactoryCollection());
IAnalysisCache analysisCache = ClassFactory.instance().createAnalysisCache(new ClassPathImpl(), reporter);
Global.setAnalysisCacheForCurrentThread(analysisCache);
FindBugs2.registerBuiltInAnalysisEngines(analysisCache);
AnalysisContext analysisContext = new AnalysisContext(project) {
public boolean isApplicationClass(@DottedClassName String className) {
// treat all classes as application class, to report bugs in it
return true;
}
};
AnalysisContext.setCurrentAnalysisContext(analysisContext);
}
use of edu.umd.cs.findbugs.DetectorFactoryCollection in project spotbugs by spotbugs.
the class GenerateUpdateXml method main.
public static void main(String[] args) {
FindBugs.setNoAnalysis();
DetectorFactoryCollection dfc = DetectorFactoryCollection.instance();
for (Plugin p : dfc.plugins()) {
System.out.println(p.getPluginId());
System.out.println(p.getReleaseDate());
System.out.println(p.getVersion());
System.out.println();
}
}
use of edu.umd.cs.findbugs.DetectorFactoryCollection in project spotbugs by spotbugs.
the class PrintBugDescriptions method print.
public void print() throws IOException {
// Ensure bug patterns are loaded
DetectorFactoryCollection factories = DetectorFactoryCollection.instance();
// Find all bug patterns reported by at least one non-disabled detector.
Collection<BugPattern> enabledPatternSet = new HashSet<BugPattern>();
for (Iterator<DetectorFactory> i = factories.factoryIterator(); i.hasNext(); ) {
DetectorFactory factory = i.next();
if (isEnabled(factory)) {
enabledPatternSet.addAll(factory.getReportedBugPatterns());
}
}
prologue();
Iterator<BugPattern> i = DetectorFactoryCollection.instance().bugPatternIterator();
while (i.hasNext()) {
BugPattern bugPattern = i.next();
if (!enabledPatternSet.contains(bugPattern)) {
continue;
}
emit(bugPattern);
}
epilogue();
}
use of edu.umd.cs.findbugs.DetectorFactoryCollection in project spotbugs by spotbugs.
the class TestDataflowAnalysis method initialize.
private void initialize() {
initialized = true;
IAnalysisCache analysisCache = Global.getAnalysisCache();
Class<? extends Dataflow<Fact, AnalysisType>> cls = null;
// First, try loading the dataflow class from the general findBugs code.
try {
Class<?> c = getClass().getClassLoader().loadClass(dataflowClassName);
cls = asDataflowClass(c);
} catch (ClassNotFoundException e) {
assert true;
}
if (cls == null) {
// Find the dataflow class from the plugin in which it was loaded
DetectorFactoryCollection detectorFactoryCollection = analysisCache.getDatabase(DetectorFactoryCollection.class);
for (Iterator<Plugin> i = detectorFactoryCollection.pluginIterator(); i.hasNext(); ) {
Plugin plugin = i.next();
try {
cls = asDataflowClass(plugin.getClassLoader().loadClass(dataflowClassName));
break;
} catch (ClassNotFoundException e) {
assert true;
}
}
}
if (cls == null) {
analysisCache.getErrorLogger().logError("TestDataflowAnalysis: could not load class " + dataflowClassName);
return;
}
dataflowClass = cls;
}
use of edu.umd.cs.findbugs.DetectorFactoryCollection in project spotbugs by spotbugs.
the class ExecutionPlan method main.
public static void main(String[] argv) throws Exception {
DetectorFactoryCollection detectorFactoryCollection = DetectorFactoryCollection.instance();
ExecutionPlan execPlan = new ExecutionPlan();
for (String pluginId : argv) {
Plugin plugin = detectorFactoryCollection.getPluginById(pluginId);
if (plugin != null) {
execPlan.addPlugin(plugin);
}
}
execPlan.build();
System.out.println(execPlan.getNumPasses() + " passes in plan");
execPlan.print();
}
Aggregations