use of edu.umd.cs.findbugs.Project in project spotbugs by spotbugs.
the class MainFrame method shouldDisplayIssueIgnoringPackagePrefixes.
// @SuppressWarnings({ "SimplifiableIfStatement" })
private boolean shouldDisplayIssueIgnoringPackagePrefixes(BugInstance b) {
Project project = getProject();
Filter suppressionFilter = project.getSuppressionFilter();
if (null == getBugCollection() || suppressionFilter.match(b)) {
return false;
}
return viewFilter.showIgnoringPackagePrefixes(b);
}
use of edu.umd.cs.findbugs.Project in project spotbugs by spotbugs.
the class BugLoader method loadProject.
@CheckForNull
public static Project loadProject(MainFrame mainFrame, File f) {
try {
Project project = Project.readXML(f);
project.setGuiCallback(mainFrame.getGuiCallback());
return project;
} catch (IOException e) {
JOptionPane.showMessageDialog(mainFrame, "Could not read " + f + "; " + e.getMessage());
} catch (SAXException | ParserConfigurationException e) {
JOptionPane.showMessageDialog(mainFrame, "Could not read project from " + f + "; " + e.getMessage());
}
return null;
}
use of edu.umd.cs.findbugs.Project in project spotbugs by spotbugs.
the class AnalysisRunner method run.
@Nonnull
public BugCollectionBugReporter run(Consumer<IFindBugsEngine> engineCustomization, Path... files) {
DetectorFactoryCollection.resetInstance(new DetectorFactoryCollection());
try (FindBugs2 engine = new FindBugs2();
Project project = createProject(files)) {
engine.setProject(project);
final DetectorFactoryCollection detectorFactoryCollection = DetectorFactoryCollection.instance();
engine.setDetectorFactoryCollection(detectorFactoryCollection);
BugCollectionBugReporter bugReporter = new BugCollectionBugReporter(project);
bugReporter.setPriorityThreshold(Priorities.LOW_PRIORITY);
bugReporter.setRankThreshold(BugRanker.VISIBLE_RANK_MAX);
engine.setBugReporter(bugReporter);
final UserPreferences preferences = UserPreferences.createDefaultUserPreferences();
preferences.getFilterSettings().clearAllCategories();
preferences.enableAllDetectors(true);
engine.setUserPreferences(preferences);
engineCustomization.accept(engine);
try {
engine.execute();
} catch (final IOException | InterruptedException e) {
throw new AssertionError("Analysis failed with exception", e);
}
if (!bugReporter.getQueuedErrors().isEmpty()) {
bugReporter.reportQueuedErrors();
throw new AssertionError("Analysis failed with exception. Check stderr for detail.");
}
return bugReporter;
}
}
use of edu.umd.cs.findbugs.Project in project spotbugs by spotbugs.
the class AnalysisRunner method createProject.
@CheckReturnValue
private Project createProject(Path[] files) {
final Project project = new Project();
project.setProjectName(getClass().getSimpleName());
if (PLUGIN_JAR != null) {
try {
String pluginId = Plugin.addCustomPlugin(PLUGIN_JAR.toURI()).getPluginId();
project.setPluginStatusTrinary(pluginId, Boolean.TRUE);
} catch (PluginException e) {
throw new AssertionError("Failed to load plugin", e);
}
}
for (Path file : files) {
project.addFile(file.toAbsolutePath().toString());
}
for (Path auxClasspathEntry : auxClasspathEntries) {
project.addAuxClasspathEntry(auxClasspathEntry.toAbsolutePath().toString());
}
return project;
}
use of edu.umd.cs.findbugs.Project in project spotbugs by spotbugs.
the class UnionResults method merge.
public static void merge(HashSet<String> hashes, SortedBugCollection into, SortedBugCollection from) {
for (BugInstance bugInstance : from.getCollection()) {
if (hashes == null || hashes.add(bugInstance.getInstanceHash())) {
into.add(bugInstance);
}
}
ProjectStats stats = into.getProjectStats();
ProjectStats stats2 = from.getProjectStats();
stats.addStats(stats2);
Project project = into.getProject();
Project project2 = from.getProject();
project.add(project2);
for (AnalysisError error : from.getErrors()) {
into.addError(error);
}
return;
}
Aggregations