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;
}
use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.
the class ReSharperParser method parse.
public void parse(final FullBuildModel model, final File projectPath, final String fileName, final String[] sourcePaths) throws IOException {
absoluteFileFinder.addSourcePath(projectPath.getAbsolutePath());
absoluteFileFinder.addSourcePaths(sourcePaths);
final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder;
try {
docBuilder = docBuilderFactory.newDocumentBuilder();
final Document docElement = docBuilder.parse(new FileInputStream(new File(projectPath, fileName)));
NodeList nl = docElement.getElementsByTagName("IssueType");
if (nl == null)
return;
for (int i = 0; i < nl.getLength(); i++) {
final Element issueTypeElement = (Element) nl.item(i);
final IssueType issueType = parseIssueType(issueTypeElement);
issueTypes.put(issueType.getId(), issueType);
}
nl = docElement.getElementsByTagName("Issue");
if (nl == null)
return;
for (int i = 0; i < nl.getLength(); i++) {
final Element issueElement = (Element) nl.item(i);
final Issue issue = parseIssue(issueElement);
final IssueType issueType = issueTypes.get(issue.getTypeId());
if (// couldn't find the issue type, skip it
issueType == null)
continue;
final Violation violation = new Violation();
violation.setType("resharper");
violation.setMessage(issue.getMessage());
violation.setPopupMessage(issueType.getDescription() + " - " + issue.getMessage());
violation.setSource(issueType.getCategory());
violation.setLine(issue.getLine());
violation.setSeverity(SEVERITIES.get(issueType.getSeverity()));
violation.setSeverityLevel(Severity.getSeverityLevel(violation.getSeverity()));
final File file = absoluteFileFinder.getFileForName(issue.getFile());
final FullFileModel fullFileModel = getFileModel(model, issue.getFile().replace('\\', '/'), file);
fullFileModel.addViolation(violation);
}
} catch (final ParserConfigurationException pce) {
throw new IOException2(pce);
} catch (final SAXException se) {
throw new IOException2(se);
}
}
use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.
the class JcReportParser method parseFileElement.
private void parseFileElement() throws IOException, XmlPullParserException {
final String name = getString("name");
// consume "file" tag
getParser().next();
if (null != name && name.length() > 0) {
FullFileModel fileModel = null;
// Loop through the child elements, getting the "item" ones
while (skipToTag("item")) {
final Violation violation = parseItemElement();
if (null != violation) {
if (fileModel == null) {
fileModel = getFileModel(fixAbsolutePath(name));
}
fileModel.addViolation(parseItemElement());
}
getParser().next();
endElement();
}
}
endElement();
}
use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.
the class CheckstyleParser method parseErrorElement.
private Violation parseErrorElement() throws IOException, XmlPullParserException {
Violation ret = new Violation();
ret.setType("checkstyle");
ret.setLine(getString("line"));
ret.setMessage(getString("message"));
ret.setSource(getString("source"));
setSeverity(ret, getString("severity"));
getParser().next();
endElement();
return ret;
}
use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.
the class CssLintParser 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;
}
Aggregations