Source:
public static int doPMD(PMDConfiguration configuration) { RuleSetFactory ruleSetFactory = RulesetsFactoryUtils.getRulesetFactory(configuration, new ResourceLoader()); RuleSets ruleSets = RulesetsFactoryUtils.getRuleSetsWithBenchmark(configuration.getRuleSets(), ruleSetFactory); if (ruleSets == null) { return 0; } if (!configuration.isIgnoreIncrementalAnalysis() && LOG.isLoggable(Level.WARNING)) { final String version = PMDVersion.isUnknown() || PMDVersion.isSnapshot() ? "latest" : "pmd-" + PMDVersion.VERSION; LOG.warning("This analysis could be faster, please consider using Incremental Analysis: " + "<LINK_0>" + version + "/pmd_userdocs_getting_started.html#incremental-analysis"); } Set<Language> languages = getApplicableLanguages(configuration, ruleSets); List<DataSource> files = getApplicableFiles(configuration, languages); long reportStart = System.nanoTime(); try { Renderer renderer = configuration.createRenderer(); List<Renderer> renderers = Collections.singletonList(renderer); renderer.setWriter(IOUtil.createWriter(configuration.getReportFile())); renderer.start(); Benchmarker.mark(Benchmark.Reporting, System.nanoTime() - reportStart, 0); RuleContext ctx = new RuleContext(); final AtomicInteger violations = new AtomicInteger(0); ctx.getReport().addListener(new ThreadSafeReportListener() { @Override public void ruleViolationAdded(RuleViolation ruleViolation) { violations.incrementAndGet(); } @Override public void metricAdded(Metric metric) { } }); processFiles(configuration, ruleSetFactory, files, ctx, renderers); reportStart = System.nanoTime(); renderer.end(); renderer.flush(); return violations.get(); } catch (Exception e) { String message = e.getMessage(); if (message != null) { LOG.severe(message); } else { LOG.log(Level.SEVERE, "Exception during processing", e); } LOG.log(Level.FINE, "Exception during processing", e); LOG.info(PMDCommandLineInterface.buildUsageText()); return 0; } finally { Benchmarker.mark(Benchmark.Reporting, System.nanoTime() - reportStart, 0); if (configuration.getClassLoader() instanceof ClasspathClassLoader) { IOUtil.tryCloseClassLoader(configuration.getClassLoader()); } } }

Target:
public static int doPMD(PMDConfiguration configuration) { RuleSetFactory ruleSetFactory = RulesetsFactoryUtils.getRulesetFactory(configuration, new ResourceLoader()); RuleSets ruleSets = RulesetsFactoryUtils.getRuleSetsWithBenchmark(configuration.getRuleSets(), ruleSetFactory); if (ruleSets == null) { return 0; } Set<Language> languages = getApplicableLanguages(configuration, ruleSets); List<DataSource> files = getApplicableFiles(configuration, languages); long reportStart = System.nanoTime(); try { Renderer renderer = configuration.createRenderer(); List<Renderer> renderers = Collections.singletonList(renderer); renderer.setWriter(IOUtil.createWriter(configuration.getReportFile())); renderer.start(); Benchmarker.mark(Benchmark.Reporting, System.nanoTime() - reportStart, 0); RuleContext ctx = new RuleContext(); final AtomicInteger violations = new AtomicInteger(0); ctx.getReport().addListener(new ThreadSafeReportListener() { @Override public void ruleViolationAdded(RuleViolation ruleViolation) { violations.incrementAndGet(); } @Override public void metricAdded(Metric metric) { } }); processFiles(configuration, ruleSetFactory, files, ctx, renderers); reportStart = System.nanoTime(); renderer.end(); renderer.flush(); return violations.get(); } catch (Exception e) { String message = e.getMessage(); if (message != null) { LOG.severe(message); } else { LOG.log(Level.SEVERE, "Exception during processing", e); } LOG.log(Level.FINE, "Exception during processing", e); LOG.info(PMDCommandLineInterface.buildUsageText()); return 0; } finally { Benchmarker.mark(Benchmark.Reporting, System.nanoTime() - reportStart, 0); if (configuration.getClassLoader() instanceof ClasspathClassLoader) { IOUtil.tryCloseClassLoader(configuration.getClassLoader()); } } }