use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.
the class StyleCopParserTest method testViolationCompareTo.
/**
* Test to catch a NPE in Violation.compareTo() because violation has to little data
*/
@Test
public void testViolationCompareTo() throws Exception {
FullBuildModel model = getFullBuildModel("onefile.xml");
Iterator<Violation> iterator = model.getFileModel("MainClass.cs").getTypeMap().get(StyleCopParser.TYPE_NAME).descendingIterator();
Violation v = iterator.next();
Violation otherV = iterator.next();
assertTrue("compareTo() should return false", v.compareTo(otherV) != 0);
}
use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.
the class OutputFileModel method createLimited.
private void createLimited() throws IOException {
for (Map.Entry<String, TreeSet<Violation>> e : fileModel.getTypeMap().entrySet()) {
String type = e.getKey();
Set<Violation> violations = e.getValue();
LimitedType limitedType = new LimitedType();
limitedType.number = violations.size();
int c = 0;
for (Violation v : violations) {
limitedType.violations.add(v);
addToVMap(v);
doViolation(v);
c++;
if (c >= config.getLimit()) {
break;
}
}
limitedMap.put(type, limitedType);
}
}
use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.
the class FindBugsParser method getBugInstance.
private void getBugInstance() throws IOException, XmlPullParserException {
String type = getParser().getAttributeValue("", "type");
String priority = getParser().getAttributeValue("", "priority");
getParser().next();
classname = null;
path = null;
lineNumber = null;
while (true) {
String tag = getSibTag();
if (tag == null) {
break;
}
if (("Class".equals(tag) || "Method".equals(tag) || "Field".equals(tag)) && sameClassname(classname)) {
if (StringUtil.isBlank(classname)) {
classname = getParser().getAttributeValue("", "classname");
}
getParser().next();
getSourceLines();
endElement();
continue;
} else if ("SourceLine".equals(tag)) {
getSourceLine();
}
skipTag();
}
String name = path == null ? resolveClassName(classname) : path;
if (StringUtil.isBlank(name)) {
LOG.info("Unable to decode BugInstance element");
endElement();
return;
}
File file = absoluteFileFinder.getFileForName(name);
name = getRelativeName(name, file);
Violation v = new Violation();
v.setType("findbugs");
v.setLine(lineNumber);
v.setSource(type);
v.setSeverity(normalizeSeverity(priority));
v.setSeverityLevel(getSeverityLevel(v.getSeverity()));
v.setMessage(convertType(type));
getFileModel(name, file).addViolation(v);
endElement();
}
use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.
the class FindBugsParser method getMavenFileInstance.
private void getMavenFileInstance() throws IOException, XmlPullParserException {
// FIXME: I have no definition - just an example file
// with no source files
String classname = checkNotBlank("classname");
String name = resolveClassName(classname);
File file = absoluteFileFinder.getFileForName(name);
name = getRelativeName(name, file);
getParser().next();
while (true) {
String tag = getSibTag();
if (tag == null) {
break;
}
if (tag.equals("BugInstance")) {
Violation v = new Violation();
v.setType("findbugs");
v.setLine(getInt("lineNumber"));
v.setSource(checkNotBlank("type"));
v.setSeverity(normalizeSeverity(checkNotBlank("priority")));
v.setSeverityLevel(getSeverityLevel(v.getSeverity()));
v.setMessage(checkNotBlank("message"));
getFileModel(name, file).addViolation(v);
}
skipTag();
}
endElement();
}
use of hudson.plugins.violations.model.Violation in project violations-plugin by jenkinsci.
the class JcReportParser method parseItemElement.
private Violation parseItemElement() throws IOException, XmlPullParserException {
final String severity = SEVERITIES.get(getString("severity"));
Violation ret = null;
if (severity != null) {
ret = new Violation();
ret.setType("jcreport");
// ret.setType(getString("origin")); // report the real source?
ret.setLine(getString("line"));
ret.setMessage(getString("message"));
ret.setSource(getString("finding-type"));
ret.setSeverity(severity);
ret.setSeverityLevel(Severity.getSeverityLevel(severity));
}
return ret;
}
Aggregations