use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.
the class StyleCopParserTest method testParseViolationData.
@Test
public void testParseViolationData() throws Exception {
FullBuildModel model = getFullBuildModel("onefile.xml");
Iterator<Violation> iterator = model.getFileModel("MainClass.cs").getTypeMap().get(StyleCopParser.TYPE_NAME).descendingIterator();
Violation v = iterator.next();
assertEquals("Line in violation is incorrect", 10, v.getLine());
assertEquals("Source in violation is incorrect", "DocumentationRules", v.getSource());
assertEquals("Message in violation is incorrect", "The property must have a documentation header. (SA1600)", v.getMessage());
assertEquals("Severity level in violation is incorrect", 2, v.getSeverityLevel());
assertEquals("Severity in violation is incorrect", "Medium", v.getSeverity());
}
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();
}
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());
}
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>");
}
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");
}
Aggregations