Tuesday, November 24, 2020

Create Sonar Plugin - Scanner Basic - Read the XML violation report

 XML violation report will be created inside working folder.

find  the report and convert to POJO

For this we need to have a separate logic to convert using something like Jackson. Basic structure of the method would be like this.

Converter class has the XML to JAVA mapping conversion.

------------------------------------------------------------------------------------------------------------------------


private Violations getReport() {
Violations report = new Violations();
try {
String workDirRoot = fileSystem.workDir().getCanonicalPath();
String reportPath = workDirRoot + File.separator + VIOLATION_REPORT_NAME;
report = Converter.convertXMLToJava(reportPath);
} catch (Exception ex) {
LOG.error(ex.getLocalizedMessage(), ex);
}
return report;
}


No comments:

Post a Comment