Search in sources :

Example 26 with Violation

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;
}
Also used : Violation(hudson.plugins.violations.model.Violation)

Example 27 with 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;
}
Also used : Violation(hudson.plugins.violations.model.Violation) Set(java.util.Set)

Example 28 with Violation

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();
}
Also used : Violation(hudson.plugins.violations.model.Violation) TreeSet(java.util.TreeSet)

Example 29 with Violation

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);
}
Also used : Violation(hudson.plugins.violations.model.Violation)

Example 30 with Violation

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();
}
Also used : Violation(hudson.plugins.violations.model.Violation)

Aggregations

Violation (hudson.plugins.violations.model.Violation)41 FullFileModel (hudson.plugins.violations.model.FullFileModel)12 ViolationsParserTest (hudson.plugins.violations.ViolationsParserTest)8 FullBuildModel (hudson.plugins.violations.model.FullBuildModel)8 Test (org.junit.Test)8 File (java.io.File)6 Map (java.util.Map)3 Element (org.w3c.dom.Element)3 HashMap (java.util.HashMap)2 TreeSet (java.util.TreeSet)2 FilePath (hudson.FilePath)1 AbsoluteFileFinder (hudson.plugins.violations.util.AbsoluteFileFinder)1 IOException2 (hudson.util.IOException2)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 Matcher (java.util.regex.Matcher)1