com.cflint.BugList Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of CFLint Show documentation
Show all versions of CFLint Show documentation
A static code analysis tool for ColdFusion (in the spirit of FindBugs and Lint). With CFLint, you are able to analyze your ColdFusion code base for code violations.
package com.cflint;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.cflint.tools.CFLintFilter;
public class BugList implements Iterable {
Map> bugList = new HashMap>();
/**
*
*/
@SuppressWarnings("unused")
private static final long serialVersionUID = -8008927848087276202L;
public BugList(final CFLintFilter filter) {
super();
this.filter = filter;
}
CFLintFilter filter;
CFLintFilter fileFilter;
public CFLintFilter getFileFilter() {
return fileFilter;
}
public CFLintFilter getFilter() {
return filter;
}
public void setFilter(final CFLintFilter filter) {
this.filter = filter;
this.fileFilter = filter.createFilePreFilter();
}
public boolean add(final BugInfo bugInfo) {
if (filter == null || filter.include(bugInfo)) {
if (!bugList.containsKey(bugInfo.getMessageCode())) {
bugList.put(bugInfo.getMessageCode(), new ArrayList());
}
final List curBugList = bugList.get(bugInfo.getMessageCode());
return curBugList.add(bugInfo);
} else {
return false;
}
}
/**
* Returns a list of bugs as a map.
*
* @return Map of bugs
*/
public Map> getBugList() {
return bugList;
}
public int size() {
int size = 0;
for (final List> list : bugList.values()) {
size += list.size();
}
return size;
}
public List getFlatBugList() {
final List retval = new ArrayList();
for (final List list : bugList.values()) {
retval.addAll(list);
}
return retval;
}
@Override
public Iterator iterator() {
return getFlatBugList().iterator();
}
}