A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/3792 below:

[core] Allow to filter violations in Report · Issue #3792 · pmd/pmd · GitHub

Implemented solution:

net.sourceforge.pmd.Report gets two new methods:

Is your feature request related to a problem? Please describe.
With the latest deprecations (#3692, #3762) Report should not be instantiated anymore. However, in maven-pmd-plugin, there is one use case: The plugin supports an own mechanism to exclude violations (https://maven.apache.org/plugins/maven-pmd-plugin/examples/violation-exclusions.html). These exclusions are applied after PMD is run and the violations are simply deleted from the report.
Currently this is implemented in PMDCollectingRenderer where the violations are collected in a mutable list and at the end a new report is created (see asReport()).
The exclusion happens here: https://github.com/apache/maven-pmd-plugin/blob/e6fd0db79767b7f15db24cba6b9ce689db0b7f3b/src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java#L301 - the returned list from the renderer is modified.

PMDCollectingRenderer could extend from AbstractAccumulatingRenderer, however then the given report must be used. This returns an unmodifiable List for the violations (

public final List<RuleViolation> getViolations() { return Collections.unmodifiableList(violations); }

).

maven-pmd-plugin is therefore not able anymore to remove violations after PMD has run and before the report is rendered (into xml, html, ...).

Describe the solution you'd like
Provide a method to remove violations from the report. A simple impl could look like this:

public void excludeViolations(List<RuleViolation> excludedViolations) {
    violations.removeAll(excludedViolations);
}

Describe alternatives you've considered

Additional context


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4