Search in sources :

Example 1 with Violation

use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.

the class FileModelParser method parseViolationElement.

private void parseViolationElement() throws IOException, XmlPullParserException {
    Violation ret = new Violation();
    ret.setLine(checkGetInt("line"));
    ret.setSource(checkGetAttribute("source"));
    ret.setSeverity(checkGetAttribute("severity"));
    ret.setSeverityLevel(getInt("severity-level"));
    ret.setType(checkGetAttribute("type"));
    ret.setMessage(checkGetAttribute("message"));
    String popup = getParser().getAttributeValue("", "popup-message");
    if (popup != null && !popup.equals("")) {
        ret.setPopupMessage(popup);
    }
    fileModel.addViolation(ret);
    getParser().next();
    endElement();
}
Also used : Violation(hudson.plugins.violations.model.Violation)

Example 2 with Violation

use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.

the class GendarmeParserTest method assertThatCriticalIssuesAreMarkedAsHigh.

@Issue("JENKINS-11227")
@Test
public void assertThatCriticalIssuesAreMarkedAsHigh() throws IOException {
    FullBuildModel model = getFullBuildModel("gendarme-2" + (File.separatorChar == '/' ? "_unix" : "") + ".xml");
    SortedSet<Violation> set = model.getFileModel(getOsDependentFilename("workspaceLeave\\Leave.Gui\\Views\\LeaveGanttView\\Column\\LeaveFooter.cs")).getTypeMap().get(GendarmeParser.TYPE_NAME);
    assertEquals("The severity is incorrect", Severity.HIGH, set.first().getSeverity());
}
Also used : Violation(hudson.plugins.violations.model.Violation) FullBuildModel(hudson.plugins.violations.model.FullBuildModel) Issue(org.jvnet.hudson.test.Issue) ViolationsParserTest(hudson.plugins.violations.ViolationsParserTest) Test(org.junit.Test)

Example 3 with Violation

use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.

the class FileModelProxy method showIcon.

private void showIcon(StringBuilder b, Set<Violation> violations) {
    // Get the worst icon in the set
    int level = Severity.LOW_VALUE;
    for (Violation v : violations) {
        if (v.getSeverityLevel() < level) {
            level = v.getSeverityLevel();
        }
    }
    b.append("<td class='source icon'>");
    addVDiv(b);
    b.append("<a class='healthReport'>");
    b.append("<img src='" + contextPath + getSeverityIcon(level) + "'/>");
    b.append("</a>");
    showDiv(b, violations);
    b.append("</div>");
    b.append("</td>");
}
Also used : Violation(hudson.plugins.violations.model.Violation)

Example 4 with Violation

use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.

the class FileModelProxy method showDiv.

private void showDiv(StringBuilder b, Set<Violation> violations) {
    b.append("<div class='healthReportDetails'>\n");
    b.append(" <table class='violationPopup'>\n");
    b.append("  <thead>\n");
    b.append("   <tr>\n");
    b.append("     <th> Type</th>\n");
    b.append("     <th> Class</th>\n");
    b.append("     <th> Description</th>\n");
    b.append("   </tr>\n");
    b.append("  </thead>\n");
    b.append("  <tbody>\n");
    for (Violation v : violations) {
        b.append("   <tr>\n");
        b.append("     <td>");
        b.append(v.getType());
        b.append("</td>\n");
        b.append("     <td>");
        b.append(v.getSource());
        b.append("</td>\n");
        b.append("     <td width='100%' class='message'>");
        b.append(XMLUtil.escapeContent(v.getPopupMessage()));
        b.append("</td>\n");
        b.append("   </tr>\n");
    }
    b.append("  </tbody>\n");
    b.append(" </table>\n");
    b.append("</div>\n");
}
Also used : Violation(hudson.plugins.violations.model.Violation)

Example 5 with Violation

use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.

the class PMDParser method parseViolationElement.

private Violation parseViolationElement() throws IOException, XmlPullParserException {
    Violation ret = new Violation();
    ret.setType("pmd");
    String line = getParser().getAttributeValue("", "beginline");
    if (line == null) {
        // in pmd version 3.9 and lower the attribute is "line"
        line = getParser().getAttributeValue("", "line");
    }
    ret.setLine(line);
    ret.setSource(getParser().getAttributeValue("", "rule"));
    setSeverity(ret, getParser().getAttributeValue("", "priority"));
    ret.setMessage(getNextText("Expecting text"));
    getParser().next();
    // violation element
    endElement();
    return ret;
}
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