resultCollection.setWithMessages(commandLine.withMessages);
if (commandLine.hashChangedSpecified) {
origCollection.computeBugHashes();
}
commandLine.adjustFilter(project, resultCollection);
ProjectStats projectStats = resultCollection.getProjectStats();
projectStats.clearBugCounts();
if (commandLine.classPattern != null) {
projectStats.purgeClassesThatDontMatch(commandLine.classPattern);
}
sourceSearcher = new SourceSearcher(project);
long trimToVersion = -1;
if (commandLine.trimToVersionAsString != null) {
Map<String, AppVersion> versions = new HashMap<String, AppVersion>();
SortedMap<Long, AppVersion> timeStamps = new TreeMap<Long, AppVersion>();
for (Iterator<AppVersion> i = origCollection.appVersionIterator(); i.hasNext();) {
AppVersion v = i.next();
versions.put(v.getReleaseName(), v);
timeStamps.put(v.getTimestamp(), v);
}
// add current version to the maps
AppVersion v = resultCollection.getCurrentAppVersion();
versions.put(v.getReleaseName(), v);
timeStamps.put(v.getTimestamp(), v);
trimToVersion = edu.umd.cs.findbugs.workflow.Filter.FilterCommandLine.getVersionNum(versions, timeStamps,
commandLine.trimToVersionAsString, true, v.getSequenceNumber());
if (trimToVersion < origCollection.getSequenceNumber()) {
String name = resultCollection.getAppVersionFromSequenceNumber(trimToVersion).getReleaseName();
long timestamp = resultCollection.getAppVersionFromSequenceNumber(trimToVersion).getTimestamp();
resultCollection.setReleaseName(name);
resultCollection.setTimestamp(timestamp);
resultCollection.trimAppVersions(trimToVersion);
}
}
if (commandLine.maxAgeSpecified || commandLine.notAProblemSpecified || commandLine.shouldFixSpecified) {
Cloud cloud = origCollection.getCloud();
SigninState signinState = cloud.getSigninState();
if (!signinState.canDownload()) {
disconnect(verbose, commandLine, resultCollection, cloud.getCloudName() + " state is " + signinState
+ "; ignoring filtering options that require cloud access");
} else if (!cloud.waitUntilIssueDataDownloaded(20, TimeUnit.SECONDS)) {
if (verbose) {
System.out.println("Waiting for cloud information required for filtering");
}
if (!cloud.waitUntilIssueDataDownloaded(60, TimeUnit.SECONDS)) {
disconnect(verbose, commandLine, resultCollection,
"Unable to connect to cloud; ignoring filtering options that require cloud access");
}
}
}
commandLine.getReady(origCollection);
for (BugInstance bug : origCollection.getCollection()) {
if (commandLine.accept(origCollection, bug)) {
if (trimToVersion >= 0) {
if (bug.getFirstVersion() > trimToVersion) {
dropped++;
continue;
} else if (bug.getLastVersion() >= trimToVersion) {
bug.setLastVersion(-1);
bug.setRemovedByChangeOfPersistingClass(false);
}
}
resultCollection.add(bug, false);
passed++;
} else {
dropped++;
}
}
if (commandLine.purgeHistorySpecified && commandLine.purgeHistory) {
resultCollection.clearAppVersions();
for (BugInstance bug : resultCollection.getCollection()) {
bug.clearHistory();
}
}
if (verbose) {
System.out.println(passed + " warnings passed through, " + dropped + " warnings dropped");
}
if (commandLine.withSourceSpecified && commandLine.withSource && !commandLine.dontUpdateStats
&& projectStats.hasClassStats()) {
for (PackageStats stats : projectStats.getPackageStats()) {
Iterator<ClassStats> i = stats.getClassStats().iterator();
while (i.hasNext()) {
String className = i.next().getName();
if (sourceSearcher.sourceNotFound.contains(className) || !sourceSearcher.sourceFound.contains(className)
&& !sourceSearcher.findSource(SourceLineAnnotation.createReallyUnknown(className))) {
i.remove();
}
}
}
}
projectStats.recomputeFromComponents();
if (argCount == args.length) {
assert !verbose;
resultCollection.writeXML(System.out);
} else {
resultCollection.writeXML(args[argCount++]);