forked from phoedos/pmd
misc cleanup
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@7343 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -48,22 +48,22 @@ public class SummaryHTMLRenderer extends AbstractAccumulatingRenderer {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void renderSummary() throws IOException {
|
||||
StringBuffer buf = new StringBuffer(500);
|
||||
buf.append("<h2><center>Summary</h2></center>");
|
||||
buf.append("<table align=\"center\" cellspacing=\"0\" cellpadding=\"3\">");
|
||||
buf.append("<th>Rule name</th>");
|
||||
buf.append("<th>Number of violations</th>");
|
||||
writer.write(buf.toString());
|
||||
Map<String, Integer> summary = report.getSummary();
|
||||
for (Map.Entry<String, Integer> entry : summary.entrySet()) {
|
||||
String ruleName = entry.getKey();
|
||||
buf.setLength(0);
|
||||
buf.append("<tr>");
|
||||
buf.append("<td>" + ruleName + "</td>");
|
||||
buf.append("<td align=center>" + entry.getValue().intValue() + "</td>");
|
||||
buf.append("</tr>");
|
||||
writer.write(buf.toString());
|
||||
}
|
||||
writer.write("</table>");
|
||||
StringBuilder buf = new StringBuilder(500);
|
||||
buf.append("<h2><center>Summary</h2></center>");
|
||||
buf.append("<table align=\"center\" cellspacing=\"0\" cellpadding=\"3\">");
|
||||
buf.append("<th>Rule name</th>");
|
||||
buf.append("<th>Number of violations</th>");
|
||||
writer.write(buf.toString());
|
||||
Map<String, Integer> summary = report.getSummary();
|
||||
for (Map.Entry<String, Integer> entry : summary.entrySet()) {
|
||||
String ruleName = entry.getKey();
|
||||
buf.setLength(0);
|
||||
buf.append("<tr>");
|
||||
buf.append("<td>" + ruleName + "</td>");
|
||||
buf.append("<td align=center>" + entry.getValue().intValue() + "</td>");
|
||||
buf.append("</tr>");
|
||||
writer.write(buf.toString());
|
||||
}
|
||||
writer.write("</table>");
|
||||
}
|
||||
}
|
||||
|
@ -147,12 +147,13 @@ public class Benchmark {
|
||||
p.getConfiguration().setDefaultLanguageVersion(languageVersion);
|
||||
RuleContext ctx = new RuleContext();
|
||||
long start = System.currentTimeMillis();
|
||||
Reader reader = null;
|
||||
for (DataSource dataSource: dataSources) {
|
||||
Reader reader = new InputStreamReader(dataSource.getInputStream());
|
||||
ctx.setSourceCodeFilename(dataSource.getNiceFileName(false, null));
|
||||
p.processFile(reader, ruleSets, ctx);
|
||||
reader.close();
|
||||
}
|
||||
reader = new InputStreamReader(dataSource.getInputStream());
|
||||
ctx.setSourceCodeFilename(dataSource.getNiceFileName(false, null));
|
||||
p.processFile(reader, ruleSets, ctx);
|
||||
IOUtil.closeQuietly(reader);
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
long elapsed = end - start;
|
||||
results.add(new Result(elapsed, rule));
|
||||
|
@ -65,15 +65,8 @@ public class ClasspathClassLoader extends URLClassLoader {
|
||||
urls.add(createURLFromPath(line));
|
||||
}
|
||||
}
|
||||
in.close();
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
LOG.log(Level.SEVERE, "IOException while closing InputStream", e);
|
||||
}
|
||||
}
|
||||
IOUtil.closeQuietly(in);
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,17 +80,9 @@ public class ClasspathClassLoader extends URLClassLoader {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
StringBuilder sb = new StringBuilder(getClass().getSimpleName());
|
||||
sb.append("[[");
|
||||
boolean first = true;
|
||||
for (URL url : getURLs()) {
|
||||
if (!first) {
|
||||
sb.append(':');
|
||||
}
|
||||
first = false;
|
||||
sb.append(url);
|
||||
}
|
||||
StringUtil.asStringOn(sb, getURLs(), ":");
|
||||
sb.append("] parent: ");
|
||||
sb.append(getParent());
|
||||
sb.append(']');
|
||||
|
@ -304,6 +304,27 @@ public final class StringUtil {
|
||||
sb.append(iter.next());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the array items onto the string builder each delimited by the separator.
|
||||
* Does nothing if the array is null or empty.
|
||||
*
|
||||
* @param sb StringBuilder
|
||||
* @param items Object[]
|
||||
* @param separator String
|
||||
*/
|
||||
public static void asStringOn(StringBuilder sb, Object[] items, String separator) {
|
||||
|
||||
if (items == null | items.length == 0) { return; }
|
||||
|
||||
sb.append(items[0]);
|
||||
|
||||
for (int i=1; i<items.length; i++) {
|
||||
sb.append(separator);
|
||||
sb.append(items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the length of the shortest string in the array.
|
||||
* If the collection is empty or any one of them is
|
||||
|
Reference in New Issue
Block a user