use of edu.umd.cs.findbugs.Project in project spotbugs by spotbugs.
the class MergeSummarizeAndView method union.
public static SortedBugCollection union(SortedBugCollection origCollection, SortedBugCollection newCollection) {
SortedBugCollection result = origCollection.duplicate();
for (Iterator<BugInstance> i = newCollection.iterator(); i.hasNext(); ) {
BugInstance bugInstance = i.next();
result.add(bugInstance);
}
ProjectStats stats = result.getProjectStats();
ProjectStats stats2 = newCollection.getProjectStats();
stats.addStats(stats2);
Project project = result.getProject();
project.add(newCollection.getProject());
return result;
}
use of edu.umd.cs.findbugs.Project in project spotbugs by spotbugs.
the class MergeSummarizeAndView method load.
private void load() {
if (options.workingDirList.isEmpty()) {
String userDir = System.getProperty("user.dir");
if (null != userDir && !"".equals(userDir)) {
options.workingDirList.add(userDir);
}
}
IGuiCallback cliUiCallback = new CommandLineUiCallback();
for (String analysisFile : options.analysisFiles) {
try {
SortedBugCollection more = createPreconfiguredBugCollection(options.workingDirList, options.srcDirList, cliUiCallback);
more.readXML(analysisFile);
BugRanker.trimToMaxRank(more, options.maxConsideredRank);
if (results != null) {
results = union(results, more);
} else {
results = more;
}
} catch (IOException e) {
System.err.println("Trouble reading " + analysisFile);
} catch (DocumentException e) {
System.err.println("Trouble parsing " + analysisFile);
}
}
if (results == null) {
throw new RuntimeException("No files successfully read");
}
Project project = results.getProject();
long old = System.currentTimeMillis() - options.maxAge * (24 * 3600 * 1000L);
if (options.baselineDate != null) {
long old2 = options.baselineDate.getTime();
if (old2 > old) {
old = old2;
}
}
scaryBugs = results.createEmptyCollectionWithMetadata();
for (BugInstance warning : results.getCollection()) {
if (!project.getSuppressionFilter().match(warning)) {
int rank = BugRanker.findRank(warning);
if (rank > BugRanker.VISIBLE_RANK_MAX) {
continue;
}
boolean highRank = rank > options.maxRank;
if (highRank) {
numLowConfidence++;
} else {
scaryBugs.add(warning);
}
}
}
}
use of edu.umd.cs.findbugs.Project in project spotbugs by spotbugs.
the class FindNonShortCircuitTest method setup.
@Before
public void setup() {
PrintingBugReporter bugReporter = new PrintingBugReporter();
ctx = AnalysisContext.currentAnalysisContext();
if (ctx == null) {
AnalysisContext.setCurrentAnalysisContext(new AnalysisContext(new Project()));
}
check = new FindNonShortCircuit(bugReporter);
}
use of edu.umd.cs.findbugs.Project in project sonar-findbugs by spotbugs.
the class FindbugsConfigurationTest method should_set_class_path.
@Test
void should_set_class_path() throws IOException {
File classpath = new File(temp, "classpath");
when(javaResourceLocator.classpath()).thenReturn(ImmutableList.of(classpath));
try (Project findbugsProject = new Project()) {
conf.initializeFindbugsProject(findbugsProject);
assertThat(findbugsProject.getAuxClasspathEntryList()).contains(classpath.getCanonicalPath());
conf.stop();
}
}
use of edu.umd.cs.findbugs.Project in project sonar-findbugs by spotbugs.
the class FindbugsConfigurationTest method should_warn_of_missing_precompiled_jsp.
@Test
void should_warn_of_missing_precompiled_jsp() throws IOException {
setupJspProject(false);
try (Project project = new Project()) {
conf.initializeFindbugsProject(project);
}
// There should be two warnings:
// - There are JSP but they are not precompiled
// - Findbugs needs sources to be compiled
assertThat(logTester.getLogs(LoggerLevel.WARN)).hasSize(2);
}
Aggregations