Clover coverage report - PMD - 3.9 Coverage timestamp: Tue Dec 19 2006 09:38:44 EST FRAMES NO FRAMES |
file stats: | LOC: | 66 |  | Methods: | 2
| NCLOC: | 52 |  | Classes: | 1
Source file | Conditionals | Statements | Methods | TOTAL
TextRenderer.java | 64.3% | 81.8% | 100% | 77.6% |

1 |  | /**
2 |  | * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 |  | */
4 |  | package net.sourceforge.pmd.renderers;
5 |  |
6 |  | import net.sourceforge.pmd.IRuleViolation;
7 |  | import net.sourceforge.pmd.PMD;
8 |  | import net.sourceforge.pmd.Report;
9 |  |
10 |  | import java.io.IOException;
11 |  | import java.io.Writer;
12 |  | import java.util.Iterator;
13 |  |
14 |  | public class TextRenderer extends AbstractRenderer {
15 |  |
16 | 5 | public void render(Writer writer, Report report) throws IOException {
17 | 5 | StringBuffer buf = new StringBuffer();
18 |  |
19 | 5 | if (report.isEmpty()) {
20 | 1 | buf.append("No problems found!");
21 | 1 | if (showSuppressedViolations) {
22 | 1 | addSuppressed(report, buf);
23 |  | }
24 | 1 | writer.write(buf.toString());
25 | 1 | return;
26 |  | }
27 | 3 | Iterator i;
28 |  |
29 | 3 | for (i = report.iterator(); i.hasNext();) {
30 | 3 | buf.setLength(0);
31 | 3 | IRuleViolation rv = (IRuleViolation) i.next();
32 | 3 | buf.append(PMD.EOL).append(rv.getFilename());
33 | 3 | buf.append(':').append(Integer.toString(rv.getBeginLine()));
34 | 3 | buf.append('\t').append(rv.getDescription());
35 | 3 | writer.write(buf.toString());
36 |  | }
37 |  |
38 | 3 | for (i = report.errors(); i.hasNext();) {
39 | 1 | buf.setLength(0);
40 | 1 | Report.ProcessingError error = (Report.ProcessingError) i.next();
41 | 1 | buf.append(PMD.EOL).append(error.getFile());
42 | 1 | buf.append("\t-\t").append(error.getMsg());
43 | 1 | writer.write(buf.toString());
44 |  | }
45 |  |
46 | 3 | if (showSuppressedViolations) {
47 | 3 | buf.setLength(0);
48 | 3 | addSuppressed(report, buf);
49 | 3 | writer.write(buf.toString());
50 |  | }
51 |  | }
52 |  |
53 | 4 | private void addSuppressed(Report report, StringBuffer buf) {
54 |  |
55 | 4 | Report.SuppressedViolation excluded;
56 |  |
57 | 4 | for (Iterator i = report.getSuppressedRuleViolations().iterator(); i.hasNext();) {
58 | 0 | excluded = (Report.SuppressedViolation) i.next();
59 | 0 | buf.append(PMD.EOL);
60 | 0 | buf.append(excluded.getRuleViolation().getRule().getName());
61 | 0 | buf.append(" rule violation suppressed by ");
62 | 0 | buf.append(excluded.suppressedByNOPMD() ? "//NOPMD" : "Annotation");
63 | 0 | buf.append(" in ").append(excluded.getRuleViolation().getFilename());
64 |  | }
65 |  | }
66 |  | }