public void report(PrintWriter out) {
TreeMap<BugRankCategory, Stats> stats = new TreeMap<BugRankCategory, Stats>();
ProjectStats projectStats = bugCollection.getProjectStats();
Collection<BugInstance> bugs = bugCollection.getCollection();
Cloud cloud = bugCollection.getCloud();
cloud.setMode(Cloud.Mode.COMMUNAL);
out.printf("Cloud sync and summary report for %s%n", bugCollection.getProject().getProjectName());
out.printf("Code dated %s%n", new Date(bugCollection.getTimestamp()));
out.printf("Code analyzed %s%n", new Date(bugCollection.getAnalysisTimestamp()));
out.printf("%7d total classes%n", projectStats.getNumClasses());
out.printf("%7d total issues%n", bugs.size());
long recentTimestamp = System.currentTimeMillis() - options.ageInHours * 3600 * 1000L;
int allRecentIssues = 0;
for (BugInstance b : bugs) {
Stats s = stats.get(BugRankCategory.getRank(b.getBugRank()));
if (s == null) {
s = new Stats();
stats.put(BugRankCategory.getRank(b.getBugRank()), s);
}
s.total++;
long firstSeen = cloud.getFirstSeen(b);
if (firstSeen > recentTimestamp) {
s.recent++;
allRecentIssues++;
}
}
out.printf("%7d recent issues%n", allRecentIssues);
if (options.cloudSummary != null && cloud.supportsCloudSummaries()) {
try {
PrintWriter cs = UserTextFile.printWriter(options.cloudSummary);
cs.printf("%6s %6s %s%n", "recent", "total", "Rank category");
for (Entry<BugRankCategory, Stats> e : stats.entrySet()) {
Stats s = e.getValue();
if (s.total > 0) {
cs.printf("%6d %6d %s%n", s.recent, s.total, e.getKey());
}
}
cs.println();
cloud.printCloudSummary(cs, bugs, null);
cs.close();
} catch (Exception e) {
out.println("Error writing cloud summary to " + options.cloudSummary);
e.printStackTrace(out);
}