Search in sources :

Example 1 with Report

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);
        }
    }
}
Also used : Report(net.sourceforge.pmd.Report) TextReport(net.sourceforge.pmd.benchmark.TextReport)

Example 2 with Report

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());
    }
}
Also used : Report(net.sourceforge.pmd.Report) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) SourceCodeProcessor(net.sourceforge.pmd.SourceCodeProcessor) IOException(java.io.IOException) PMDException(net.sourceforge.pmd.PMDException) IOException(java.io.IOException) DataSource(net.sourceforge.pmd.util.datasource.DataSource) BufferedInputStream(java.io.BufferedInputStream) RuleSets(net.sourceforge.pmd.RuleSets) Renderer(net.sourceforge.pmd.renderers.Renderer) PMDException(net.sourceforge.pmd.PMDException)

Aggregations

Report (net.sourceforge.pmd.Report)2 BufferedInputStream (java.io.BufferedInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PMDException (net.sourceforge.pmd.PMDException)1 RuleSets (net.sourceforge.pmd.RuleSets)1 SourceCodeProcessor (net.sourceforge.pmd.SourceCodeProcessor)1 TextReport (net.sourceforge.pmd.benchmark.TextReport)1 Renderer (net.sourceforge.pmd.renderers.Renderer)1 DataSource (net.sourceforge.pmd.util.datasource.DataSource)1