forked from phoedos/pmd
Merge branch 'pmd/7.0.x' into pmd7-896-slf4j
This commit is contained in:
@ -29,12 +29,21 @@ This is a {{ site.pmd.release_type }} release.
|
|||||||
#### Deprecated API
|
#### Deprecated API
|
||||||
|
|
||||||
Some API deprecations were performed in core PMD classes, to improve compatibility with PMD 7.
|
Some API deprecations were performed in core PMD classes, to improve compatibility with PMD 7.
|
||||||
- {% jdoc core::Report %}: construction methods like addViolation or createReport
|
- {% jdoc core::Report %}: the constructor and other construction methods like addViolation or createReport
|
||||||
- {% jdoc core::RuleContext %}: all constructors, getters and setters. A new set
|
- {% jdoc core::RuleContext %}: all constructors, getters and setters. A new set
|
||||||
of stable methods, matching those in PMD 7, was added to replace the `addViolation`
|
of stable methods, matching those in PMD 7, was added to replace the `addViolation`
|
||||||
overloads of {% jdoc core::lang.rule.AbstractRule %}. In PMD 7, `RuleContext` will
|
overloads of {% jdoc core::lang.rule.AbstractRule %}. In PMD 7, `RuleContext` will
|
||||||
be the API to report violations, and it can already be used as such in PMD 6.
|
be the API to report violations, and it can already be used as such in PMD 6.
|
||||||
|
- The field {% jdoc core::PMD#configuration %} is unused and will be removed.
|
||||||
|
|
||||||
|
#### Internal API
|
||||||
|
|
||||||
|
Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0.
|
||||||
|
You can identify them with the `@InternalApi` annotation. You'll also get a deprecation warning.
|
||||||
|
|
||||||
- {% jdoc core::RuleSet %}: methods that serve to apply rules, including `apply`, `start`, `end`, `removeDysfunctionalRules`
|
- {% jdoc core::RuleSet %}: methods that serve to apply rules, including `apply`, `start`, `end`, `removeDysfunctionalRules`
|
||||||
|
- {% jdoc !!core::renderers.AbstractAccumulatingRenderer#renderFileReport(Report) %} is internal API
|
||||||
|
and should not be overridden in own renderers.
|
||||||
|
|
||||||
#### Changed API
|
#### Changed API
|
||||||
|
|
||||||
|
@ -60,6 +60,17 @@ import net.sourceforge.pmd.util.datasource.ReaderDataSource;
|
|||||||
* process is controlled via interactions with this class. A command line
|
* process is controlled via interactions with this class. A command line
|
||||||
* interface is supported, as well as a programmatic API for integrating PMD
|
* interface is supported, as well as a programmatic API for integrating PMD
|
||||||
* with other software such as IDEs and Ant.
|
* with other software such as IDEs and Ant.
|
||||||
|
*
|
||||||
|
* <p>Main entrypoints are:
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link #main(String[])} which exits the java process</li>
|
||||||
|
* <li>{@link #runPmd(String...)} which returns a {@link StatusCode}</li>
|
||||||
|
* <li>{@link #runPmd(PMDConfiguration)}</li>
|
||||||
|
* <li>{@link #processFiles(PMDConfiguration, List, Collection, List)}</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* <p><strong>Warning:</strong> This class is not intended to be instantiated or subclassed. It will
|
||||||
|
* be made final in PMD7.
|
||||||
*/
|
*/
|
||||||
public final class PMD {
|
public final class PMD {
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import net.sourceforge.pmd.annotation.DeprecatedUntil700;
|
||||||
|
import net.sourceforge.pmd.annotation.InternalApi;
|
||||||
import net.sourceforge.pmd.renderers.AbstractAccumulatingRenderer;
|
import net.sourceforge.pmd.renderers.AbstractAccumulatingRenderer;
|
||||||
import net.sourceforge.pmd.reporting.FileAnalysisListener;
|
import net.sourceforge.pmd.reporting.FileAnalysisListener;
|
||||||
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
|
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
|
||||||
@ -37,8 +39,10 @@ public final class Report {
|
|||||||
private final List<ProcessingError> errors = synchronizedList(new ArrayList<>());
|
private final List<ProcessingError> errors = synchronizedList(new ArrayList<>());
|
||||||
private final List<ConfigurationError> configErrors = synchronizedList(new ArrayList<>());
|
private final List<ConfigurationError> configErrors = synchronizedList(new ArrayList<>());
|
||||||
|
|
||||||
Report() {
|
@DeprecatedUntil700
|
||||||
// package-private, you have to use a listener to build a report.
|
@InternalApi
|
||||||
|
public Report() { // NOPMD - UnnecessaryConstructor
|
||||||
|
// TODO: should be package-private, you have to use a listener to build a report.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,7 +172,10 @@ public final class Report {
|
|||||||
*
|
*
|
||||||
* @deprecated PMD's way of creating a report is internal and may be changed in pmd 7.
|
* @deprecated PMD's way of creating a report is internal and may be changed in pmd 7.
|
||||||
*/
|
*/
|
||||||
private void addRuleViolation(RuleViolation violation) {
|
@DeprecatedUntil700
|
||||||
|
@Deprecated
|
||||||
|
@InternalApi
|
||||||
|
public void addRuleViolation(RuleViolation violation) {
|
||||||
synchronized (violations) {
|
synchronized (violations) {
|
||||||
int index = Collections.binarySearch(violations, violation, RuleViolation.DEFAULT_COMPARATOR);
|
int index = Collections.binarySearch(violations, violation, RuleViolation.DEFAULT_COMPARATOR);
|
||||||
violations.add(index < 0 ? -index - 1 : index, violation);
|
violations.add(index < 0 ? -index - 1 : index, violation);
|
||||||
@ -189,7 +196,10 @@ public final class Report {
|
|||||||
*
|
*
|
||||||
* @deprecated PMD's way of creating a report is internal and may be changed in pmd 7.
|
* @deprecated PMD's way of creating a report is internal and may be changed in pmd 7.
|
||||||
*/
|
*/
|
||||||
private void addConfigError(ConfigurationError error) {
|
@DeprecatedUntil700
|
||||||
|
@Deprecated
|
||||||
|
@InternalApi
|
||||||
|
public void addConfigError(ConfigurationError error) {
|
||||||
configErrors.add(error);
|
configErrors.add(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +210,10 @@ public final class Report {
|
|||||||
* the error to add
|
* the error to add
|
||||||
* @deprecated PMD's way of creating a report is internal and may be changed in pmd 7.
|
* @deprecated PMD's way of creating a report is internal and may be changed in pmd 7.
|
||||||
*/
|
*/
|
||||||
private void addError(ProcessingError error) {
|
@DeprecatedUntil700
|
||||||
|
@Deprecated
|
||||||
|
@InternalApi
|
||||||
|
public void addError(ProcessingError error) {
|
||||||
errors.add(error);
|
errors.add(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import java.util.Objects;
|
|||||||
import net.sourceforge.pmd.Report;
|
import net.sourceforge.pmd.Report;
|
||||||
import net.sourceforge.pmd.Report.ConfigurationError;
|
import net.sourceforge.pmd.Report.ConfigurationError;
|
||||||
import net.sourceforge.pmd.Report.GlobalReportBuilderListener;
|
import net.sourceforge.pmd.Report.GlobalReportBuilderListener;
|
||||||
|
import net.sourceforge.pmd.annotation.InternalApi;
|
||||||
import net.sourceforge.pmd.benchmark.TimeTracker;
|
import net.sourceforge.pmd.benchmark.TimeTracker;
|
||||||
import net.sourceforge.pmd.benchmark.TimedOperation;
|
import net.sourceforge.pmd.benchmark.TimedOperation;
|
||||||
import net.sourceforge.pmd.benchmark.TimedOperationCategory;
|
import net.sourceforge.pmd.benchmark.TimedOperationCategory;
|
||||||
@ -24,6 +25,9 @@ import net.sourceforge.pmd.util.datasource.DataSource;
|
|||||||
* quite large in some scenarios. Consider using
|
* quite large in some scenarios. Consider using
|
||||||
* {@link AbstractIncrementingRenderer} which can use significantly less memory.
|
* {@link AbstractIncrementingRenderer} which can use significantly less memory.
|
||||||
*
|
*
|
||||||
|
* <p>Subclasses should only implement the {@link #end()} method to output the
|
||||||
|
* complete {@link #report}.
|
||||||
|
*
|
||||||
* @see AbstractIncrementingRenderer
|
* @see AbstractIncrementingRenderer
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractAccumulatingRenderer extends AbstractRenderer {
|
public abstract class AbstractAccumulatingRenderer extends AbstractRenderer {
|
||||||
@ -48,7 +52,15 @@ public abstract class AbstractAccumulatingRenderer extends AbstractRenderer {
|
|||||||
Objects.requireNonNull(dataSource);
|
Objects.requireNonNull(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @deprecated This is internal API. Do not override when extending {@link AbstractAccumulatingRenderer}.
|
||||||
|
* In PMD7 this method will be made final.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@InternalApi
|
||||||
|
@Deprecated
|
||||||
public final void renderFileReport(Report report) throws IOException {
|
public final void renderFileReport(Report report) throws IOException {
|
||||||
// do nothing, final because it will never be called by the listener
|
// do nothing, final because it will never be called by the listener
|
||||||
Objects.requireNonNull(report);
|
Objects.requireNonNull(report);
|
||||||
|
@ -256,20 +256,20 @@ public abstract class RuleTst {
|
|||||||
|
|
||||||
public Report runTestFromString(String code, Rule rule, LanguageVersion languageVersion, boolean isUseAuxClasspath) {
|
public Report runTestFromString(String code, Rule rule, LanguageVersion languageVersion, boolean isUseAuxClasspath) {
|
||||||
try {
|
try {
|
||||||
PMDConfiguration config = new PMDConfiguration();
|
PMDConfiguration configuration = new PMDConfiguration();
|
||||||
config.setIgnoreIncrementalAnalysis(true);
|
configuration.setIgnoreIncrementalAnalysis(true);
|
||||||
config.setDefaultLanguageVersion(languageVersion);
|
configuration.setDefaultLanguageVersion(languageVersion);
|
||||||
config.setThreads(1);
|
configuration.setThreads(1);
|
||||||
|
|
||||||
if (isUseAuxClasspath) {
|
if (isUseAuxClasspath) {
|
||||||
// configure the "auxclasspath" option for unit testing
|
// configure the "auxclasspath" option for unit testing
|
||||||
config.prependClasspath(".");
|
configuration.prependClasspath(".");
|
||||||
} else {
|
} else {
|
||||||
// simple class loader, that doesn't delegate to parent.
|
// simple class loader, that doesn't delegate to parent.
|
||||||
// this allows us in the tests to simulate PMD run without
|
// this allows us in the tests to simulate PMD run without
|
||||||
// auxclasspath, not even the classes from the test dependencies
|
// auxclasspath, not even the classes from the test dependencies
|
||||||
// will be found.
|
// will be found.
|
||||||
config.setClassLoader(new ClassLoader() {
|
configuration.setClassLoader(new ClassLoader() {
|
||||||
@Override
|
@Override
|
||||||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
||||||
if (name.startsWith("java.") || name.startsWith("javax.")) {
|
if (name.startsWith("java.") || name.startsWith("javax.")) {
|
||||||
@ -289,7 +289,7 @@ public abstract class RuleTst {
|
|||||||
listOf(RuleSet.forSingleRule(rule)),
|
listOf(RuleSet.forSingleRule(rule)),
|
||||||
DataSource.forString(code, "test." + languageVersion.getLanguage().getExtensions().get(0)),
|
DataSource.forString(code, "test." + languageVersion.getLanguage().getExtensions().get(0)),
|
||||||
listener,
|
listener,
|
||||||
config
|
configuration
|
||||||
);
|
);
|
||||||
|
|
||||||
listener.close();
|
listener.close();
|
||||||
|
2
pom.xml
2
pom.xml
@ -94,7 +94,7 @@
|
|||||||
<surefire.version>3.0.0-M5</surefire.version>
|
<surefire.version>3.0.0-M5</surefire.version>
|
||||||
<checkstyle.version>9.3</checkstyle.version>
|
<checkstyle.version>9.3</checkstyle.version>
|
||||||
<checkstyle.plugin.version>3.1.2</checkstyle.plugin.version>
|
<checkstyle.plugin.version>3.1.2</checkstyle.plugin.version>
|
||||||
<pmd.plugin.version>3.15.0</pmd.plugin.version>
|
<pmd.plugin.version>3.16.0</pmd.plugin.version>
|
||||||
<ant.version>1.10.12</ant.version>
|
<ant.version>1.10.12</ant.version>
|
||||||
<javadoc.plugin.version>3.2.0</javadoc.plugin.version>
|
<javadoc.plugin.version>3.2.0</javadoc.plugin.version>
|
||||||
<antlr.version>4.8</antlr.version>
|
<antlr.version>4.8</antlr.version>
|
||||||
|
Reference in New Issue
Block a user