use of net.sourceforge.pmd.Report in project maven-plugins by apache.
the class PmdReport method execute.
private void execute(Locale locale) throws MavenReportException {
if (!skip && canGenerateReport()) {
ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
Report report = generateReport(locale);
if (!isHtml() && !isXml()) {
writeNonHtml(report);
}
} finally {
Thread.currentThread().setContextClassLoader(origLoader);
}
}
}
use of net.sourceforge.pmd.Report in project Gargoyle by callakrsos.
the class PMDGargoyleThreadProcessor method processFiles.
public void processFiles(RuleSetFactory ruleSetFactory, List<DataSource> files, RuleContext ctx, List<Renderer> renderers) {
// single threaded execution
RuleSets rs = createRuleSets(ruleSetFactory);
SourceCodeProcessor processor = new SourceCodeProcessor(configuration);
for (DataSource dataSource : files) {
String niceFileName = filenameFrom(dataSource);
Report report = PMD.setupReport(rs, ctx, niceFileName);
// overtake the listener
//bug fix 2016-10-05 by kyj. 결과가 중복되서 출력됨.
// report.addSynchronizedListeners(ctx.getReport().getSynchronizedListeners());
// ctx.setReport(report);
// ctx.setSourceCodeFilename(niceFileName);
// if (LOG.isLoggable(Level.FINE)) {
// LOG.fine("Processing " + ctx.getSourceCodeFilename());
// }
rs.start(ctx);
for (Renderer r : renderers) {
r.startFileAnalysis(dataSource);
}
try {
InputStream stream = new BufferedInputStream(dataSource.getInputStream());
// ctx.setLanguageVersion(null);
processor.processSourceCode(stream, rs, ctx);
} catch (PMDException pmde) {
// LOGGER.error(ValueUtil.toString(pmde));
// if (LOG.isLoggable(Level.FINE)) {
// LOG.log(Level.FINE, "Error while processing file: " + niceFileName, pmde.getCause());
// }
report.addError(new Report.ProcessingError(pmde.getMessage(), niceFileName));
} catch (IOException ioe) {
// LOGGER.error(ValueUtil.toString(ioe));
// unexpected exception: log and stop executor service
addError(report, "Unable to read source file", ioe, niceFileName);
} catch (RuntimeException re) {
// LOGGER.error(ValueUtil.toString(re));
// unexpected exception: log and stop executor service
addError(report, "RuntimeException while processing file", re, niceFileName);
} catch (Exception e) {
LOGGER.error(ValueUtil.toString(e));
}
rs.end(ctx);
super.renderReports(renderers, ctx.getReport());
}
}
Aggregations