use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.
the class JsLintParser method parseIssueElement.
private Violation parseIssueElement() throws IOException, XmlPullParserException {
Violation violation = new Violation();
violation.setType(TYPE_NAME);
violation.setLine(getString("line"));
violation.setMessage(getString("reason"));
violation.setSource(getString("evidence"));
setSeverity(violation, getString("severity"));
getParser().next();
endElement();
return violation;
}
use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.
the class ReportedFileAsserter method getViolations.
private List<Violation> getViolations() {
List<Violation> violations = newArrayList();
Map<Integer, Set<Violation>> lineMap = getOrFail().getFileModel().getLineViolationMap();
for (Integer line : lineMap.keySet()) {
for (Violation violation : lineMap.get(line)) {
violations.add(violation);
}
}
return violations;
}
use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.
the class FileModelProxy method getViolationsSummary.
public String getViolationsSummary() {
StringBuilder ret = new StringBuilder();
for (Entry<String, TreeSet<Violation>> t : this.fileModel.get().getTypeMap().entrySet()) {
ret.append("<table class=\"pane\">");
ret.append("<tbody>");
ret.append("<tr><td class=\"pane-header\" colspan=\"5\">");
ret.append(this.typeLine(t.getKey()));
ret.append("</td></tr>");
for (Violation v : t.getValue()) {
ret.append("<tr>");
if (v.getSource().toUpperCase().contains("Security".toUpperCase())) {
ret.append("<td class=\"pane\">");
ret.append("<img src=\"/plugin/violations/images/16x16/security.png\" alt=\"Security violation\">");
ret.append("</td>");
} else {
ret.append("<td class=\"pane\" />");
}
ret.append("<td class=\"pane\">");
ret.append(getVisualStudioLink(v));
ret.append("</td>");
ret.append("<td class=\"pane\">");
if (this.getShowLines()) {
ret.append("<a href=\"#line");
ret.append(v.getLine());
ret.append("\">");
ret.append(v.getLine());
ret.append("</a>");
} else {
ret.append(v.getLine());
}
ret.append("</td>");
ret.append("<td class=\"pane\">");
ret.append(this.severityColumn(v));
ret.append("</td>");
ret.append("<td class=\"pane\" width=\"99%\">");
ret.append(v.getMessage());
ret.append("</td>");
ret.append("</tr>");
}
ret.append("</table>");
ret.append("<p></p>");
}
return ret.toString();
}
use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.
the class CPDParser method addViolation.
private void addViolation(int lines, int tokens, FileElement self, FileElement other) {
Violation v = new Violation();
v.setType("cpd");
v.setLine(self.line);
setSeverity(v, (tokens < LOW_LIMIT) ? Severity.LOW : (tokens < MEDIUM_LIMIT) ? Severity.MEDIUM : Severity.HIGH);
v.setSource("duplication");
v.setMessage("Duplication of " + tokens + " tokens from " + relativeHRef(self, other));
v.setPopupMessage("Duplication of " + tokens + " tokens from " + relativeOther(self, other));
getFileModel(self.path).addViolation(v);
}
use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.
the class FileModelProxy method getSummaryTable.
public String getSummaryTable() {
StringBuilder gst = new StringBuilder();
int count = 0;
gst.append(" <table class='violations' width='100%'>\n");
gst.append(" <tr>\n");
gst.append(" <td class='violations-header'> # </td>\n");
gst.append(" <td class='violations-header'> Type </td>\n");
gst.append(" <td class='violations-header'> Class</td>\n");
gst.append(" <td class='violations-header'> Message</td>\n");
gst.append(" <td class='violations-header'> Description</td>\n");
gst.append(" </tr>\n");
Set<Violation> violations = fileModel.get().getLineViolationMap().get(0);
for (Violation v : violations) {
++count;
gst.append(" <tr>\n");
gst.append(" <td class='violations'>");
gst.append(count);
gst.append("</td>\n");
gst.append(" <td class='violations'>");
gst.append(v.getType());
gst.append("</td>\n");
gst.append(" <td class='violations'>");
gst.append(v.getSource());
gst.append("</td>\n");
gst.append(" <td class='violations'>");
gst.append(v.getMessage());
gst.append("</td>\n");
gst.append(" <td class='violations'>");
gst.append(v.getPopupMessage());
gst.append("</td>\n");
gst.append(" </tr>\n");
}
gst.append(" </table>\n");
gst.append("<p><br>\n");
gst.append("<h3>Total Number of violations: \n");
gst.append(count);
gst.append("</h3><p>\n");
return gst.toString();
}
Aggregations