package edu.umd.cs.findbugs;


import java.util.*;

public class CountBugs {

	private static HashSet<String> categorySet = new HashSet<String>();
	private static TreeMap<String, Integer> countMap = new TreeMap<String, Integer>();

	public static void main(String[] argv) throws Exception {
		if (argv.length < 1) {
			System.err.println("Usage: " + CountBugs.class.getName() + " <results file>");
			System.exit(1);
		}

		DetectorFactoryCollection.instance(); // load plugins

		int arg = 0;
		if (argv[0].equals("-categories")) {
			StringTokenizer tok = new StringTokenizer(argv[1], ",");
			while (tok.hasMoreTokens())
				categorySet.add(tok.nextToken());
			arg = 2;
		}

		String filename = argv[arg];

		BugCollection bugCollection = new SortedBugCollection();
		bugCollection.readXML(filename, new Project());

		Iterator<BugInstance> i = bugCollection.iterator();
		while (i.hasNext()) {
			BugInstance bugInstance = i.next();
			String category = bugInstance.getAbbrev();

			if (categorySet.size() > 0 && !categorySet.contains(category))
				continue;

			Integer count = countMap.get(category);
			if (count == null)
				count = new Integer(0);
			countMap.put(category, new Integer(count.intValue() + 1));
		}

		Iterator<Map.Entry<String, Integer>> j = countMap.entrySet().iterator();
		while(j.hasNext()) {
			Map.Entry<String,Integer> entry = j.next();
			System.out.println(entry.getKey() + ": " + entry.getValue());
		}

	}
}

@@ -620,46 +620,129 @@
 s())
-%0A%09%09%09%09categorySet.add(tok.nextToken());
+ %7B%0A%09%09%09%09String category = tok.nextToken();%0A%09%09%09%09categorySet.add(category);%0A%09%09%09%09countMap.put(category, new Integer(0));%0A%09%09%09%7D
 %0A%09%09%09

Ensure counts are zero for all categories.