Package net.sourceforge.pmd
Class Report
- java.lang.Object
-
- net.sourceforge.pmd.Report
-
public final class Report extends Object
AReport
collects all informations during a PMD execution. This includes violations, suppressed violations, metrics, error during processing and configuration errors.A report may be created by a
Report.GlobalReportBuilderListener
that you use as the GlobalAnalysisListener inPMD's entry point
. You can also create one manually withbuildReport(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 newReport
rather than modifying their receiver.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Report.ConfigurationError
Represents a configuration error.static class
Report.GlobalReportBuilderListener
AGlobalAnalysisListener
that accumulates the events of all files into aReport
.static class
Report.ProcessingError
Represents a processing error, such as a parse error.static class
Report.ReportBuilderListener
AFileAnalysisListener
that accumulates events into aReport
.static class
Report.SuppressedViolation
Represents a violation, that has been suppressed.
-
Constructor Summary
Constructors Constructor Description Report()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addConfigError(Report.ConfigurationError error)
Deprecated.PMD's way of creating a report is internal and may be changed in pmd 7.void
addError(Report.ProcessingError error)
Deprecated.PMD's way of creating a report is internal and may be changed in pmd 7.void
addRuleViolation(RuleViolation violation)
Deprecated.PMD's way of creating a report is internal and may be changed in pmd 7.static Report
buildReport(Consumer<? super FileAnalysisListener> lambda)
Create a report by making side effects on aFileAnalysisListener
.Report
filterViolations(Predicate<RuleViolation> filter)
Creates a new report taking all the information from this report, but filtering the violations.List<Report.ConfigurationError>
getConfigurationErrors()
Returns an unmodifiable list of configuration errors that have been recorded until now.List<Report.ProcessingError>
getProcessingErrors()
Returns an unmodifiable list of processing errors that have been recorded until now.List<Report.SuppressedViolation>
getSuppressedViolations()
Returns an unmodifiable list of violations that were suppressed.List<RuleViolation>
getViolations()
Returns an unmodifiable list of violations that have been recorded until now.void
merge(Report r)
Deprecated.Convert Renderer to use the reports.Report
union(Report other)
Creates a new report by combining this report with another report.
-
-
-
Constructor Detail
-
Report
@InternalApi public Report()
-
-
Method Detail
-
addRuleViolation
@Deprecated @InternalApi public void addRuleViolation(RuleViolation violation)
Deprecated.PMD's way of creating a report is internal and may be changed in pmd 7.Adds a new rule violation to the report and notify the listeners.- Parameters:
violation
- the violation to add
-
addConfigError
@Deprecated @InternalApi public void addConfigError(Report.ConfigurationError error)
Deprecated.PMD's way of creating a report is internal and may be changed in pmd 7.Adds a new configuration error to the report.- Parameters:
error
- the error to add
-
addError
@Deprecated @InternalApi public void addError(Report.ProcessingError error)
Deprecated.PMD's way of creating a report is internal and may be changed in pmd 7.Adds a new processing error to the report.- Parameters:
error
- the error to add
-
merge
@Deprecated public void merge(Report r)
Deprecated.Convert Renderer to use the reports.Merges the given report into this report. This might be necessary, if a summary over all violations is needed as PMD creates one report per file by default.This is synchronized on an internal lock (note that other mutation operations are not synchronized, todo for pmd 7).
- Parameters:
r
- the report to be merged into this.- See Also:
AbstractAccumulatingRenderer
-
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 aFileAnalysisListener
. This wraps aReport.ReportBuilderListener
.
-
filterViolations
@Experimental 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
@Experimental public Report union(Report other)
Creates a new report by combining this report with another report. This is similar tomerge(Report)
, but instead a new report is created. The lowest start time and greatest end time are kept in the copy.- Parameters:
other
- the other report to combine- Returns:
-
-