Package net.sourceforge.pmd
Class Report
- java.lang.Object
-
- net.sourceforge.pmd.Report
-
- All Implemented Interfaces:
Iterable<RuleViolation>
public class Report extends Object implements Iterable<RuleViolation>
AReportis the output of a PMD execution. This includes violations, suppressed violations, metrics, error during processing and configuration errors. PMD's entry point creates a report (seePmdAnalysis.performAnalysisAndCollectReport()) The mutation methods on this class are deprecated, as they will be internalized in PMD 7.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 newReportrather than modifying their receiver.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReport.ConfigurationErrorRepresents a configuration error.static classReport.ProcessingErrorRepresents a processing error, such as a parse error.static classReport.ReadableDurationDeprecated.Not used within PMD.static classReport.SuppressedViolationRepresents a violation, that has been suppressed.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddConfigError(Report.ConfigurationError error)Deprecated.PMD's way of creating a report is internal and may be changed in pmd 7.voidaddError(Report.ProcessingError error)Deprecated.PMD's way of creating a report is internal and may be changed in pmd 7.voidaddListener(ThreadSafeReportListener listener)Deprecated.voidaddListeners(List<ThreadSafeReportListener> allListeners)Deprecated.ThreadSafeReportListeneris deprecatedvoidaddMetric(Metric metric)Deprecated.seeStatisticalRulevoidaddRuleViolation(RuleViolation violation)Deprecated.PMD's way of creating a report is internal and may be changed in pmd 7.Iterator<Report.ConfigurationError>configErrors()Deprecated.static ReportcreateReport(RuleContext ctx, String fileName)Deprecated.Is internal APIvoidend()Deprecated.Not used,getElapsedTimeInMillis()will be removedIterator<Report.ProcessingError>errors()Deprecated.ReportfilterViolations(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.Map<String,Integer>getCountSummary()Deprecated.This is too specific.longgetElapsedTimeInMillis()Deprecated.UnusedList<ThreadSafeReportListener>getListeners()Deprecated.ThreadSafeReportListeneris deprecatedList<Report.ProcessingError>getProcessingErrors()Returns an unmodifiable list of processing errors that have been recorded until now.Map<String,Integer>getSummary()Deprecated.This is too specific, only used by one renderer.List<Report.SuppressedViolation>getSuppressedRuleViolations()Deprecated.UsegetSuppressedViolations()(be aware, that that method returns an unmodifiable list)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.ReportTreegetViolationTree()Deprecated.TheReportTreeis deprecatedbooleanhasConfigErrors()Deprecated.UsegetConfigurationErrors().isEmpty()booleanhasErrors()Deprecated.UsegetProcessingErrors().isEmpty()booleanhasMetrics()Deprecated.seeStatisticalRulebooleanisEmpty()Deprecated.Iterator<RuleViolation>iterator()Deprecated.UsegetViolations()voidmerge(Report r)Deprecated.Internal APIIterator<Metric>metrics()Deprecated.seeStatisticalRuleintsize()Deprecated.UsegetViolations()voidstart()Deprecated.Not used,getElapsedTimeInMillis()will be removedvoidsuppress(Map<Integer,String> lines)Configure the lines, that are suppressed via a NOPMD comment.booleantreeIsEmpty()Deprecated.TheReportTreeis deprecated, usegetViolations().isEmpty() instead.Iterator<RuleViolation>treeIterator()Deprecated.TheReportTreeis deprecatedinttreeSize()Deprecated.TheReportTreeis deprecatedReportunion(Report other)Creates a new report by combining this report with another report.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
Report
@Deprecated @InternalApi public Report()
Deprecated.Reportinstances are created by PMD. There is no need to create a own report. This constructor will be hidden in PMD7.
-
-
Method Detail
-
createReport
@Deprecated @InternalApi public static Report createReport(RuleContext ctx, String fileName)
Deprecated.Is internal APICreates a new, initialized, empty report for the given file name.- Parameters:
ctx- The context to use to connect to the reportfileName- the filename used to report any violations- Returns:
- the new report
-
suppress
public void suppress(Map<Integer,String> lines)
Configure the lines, that are suppressed via a NOPMD comment.- Parameters:
lines- the suppressed lines
-
getCountSummary
@Deprecated public Map<String,Integer> getCountSummary()
Deprecated.This is too specific. Not every violation has a qualified name.Calculate a summary of violation counts per fully classified class name.- Returns:
- violations per class name
-
getViolationTree
@Deprecated public ReportTree getViolationTree()
Deprecated.TheReportTreeis deprecated
-
getSummary
@Deprecated public Map<String,Integer> getSummary()
Deprecated.This is too specific, only used by one renderer.Calculate a summary of violations per rule.- Returns:
- a Map summarizing the Report: String (rule name) -> Integer (count of violations)
-
addListener
@Deprecated public void addListener(ThreadSafeReportListener listener)
Deprecated.Registers a report listener- Parameters:
listener- the listener
-
getSuppressedRuleViolations
@Deprecated public List<Report.SuppressedViolation> getSuppressedRuleViolations()
Deprecated.UsegetSuppressedViolations()(be aware, that that method returns an unmodifiable list)Returns the suppressed violations.
-
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
-
addMetric
@Deprecated public void addMetric(Metric metric)
Deprecated.seeStatisticalRuleAdds a new metric to the report and notify the listeners- Parameters:
metric- the metric 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 @InternalApi public void merge(Report r)
Deprecated.Internal APIMerges 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
-
hasMetrics
@Deprecated public boolean hasMetrics()
Deprecated.seeStatisticalRuleCheck whether any metrics have been reported- Returns:
trueif there are metrics,falseotherwise
-
metrics
@Deprecated public Iterator<Metric> metrics()
Deprecated.seeStatisticalRuleIterate over the metrics.- Returns:
- an iterator over the metrics
-
isEmpty
@Deprecated public boolean isEmpty()
Deprecated.Checks whether there are no violations and no processing errors. That means, that PMD analysis yielded nothing to worry about.
-
hasErrors
@Deprecated public boolean hasErrors()
Deprecated.UsegetProcessingErrors().isEmpty()Checks whether any processing errors have been reported.- Returns:
trueif there were any processing errors,falseotherwise
-
hasConfigErrors
@Deprecated public boolean hasConfigErrors()
Deprecated.UsegetConfigurationErrors().isEmpty()Checks whether any configuration errors have been reported.- Returns:
trueif there were any configuration errors,falseotherwise
-
treeIsEmpty
@Deprecated public boolean treeIsEmpty()
Deprecated.TheReportTreeis deprecated, usegetViolations().isEmpty() instead.Checks whether no violations have been reported.- Returns:
trueif no violations have been reported,falseotherwise
-
treeIterator
@Deprecated public Iterator<RuleViolation> treeIterator()
Deprecated.TheReportTreeis deprecatedReturns an iteration over the reported violations.- Returns:
- an iterator
-
iterator
@Deprecated public Iterator<RuleViolation> iterator()
Deprecated.UsegetViolations()- Specified by:
iteratorin interfaceIterable<RuleViolation>
-
getSuppressedViolations
public final List<Report.SuppressedViolation> getSuppressedViolations()
Returns an unmodifiable list of violations that were suppressed.
-
getViolations
public final 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 final List<Report.ProcessingError> getProcessingErrors()
Returns an unmodifiable list of processing errors that have been recorded until now.
-
getConfigurationErrors
public final List<Report.ConfigurationError> getConfigurationErrors()
Returns an unmodifiable list of configuration errors that have been recorded until now.
-
errors
@Deprecated public Iterator<Report.ProcessingError> errors()
Deprecated.Returns an iterator of the reported processing errors.- Returns:
- the iterator
-
configErrors
@Deprecated public Iterator<Report.ConfigurationError> configErrors()
Deprecated.Returns an iterator of the reported configuration errors.- Returns:
- the iterator
-
treeSize
@Deprecated public int treeSize()
Deprecated.TheReportTreeis deprecatedThe number of violations.- Returns:
- number of violations.
-
size
@Deprecated public int size()
Deprecated.UsegetViolations()The number of violations.- Returns:
- number of violations.
-
start
@Deprecated public void start()
Deprecated.Not used,getElapsedTimeInMillis()will be removedMark the start time of the report. This is used to get the elapsed time in the end.- See Also:
getElapsedTimeInMillis()
-
end
@Deprecated public void end()
Deprecated.Not used,getElapsedTimeInMillis()will be removedMark the end time of the report. This is ued to get the elapsed time.- See Also:
getElapsedTimeInMillis()
-
getElapsedTimeInMillis
@Deprecated public long getElapsedTimeInMillis()
Deprecated.Unused
-
getListeners
@Deprecated public List<ThreadSafeReportListener> getListeners()
Deprecated.ThreadSafeReportListeneris deprecated
-
addListeners
@Deprecated public void addListeners(List<ThreadSafeReportListener> allListeners)
Deprecated.ThreadSafeReportListeneris deprecatedAdds all given listeners to this report- Parameters:
allListeners- the report listeners
-
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:
-
-