Class Report

java.lang.Object
net.sourceforge.pmd.reporting.Report

public final class Report extends Object
A Report collects all information during a PMD execution. This includes violations, suppressed violations, metrics, recoverable errors (that occurred during processing) and configuration errors.

A report may be created by a Report.GlobalReportBuilderListener that you use as the GlobalAnalysisListener in PMD's entry point. You can also create one manually with buildReport(Consumer).

For special use cases, like filtering the report after PMD analysis and before rendering the report, some transformation operations are provided:

These methods create a new Report rather than modifying their receiver.
  • Method Details

    • getSuppressedViolations

      public List<Report.SuppressedViolation> getSuppressedViolations()
      Returns an unmodifiable list of violations that were suppressed.
    • getViolations

      public List<RuleViolation> getViolations()
      Returns an unmodifiable list of violations that have been recorded until now. None of those violations were suppressed.

      The violations list is sorted with RuleViolation.DEFAULT_COMPARATOR.

    • getProcessingErrors

      public List<Report.ProcessingError> getProcessingErrors()
      Returns an unmodifiable list of processing errors that have been recorded until now.
    • getConfigurationErrors

      public List<Report.ConfigurationError> getConfigurationErrors()
      Returns an unmodifiable list of configuration errors that have been recorded until now.
    • buildReport

      public static Report buildReport(Consumer<? super FileAnalysisListener> lambda)
      Create a report by making side effects on a FileAnalysisListener. This wraps a Report.ReportBuilderListener.
    • filterViolations

      public Report filterViolations(Predicate<RuleViolation> filter)
      Creates a new report taking all the information from this report, but filtering the violations.
      Parameters:
      filter - when true, the violation will be kept.
      Returns:
      copy of this report
    • union

      public Report union(Report other)
      Creates a new report by combining this report with another report. The lowest start time and greatest end time are kept in the copy.
      Parameters:
      other - the other report to combine
      Returns:
      a new report which is the combination of this and the other report.