From 3a5ff11dc25e23d3ba3fb304c4da6775e06dcd9d Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 26 Jan 2024 19:06:08 +0100 Subject: [PATCH] [core] Rename MessageReporter to PmdReporter as public API PmdReporter is supposed to be used when configuring PMD (see AbstractConfiguration#setReporter), so it can't be internal. Refs #4348 --- docs/pages/release_notes.md | 3 +++ .../pmd/cli/commands/internal/PmdCommand.java | 8 ++++---- .../pmd/cli/internal/PmdRootLogger.java | 8 ++++---- .../sourceforge/pmd/AbstractConfiguration.java | 10 +++++----- .../java/net/sourceforge/pmd/PmdAnalysis.java | 18 +++++++++--------- .../net/sourceforge/pmd/RuleSetFactory.java | 18 +++++++++--------- .../net/sourceforge/pmd/RuleSetLoader.java | 8 ++++---- .../sourceforge/pmd/RuleSetReferenceId.java | 6 +++--- .../java/net/sourceforge/pmd/RuleSets.java | 4 ++-- .../net/sourceforge/pmd/cpd/CpdAnalysis.java | 4 ++-- .../pmd/internal/util/FileCollectionUtil.java | 4 ++-- .../pmd/lang/LanguageProcessor.java | 8 ++++---- .../pmd/lang/LanguageProcessorRegistry.java | 14 +++++++------- .../pmd/lang/ast/SemanticErrorReporter.java | 6 +++--- .../pmd/lang/document/FileCollector.java | 12 ++++++------ .../pmd/lang/impl/MultiThreadProcessor.java | 4 ++-- .../net/sourceforge/pmd/rules/RuleFactory.java | 6 +++--- .../pmd/util/internal/xml/PmdXmlReporter.java | 4 ++-- .../{MessageReporter.java => PmdReporter.java} | 12 ++++-------- .../log/internal/ErrorsAsWarningsReporter.java | 8 +++----- .../util/log/internal/MessageReporterBase.java | 4 ++-- .../pmd/util/log/internal/QuietReporter.java | 6 ++---- .../log/internal/SimpleMessageReporter.java | 6 ++---- .../treeexport/TreeExportConfiguration.java | 8 ++++---- .../sourceforge/pmd/DummyParsingHelper.java | 4 ++-- .../net/sourceforge/pmd/PmdAnalysisTest.java | 4 ++-- .../pmd/RulesetFactoryTestBase.java | 4 ++-- .../sourceforge/pmd/cli/PMDFilelistTest.java | 4 ++-- .../lang/LanguageProcessorRegistryTest.java | 4 ++-- .../lang/ast/SemanticErrorReporterTest.java | 6 +++--- .../lang/impl/AbstractPMDProcessorTest.java | 4 ++-- .../pmd/processor/PmdRunnableTest.java | 6 +++--- .../pmd/lang/java/JavaParsingHelper.java | 4 ++-- .../sourceforge/pmd/lang/vf/VFTestUtils.java | 4 ++-- 34 files changed, 113 insertions(+), 120 deletions(-) rename pmd-core/src/main/java/net/sourceforge/pmd/util/log/{MessageReporter.java => PmdReporter.java} (88%) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index fd6547a97c..c2a5c7f2a0 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -196,6 +196,9 @@ The following previously deprecated classes have been removed: **Renamed classes, interfaces** +* pmd-core + * {%jdoc core::util.log.PmdReporter %} - has been renamed from `net.sourceforge.pmd.util.log.MessageReporter` + * pmd-java * The interface `AccessNode` has been renamed to {% jdoc java::lang.ast.ModifierOwner %}. This is only relevant for Java rules, which use that type directly e.g. through downcasting. diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdCommand.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdCommand.java index 29758b74be..feceb9e886 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdCommand.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdCommand.java @@ -38,7 +38,7 @@ import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.renderers.RendererFactory; import net.sourceforge.pmd.reporting.ReportStats; import net.sourceforge.pmd.util.StringUtil; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter; import picocli.CommandLine.Command; @@ -311,7 +311,7 @@ public class PmdCommand extends AbstractAnalysisPmdSubcommand TimeTracker.startGlobalTracking(); } - final MessageReporter pmdReporter = configuration.getReporter(); + final PmdReporter pmdReporter = configuration.getReporter(); try { PmdAnalysis pmd = null; @@ -359,14 +359,14 @@ public class PmdCommand extends AbstractAnalysisPmdSubcommand } } - private void printErrorDetected(MessageReporter reporter, int errors) { + private void printErrorDetected(PmdReporter reporter, int errors) { String msg = LogMessages.errorDetectedMessage(errors, "pmd"); // note: using error level here increments the error count of the reporter, // which we don't want. reporter.info(StringUtil.quoteMessageFormat(msg)); } - private void finishBenchmarker(final MessageReporter pmdReporter) { + private void finishBenchmarker(final PmdReporter pmdReporter) { if (benchmark) { final TimingReport timingReport = TimeTracker.stopGlobalTracking(); diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/PmdRootLogger.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/PmdRootLogger.java index c687582a63..54f23ad079 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/PmdRootLogger.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/PmdRootLogger.java @@ -13,7 +13,7 @@ import org.slf4j.event.Level; import net.sourceforge.pmd.AbstractConfiguration; import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter; /** @@ -46,7 +46,7 @@ public final class PmdRootLogger { resetLogLevel = true; } - MessageReporter pmdReporter = setupMessageReporter(); + PmdReporter pmdReporter = setupMessageReporter(); conf.setReporter(pmdReporter); return runnable.apply(conf); } finally { @@ -58,14 +58,14 @@ public final class PmdRootLogger { } } - private static @NonNull MessageReporter setupMessageReporter() { + private static @NonNull PmdReporter setupMessageReporter() { // Note: This implementation uses slf4j as the backend. If PMD is integrated into an application // a slf4j implementation binding must be provided to see any loggings (even errors). // In pmd-cli, we use slf4j-simple. // create a top-level reporter // TODO CLI errors should also be reported through this - MessageReporter pmdReporter = new SimpleMessageReporter(log); + PmdReporter pmdReporter = new SimpleMessageReporter(log); // always install java.util.logging to slf4j bridge Slf4jSimpleConfiguration.installJulBridge(); // logging, mostly for testing purposes diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java index c9a73c70ae..5b7e2184e5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java @@ -25,7 +25,7 @@ import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.LanguageVersionDiscoverer; import net.sourceforge.pmd.util.AssertionUtil; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * Base configuration class for both PMD and CPD. @@ -39,7 +39,7 @@ public abstract class AbstractConfiguration { private Charset sourceEncoding = Charset.forName(System.getProperty("file.encoding")); private final Map langProperties = new HashMap<>(); private final LanguageRegistry langRegistry; - private MessageReporter reporter; + private PmdReporter reporter; private final LanguageVersionDiscoverer languageVersionDiscoverer; private LanguageVersion forceLanguageVersion; private @NonNull List inputPaths = new ArrayList<>(); @@ -49,7 +49,7 @@ public abstract class AbstractConfiguration { private boolean collectRecursive = true; - protected AbstractConfiguration(LanguageRegistry languageRegistry, MessageReporter messageReporter) { + protected AbstractConfiguration(LanguageRegistry languageRegistry, PmdReporter messageReporter) { this.langRegistry = Objects.requireNonNull(languageRegistry); this.languageVersionDiscoverer = new LanguageVersionDiscoverer(languageRegistry); this.reporter = Objects.requireNonNull(messageReporter); @@ -100,7 +100,7 @@ public abstract class AbstractConfiguration { * Returns the message reporter that is to be used while running * the analysis. */ - public @NonNull MessageReporter getReporter() { + public @NonNull PmdReporter getReporter() { return reporter; } @@ -110,7 +110,7 @@ public abstract class AbstractConfiguration { * * @param reporter A non-null message reporter */ - public void setReporter(@NonNull MessageReporter reporter) { + public void setReporter(@NonNull PmdReporter reporter) { AssertionUtil.requireParamNotNull("reporter", reporter); this.reporter = reporter; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java b/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java index 6ef8602b73..bc49d48f49 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java @@ -51,7 +51,7 @@ import net.sourceforge.pmd.reporting.ReportStats; import net.sourceforge.pmd.reporting.ReportStatsListener; import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.StringUtil; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * Main programmatic API of PMD. This is not a CLI entry point, see module @@ -122,8 +122,8 @@ import net.sourceforge.pmd.util.log.MessageReporter; *

Customizing message output

* *

The analysis reports messages like meta warnings and errors through a - * {@link MessageReporter} instance. To override how those messages are output, - * you can set it in {@link PMDConfiguration#setReporter(MessageReporter)}. + * {@link PmdReporter} instance. To override how those messages are output, + * you can set it in {@link PMDConfiguration#setReporter(PmdReporter)}. * By default, it forwards messages to SLF4J. * */ @@ -136,7 +136,7 @@ public final class PmdAnalysis implements AutoCloseable { private final List listeners = new ArrayList<>(); private final List ruleSets = new ArrayList<>(); private final PMDConfiguration configuration; - private final MessageReporter reporter; + private final PmdReporter reporter; private final Map langProperties = new HashMap<>(); private boolean closed; @@ -344,7 +344,7 @@ public final class PmdAnalysis implements AutoCloseable { * processed. This does not return a report, as the analysis results * are consumed by {@link GlobalAnalysisListener} instances (of which * Renderers are a special case). Note that this does - * not throw, errors are instead accumulated into a {@link MessageReporter}. + * not throw, errors are instead accumulated into a {@link PmdReporter}. */ public void performAnalysis() { performAnalysisImpl(Collections.emptyList()); @@ -355,7 +355,7 @@ public final class PmdAnalysis implements AutoCloseable { * and finish the registered renderers. All files collected in the * {@linkplain #files() file collector} are processed. Returns the * output report. Note that this does not throw, errors are instead - * accumulated into a {@link MessageReporter}. + * accumulated into a {@link PmdReporter}. */ public Report performAnalysisAndCollectReport() { try (GlobalReportBuilderListener reportBuilder = new GlobalReportBuilderListener()) { @@ -534,7 +534,7 @@ public final class PmdAnalysis implements AutoCloseable { } - public MessageReporter getReporter() { + public PmdReporter getReporter() { return reporter; } @@ -586,7 +586,7 @@ public final class PmdAnalysis implements AutoCloseable { return stats; } - static void printErrorDetected(MessageReporter reporter, int errors) { + static void printErrorDetected(PmdReporter reporter, int errors) { String msg = LogMessages.errorDetectedMessage(errors, "PMD"); // note: using error level here increments the error count of the reporter, // which we don't want. @@ -598,7 +598,7 @@ public final class PmdAnalysis implements AutoCloseable { } private static void encourageToUseIncrementalAnalysis(final PMDConfiguration configuration) { - final MessageReporter reporter = configuration.getReporter(); + final PmdReporter reporter = configuration.getReporter(); if (!configuration.isIgnoreIncrementalAnalysis() && configuration.getAnalysisCache() instanceof NoopAnalysisCache diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java index b78a5c6f5d..1c3e7dc455 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java @@ -54,7 +54,7 @@ import net.sourceforge.pmd.util.StringUtil; import net.sourceforge.pmd.util.internal.xml.PmdXmlReporter; import net.sourceforge.pmd.util.internal.xml.XmlErrorMessages; import net.sourceforge.pmd.util.internal.xml.XmlUtil; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; import com.github.oowekyala.ooxml.DomUtils; import com.github.oowekyala.ooxml.messages.NiceXmlMessageSpec; @@ -81,7 +81,7 @@ final class RuleSetFactory { private final RulePriority minimumPriority; private final boolean warnDeprecated; private final RuleSetFactoryCompatibility compatibilityFilter; - private final MessageReporter reporter; + private final PmdReporter reporter; private final boolean includeDeprecatedRuleReferences; private final Map parsedRulesets = new HashMap<>(); @@ -92,7 +92,7 @@ final class RuleSetFactory { boolean warnDeprecated, RuleSetFactoryCompatibility compatFilter, boolean includeDeprecatedRuleReferences, - MessageReporter reporter) { + PmdReporter reporter) { this.resourceLoader = resourceLoader; this.languageRegistry = Objects.requireNonNull(languageRegistry); this.minimumPriority = minimumPriority; @@ -447,7 +447,7 @@ final class RuleSetFactory { return null; // deleted rule } // only emit a warning if we check for deprecated syntax - MessageReporter subReporter = warnDeprecated ? err.at(xmlPlace) : MessageReporter.quiet(); + PmdReporter subReporter = warnDeprecated ? err.at(xmlPlace) : PmdReporter.quiet(); List references = RuleSetReferenceId.parse(ref, subReporter); if (references.size() > 1 && warnDeprecated) { @@ -677,20 +677,20 @@ final class RuleSetFactory { } private static final class PmdXmlReporterImpl - extends XmlMessageReporterBase + extends XmlMessageReporterBase implements PmdXmlReporter { - private final MessageReporter pmdReporter; + private final PmdReporter pmdReporter; private int errCount; - PmdXmlReporterImpl(MessageReporter pmdReporter, OoxmlFacade ooxml, XmlPositioner positioner) { + PmdXmlReporterImpl(PmdReporter pmdReporter, OoxmlFacade ooxml, XmlPositioner positioner) { super(ooxml, positioner); this.pmdReporter = pmdReporter; } @Override - protected MessageReporter create2ndStage(XmlPosition position, XmlPositioner positioner) { - return new MessageReporter() { + protected PmdReporter create2ndStage(XmlPosition position, XmlPositioner positioner) { + return new PmdReporter() { @Override public boolean isLoggable(Level level) { return pmdReporter.isLoggable(level); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetLoader.java index 15987ef0bc..cc7b963a6a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetLoader.java @@ -26,7 +26,7 @@ import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.util.CollectionUtil; import net.sourceforge.pmd.util.ResourceLoader; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * Configurable object to load rulesets from XML resources. @@ -43,7 +43,7 @@ public final class RuleSetLoader { private boolean warnDeprecated = true; private @NonNull RuleSetFactoryCompatibility compatFilter = RuleSetFactoryCompatibility.DEFAULT; private boolean includeDeprecatedRuleReferences = false; - private @NonNull MessageReporter reporter = MessageReporter.quiet(); + private @NonNull PmdReporter reporter = PmdReporter.quiet(); /** * Create a new RuleSetLoader with a default configuration. @@ -53,7 +53,7 @@ public final class RuleSetLoader { // default } - RuleSetLoader withReporter(@NonNull MessageReporter reporter) { + RuleSetLoader withReporter(@NonNull PmdReporter reporter) { this.reporter = Objects.requireNonNull(reporter); return this; } @@ -153,7 +153,7 @@ public final class RuleSetLoader { ); } - private @Nullable MessageReporter filteredReporter() { + private @Nullable PmdReporter filteredReporter() { return warnDeprecated ? reporter : null; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java index 7afa4f78b2..c518210629 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java @@ -19,7 +19,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.util.ResourceLoader; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * This class is used to parse a RuleSet reference value. Most commonly used for @@ -147,7 +147,7 @@ public class RuleSetReferenceId { */ RuleSetReferenceId(final String id, final RuleSetReferenceId externalRuleSetReferenceId, - final @Nullable MessageReporter err) { + final @Nullable PmdReporter err) { this.originalRef = id; if (externalRuleSetReferenceId != null && !externalRuleSetReferenceId.isExternal()) { @@ -380,7 +380,7 @@ public class RuleSetReferenceId { } static List parse(String referenceString, - MessageReporter err) { + PmdReporter err) { List references = new ArrayList<>(); if (referenceString != null && referenceString.trim().length() > 0) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java index 5a118bca1a..178e424cf1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java @@ -21,7 +21,7 @@ import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.rule.internal.RuleApplicator; import net.sourceforge.pmd.reporting.FileAnalysisListener; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * Grouping of Rules per Language in a RuleSet. @@ -64,7 +64,7 @@ public class RuleSets { this.ruleSets = Collections.singletonList(ruleSet); } - public void initializeRules(LanguageProcessorRegistry lpReg, MessageReporter reporter) { + public void initializeRules(LanguageProcessorRegistry lpReg, PmdReporter reporter) { // this is abusing the mutability of RuleSet, will go away eventually. for (RuleSet rset : ruleSets) { for (Iterator iterator = rset.getRules().iterator(); iterator.hasNext();) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CpdAnalysis.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CpdAnalysis.java index fc1e131825..52e7309f69 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CpdAnalysis.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CpdAnalysis.java @@ -29,7 +29,7 @@ import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.TextDocument; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.properties.PropertyDescriptor; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * Main programmatic API of CPD. This is not a CLI entry point, see module @@ -70,7 +70,7 @@ public final class CpdAnalysis implements AutoCloseable { private static final Logger LOGGER = LoggerFactory.getLogger(CpdAnalysis.class); private final CPDConfiguration configuration; private final FileCollector files; - private final MessageReporter reporter; + private final PmdReporter reporter; private final @Nullable CPDReportRenderer renderer; private @NonNull CPDListener listener = new CPDNullListener(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java index 9fb518a9e5..8deb034292 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java @@ -21,7 +21,7 @@ import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.util.database.DBMSMetadata; import net.sourceforge.pmd.util.database.DBURI; import net.sourceforge.pmd.util.database.SourceObject; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; import net.sourceforge.pmd.util.log.internal.ErrorsAsWarningsReporter; /** @@ -57,7 +57,7 @@ public final class FileCollectionUtil { // This is to be able to interpret the log (will report 'adding' xxx) LOG.debug("Now collecting files to exclude."); // errors like "excluded file does not exist" are reported as warnings. - MessageReporter mutedLog = new ErrorsAsWarningsReporter(collector.getReporter()); + PmdReporter mutedLog = new ErrorsAsWarningsReporter(collector.getReporter()); try (FileCollector excludeCollector = collector.newCollector(mutedLog)) { if (configuration.getIgnoreFile() != null) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessor.java index cebbcf6fa5..51f227eecf 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessor.java @@ -14,7 +14,7 @@ import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.cache.internal.AnalysisCache; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * Stateful object managing the analysis for a given language. @@ -65,7 +65,7 @@ public interface LanguageProcessor extends AutoCloseable { private final GlobalAnalysisListener listener; private final int threadCount; private final AnalysisCache analysisCache; - private final MessageReporter messageReporter; + private final PmdReporter messageReporter; private final LanguageProcessorRegistry lpRegistry; @@ -79,7 +79,7 @@ public interface LanguageProcessor extends AutoCloseable { GlobalAnalysisListener listener, int threadCount, AnalysisCache analysisCache, - MessageReporter messageReporter, + PmdReporter messageReporter, LanguageProcessorRegistry lpRegistry) { this.rulesets = rulesets; this.files = files; @@ -110,7 +110,7 @@ public interface LanguageProcessor extends AutoCloseable { return analysisCache; } - public MessageReporter getMessageReporter() { + public PmdReporter getMessageReporter() { return messageReporter; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessorRegistry.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessorRegistry.java index 19bc5a02ae..dd11a890e7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessorRegistry.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessorRegistry.java @@ -23,7 +23,7 @@ import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertySource; import net.sourceforge.pmd.util.CollectionUtil; import net.sourceforge.pmd.util.StringUtil.CaseConvention; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * Stores all currently initialized {@link LanguageProcessor}s during analysis. @@ -116,14 +116,14 @@ public final class LanguageProcessorRegistry implements AutoCloseable { */ public static LanguageProcessorRegistry create(LanguageRegistry registry, Map languageProperties, - MessageReporter messageReporter) { + PmdReporter messageReporter) { return create(registry, languageProperties, messageReporter, System.getenv()); } // overload for testing to allow mocking the system env vars. static LanguageProcessorRegistry create(LanguageRegistry registry, Map languageProperties, - MessageReporter messageReporter, + PmdReporter messageReporter, Map env) { Set processors = new HashSet<>(); for (Language language : registry) { @@ -152,7 +152,7 @@ public final class LanguageProcessorRegistry implements AutoCloseable { // TODO this should be reused when implementing the CLI public static Map derivePropertiesFromStrings( Map stringProperties, - MessageReporter reporter + PmdReporter reporter ) { Map typedProperties = new HashMap<>(); stringProperties.forEach((l, props) -> { @@ -163,7 +163,7 @@ public final class LanguageProcessorRegistry implements AutoCloseable { } - private static void setLanguageProperties(Map languageProperties, MessageReporter messageReporter, Language language, LanguagePropertyBundle properties) { + private static void setLanguageProperties(Map languageProperties, PmdReporter messageReporter, Language language, LanguagePropertyBundle properties) { Properties props = languageProperties.get(language); if (props != null) { props.forEach((k, v) -> { @@ -182,7 +182,7 @@ public final class LanguageProcessorRegistry implements AutoCloseable { private static void trySetPropertyCapture(PropertySource source, PropertyDescriptor propertyDescriptor, String propertyValue, - MessageReporter reporter) { + PmdReporter reporter) { try { T value = propertyDescriptor.serializer().fromString(propertyValue); source.setProperty(propertyDescriptor, value); @@ -194,7 +194,7 @@ public final class LanguageProcessorRegistry implements AutoCloseable { } } - private static void readLanguagePropertiesFromEnv(LanguagePropertyBundle props, MessageReporter reporter, Map env) { + private static void readLanguagePropertiesFromEnv(LanguagePropertyBundle props, PmdReporter reporter, Map env) { for (PropertyDescriptor propertyDescriptor : props.getPropertyDescriptors()) { String envVarName = getEnvironmentVariableName(props.getLanguage(), propertyDescriptor); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporter.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporter.java index 4f421b8075..ae95fe2395 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporter.java @@ -10,7 +10,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.slf4j.event.Level; import net.sourceforge.pmd.util.StringUtil; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * Reports errors that occur after parsing. This may be used to implement @@ -83,10 +83,10 @@ public interface SemanticErrorReporter { /** - * Forwards to a {@link MessageReporter}, except trace and debug + * Forwards to a {@link PmdReporter}, except trace and debug * messages which are reported on a logger. */ - static SemanticErrorReporter reportToLogger(MessageReporter reporter) { + static SemanticErrorReporter reportToLogger(PmdReporter reporter) { return new SemanticErrorReporter() { private SemanticException exception = null; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java index 6cc0ff5006..3d0ab591aa 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java @@ -42,7 +42,7 @@ import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.LanguageVersionDiscoverer; import net.sourceforge.pmd.util.AssertionUtil; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * Collects files to analyse before a PMD run. This API allows opening @@ -59,14 +59,14 @@ public final class FileCollector implements AutoCloseable { private final List resourcesToClose = new ArrayList<>(); private Charset charset = StandardCharsets.UTF_8; private final LanguageVersionDiscoverer discoverer; - private final MessageReporter reporter; + private final PmdReporter reporter; private final FileId outerFsPath; private boolean closed; private boolean recursive = true; // construction - private FileCollector(LanguageVersionDiscoverer discoverer, MessageReporter reporter, FileId outerFsPath) { + private FileCollector(LanguageVersionDiscoverer discoverer, PmdReporter reporter, FileId outerFsPath) { this.discoverer = discoverer; this.reporter = reporter; this.outerFsPath = outerFsPath; @@ -82,7 +82,7 @@ public final class FileCollector implements AutoCloseable { * creating a collector yourself. */ @InternalApi - public static FileCollector newCollector(LanguageVersionDiscoverer discoverer, MessageReporter reporter) { + public static FileCollector newCollector(LanguageVersionDiscoverer discoverer, PmdReporter reporter) { return new FileCollector(discoverer, reporter, null); } @@ -90,7 +90,7 @@ public final class FileCollector implements AutoCloseable { * Returns a new collector using the configuration except for the logger. */ @InternalApi - public FileCollector newCollector(MessageReporter logger) { + public FileCollector newCollector(PmdReporter logger) { FileCollector fileCollector = new FileCollector(discoverer, logger, null); fileCollector.charset = this.charset; return fileCollector; @@ -118,7 +118,7 @@ public final class FileCollector implements AutoCloseable { * Returns the reporter for the file collection phase. */ @InternalApi - public MessageReporter getReporter() { + public PmdReporter getReporter() { return reporter; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessor.java index cd0e26dc37..db0feb12f4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessor.java @@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit; import net.sourceforge.pmd.RuleSets; import net.sourceforge.pmd.lang.LanguageProcessor.AnalysisTask; import net.sourceforge.pmd.lang.document.TextFile; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** @@ -43,7 +43,7 @@ final class MultiThreadProcessor extends AbstractPMDProcessor { RuleSets copy = new RuleSets(task.getRulesets()); // use a noop reporter because the copy should only contain rules that // initialized properly - copy.initializeRules(task.getLpRegistry(), MessageReporter.quiet()); + copy.initializeRules(task.getLpRegistry(), PmdReporter.quiet()); return copy; }); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rules/RuleFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/rules/RuleFactory.java index b3a0a2cbde..7b4dd0310d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rules/RuleFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rules/RuleFactory.java @@ -63,7 +63,7 @@ import net.sourceforge.pmd.util.internal.xml.PmdXmlReporter; import net.sourceforge.pmd.util.internal.xml.SchemaConstant; import net.sourceforge.pmd.util.internal.xml.XmlErrorMessages; import net.sourceforge.pmd.util.internal.xml.XmlUtil; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; import com.github.oowekyala.ooxml.DomUtils; import com.github.oowekyala.ooxml.messages.XmlException; @@ -429,7 +429,7 @@ public class RuleFactory { } - private static @Nullable T tryParsePropertyValue(BuilderAndMapper factory, String value, MessageReporter err) { + private static @Nullable T tryParsePropertyValue(BuilderAndMapper factory, String value, PmdReporter err) { try { return factory.getXmlMapper().fromString(value); } catch (IllegalArgumentException e) { @@ -437,7 +437,7 @@ public class RuleFactory { } } - private static Comparable asComparableOrThrow(T object, MessageReporter err) { + private static Comparable asComparableOrThrow(T object, PmdReporter err) { if (object instanceof Comparable) { return (Comparable) object; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/internal/xml/PmdXmlReporter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/internal/xml/PmdXmlReporter.java index 02464f545a..a0facb0fdb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/internal/xml/PmdXmlReporter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/internal/xml/PmdXmlReporter.java @@ -4,13 +4,13 @@ package net.sourceforge.pmd.util.internal.xml; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; import com.github.oowekyala.ooxml.messages.XmlMessageReporter; /** * @author Clément Fournier */ -public interface PmdXmlReporter extends XmlMessageReporter { +public interface PmdXmlReporter extends XmlMessageReporter { } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/MessageReporter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/PmdReporter.java similarity index 88% rename from pmd-core/src/main/java/net/sourceforge/pmd/util/log/MessageReporter.java rename to pmd-core/src/main/java/net/sourceforge/pmd/util/log/PmdReporter.java index 9763f6ad01..bfdaab89e6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/MessageReporter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/PmdReporter.java @@ -9,22 +9,18 @@ import java.text.MessageFormat; import org.checkerframework.checker.nullness.qual.Nullable; import org.slf4j.event.Level; -import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.util.log.internal.QuietReporter; /** * Façade to report user-facing messages (info, warning and error). - * Note: messages are formatted using {@link MessageFormat}. * - *

Internal API: this is a transitional API that will be significantly - * changed in PMD 7, with the transition to SLF4J. See https://github.com/pmd/pmd/issues/3816 + *

Note: messages are formatted using {@link MessageFormat}. * - * TODO rename to PmdReporter + *

Note: This interface was called net.sourceforge.pmd.util.log.MessageReporter in PMD 6.

* * @author Clément Fournier */ -@InternalApi -public interface MessageReporter { +public interface PmdReporter { // todo change String to MessageFormat in those arg lists, it's too confusing // where to apply MessageFormat otherwise... @@ -101,7 +97,7 @@ public interface MessageReporter { * Returns a reporter instance that does not output anything, but * still counts errors. */ - static MessageReporter quiet() { + static PmdReporter quiet() { return new QuietReporter(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/ErrorsAsWarningsReporter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/ErrorsAsWarningsReporter.java index 71b201e2cc..9befa9e29f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/ErrorsAsWarningsReporter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/ErrorsAsWarningsReporter.java @@ -6,20 +6,18 @@ package net.sourceforge.pmd.util.log.internal; import org.slf4j.event.Level; -import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * Turns errors into warnings reported on another logger. * * @author Clément Fournier */ -@InternalApi public final class ErrorsAsWarningsReporter extends MessageReporterBase { - private final MessageReporter backend; + private final PmdReporter backend; - public ErrorsAsWarningsReporter(MessageReporter backend) { + public ErrorsAsWarningsReporter(PmdReporter backend) { this.backend = backend; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/MessageReporterBase.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/MessageReporterBase.java index e0929ac7d5..617b150237 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/MessageReporterBase.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/MessageReporterBase.java @@ -14,14 +14,14 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.slf4j.event.Level; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * Base implementation. * * @author Clément Fournier */ -public abstract class MessageReporterBase implements MessageReporter { +public abstract class MessageReporterBase implements PmdReporter { private int numErrors; private @Nullable Level minLevel = Level.TRACE; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/QuietReporter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/QuietReporter.java index ca9cfe55a9..b60bba7b46 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/QuietReporter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/QuietReporter.java @@ -6,16 +6,14 @@ package net.sourceforge.pmd.util.log.internal; import org.slf4j.event.Level; -import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * A logger that ignores all messages. * * @author Clément Fournier */ -@InternalApi -public class QuietReporter extends MessageReporterBase implements MessageReporter { +public class QuietReporter extends MessageReporterBase implements PmdReporter { // note: not singleton because PmdLogger accumulates error count. // note: not final because used as mock in tests. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/SimpleMessageReporter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/SimpleMessageReporter.java index f7ce618fa6..fd6189dbe6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/SimpleMessageReporter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/SimpleMessageReporter.java @@ -7,16 +7,14 @@ package net.sourceforge.pmd.util.log.internal; import org.slf4j.Logger; import org.slf4j.event.Level; -import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * A {@link Logger} (java.util) based logger impl. * * @author Clément Fournier */ -@InternalApi -public class SimpleMessageReporter extends MessageReporterBase implements MessageReporter { +public class SimpleMessageReporter extends MessageReporterBase implements PmdReporter { private final Logger backend; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExportConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExportConfiguration.java index b57dbd0e34..2f55cb36d4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExportConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExportConfiguration.java @@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory; import net.sourceforge.pmd.AbstractConfiguration; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter; public class TreeExportConfiguration extends AbstractConfiguration { @@ -28,7 +28,7 @@ public class TreeExportConfiguration extends AbstractConfiguration { private Properties languageProperties = new Properties(); private Path file; private boolean readStdin; - private MessageReporter messageReporter = new SimpleMessageReporter(LOG); + private PmdReporter messageReporter = new SimpleMessageReporter(LOG); public TreeExportConfiguration(LanguageRegistry registry) { super(registry, new SimpleMessageReporter(LoggerFactory.getLogger(TreeExporter.class))); @@ -86,11 +86,11 @@ public class TreeExportConfiguration extends AbstractConfiguration { this.readStdin = readStdin; } - public MessageReporter getMessageReporter() { + public PmdReporter getMessageReporter() { return messageReporter; } - public void setMessageReporter(MessageReporter messageReporter) { + public void setMessageReporter(PmdReporter messageReporter) { this.messageReporter = messageReporter; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/DummyParsingHelper.java b/pmd-core/src/test/java/net/sourceforge/pmd/DummyParsingHelper.java index 417de87663..aa0da9ba92 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/DummyParsingHelper.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/DummyParsingHelper.java @@ -21,7 +21,7 @@ import net.sourceforge.pmd.lang.ast.Parser.ParserTask; import net.sourceforge.pmd.lang.ast.SemanticErrorReporter; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.TextDocument; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * @author Clément Fournier @@ -61,7 +61,7 @@ public class DummyParsingHelper implements Extension, BeforeEachCallback, AfterE LanguageProcessorRegistry registry = LanguageProcessorRegistry.create( LanguageRegistry.PMD, Collections.emptyMap(), - MessageReporter.quiet() + PmdReporter.quiet() ); dummyProcessor = registry.getProcessor(DummyLanguageModule.getInstance()); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java index 8095c7a009..1f4e7c14bc 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java @@ -33,7 +33,7 @@ import net.sourceforge.pmd.lang.document.SimpleTestTextFile; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.reporting.ReportStats; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * @author Clément Fournier @@ -106,7 +106,7 @@ class PmdAnalysisTest { void testRuleFailureDuringInitialization() { PMDConfiguration config = new PMDConfiguration(); config.setThreads(1); - MessageReporter mockReporter = spy(MessageReporter.quiet()); + PmdReporter mockReporter = spy(PmdReporter.quiet()); config.setReporter(mockReporter); try (PmdAnalysis pmd = PmdAnalysis.create(config)) { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RulesetFactoryTestBase.java b/pmd-core/src/test/java/net/sourceforge/pmd/RulesetFactoryTestBase.java index f21796ee76..37d8fb7602 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RulesetFactoryTestBase.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RulesetFactoryTestBase.java @@ -30,12 +30,12 @@ import org.slf4j.event.Level; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.util.internal.xml.SchemaConstant; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter; public class RulesetFactoryTestBase { - protected MessageReporter mockReporter; + protected PmdReporter mockReporter; @BeforeEach void setup() { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDFilelistTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDFilelistTest.java index b3693969d1..8e49b3be93 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDFilelistTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDFilelistTest.java @@ -25,14 +25,14 @@ import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersionDiscoverer; import net.sourceforge.pmd.lang.document.FileCollector; import net.sourceforge.pmd.lang.document.TextFile; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; class PMDFilelistTest { private static final Path RESOURCES = Paths.get("src/test/resources/net/sourceforge/pmd/cli/"); private @NonNull FileCollector newCollector() { - return FileCollector.newCollector(new LanguageVersionDiscoverer(LanguageRegistry.PMD), MessageReporter.quiet()); + return FileCollector.newCollector(new LanguageVersionDiscoverer(LanguageRegistry.PMD), PmdReporter.quiet()); } @Test diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageProcessorRegistryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageProcessorRegistryTest.java index eb500bbfc6..cb4824a27b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageProcessorRegistryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageProcessorRegistryTest.java @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; class LanguageProcessorRegistryTest { @Test @@ -28,7 +28,7 @@ class LanguageProcessorRegistryTest { DummyLanguagePropertyBundle bundle = new DummyLanguagePropertyBundle(dummyLanguage); languageProperties.put(dummyLanguage, bundle); - try (LanguageProcessorRegistry ignored = LanguageProcessorRegistry.create(languageRegistry, languageProperties, MessageReporter.quiet(), env)) { + try (LanguageProcessorRegistry ignored = LanguageProcessorRegistry.create(languageRegistry, languageProperties, PmdReporter.quiet(), env)) { assertEquals("theValue", bundle.getRootDirectory()); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporterTest.java index e5c1b86e71..7769164d37 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporterTest.java @@ -22,7 +22,7 @@ import org.slf4j.event.Level; import org.slf4j.helpers.NOPLogger; import net.sourceforge.pmd.DummyParsingHelper; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; /** * Reports errors that occur after parsing. This may be used to implement @@ -30,7 +30,7 @@ import net.sourceforge.pmd.util.log.MessageReporter; */ class SemanticErrorReporterTest { - MessageReporter mockReporter; + PmdReporter mockReporter; Logger mockLogger; @RegisterExtension @@ -38,7 +38,7 @@ class SemanticErrorReporterTest { @BeforeEach void setup() { - mockReporter = mock(MessageReporter.class); + mockReporter = mock(PmdReporter.class); when(mockReporter.isLoggable(Level.ERROR)).thenReturn(true); mockLogger = spy(NOPLogger.class); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessorTest.java index ca52a03e65..060515d596 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessorTest.java @@ -28,12 +28,12 @@ import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; abstract class AbstractPMDProcessorTest { protected SimpleReportListener reportListener; - protected MessageReporter reporter; + protected PmdReporter reporter; protected abstract int getThreads(); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/processor/PmdRunnableTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/processor/PmdRunnableTest.java index 93da9002b1..f2d7e24d45 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/processor/PmdRunnableTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/processor/PmdRunnableTest.java @@ -42,7 +42,7 @@ import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.impl.SimpleLanguageModuleBase; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.util.ContextedAssertionError; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; import com.github.stefanbirkner.systemlambda.SystemLambda; @@ -54,7 +54,7 @@ class PmdRunnableTest { private static final String THROWS_ASSERTION_ERROR = "1.9-throws"; private PMDConfiguration configuration; - private MessageReporter reporter; + private PmdReporter reporter; private Rule rule; @@ -63,7 +63,7 @@ class PmdRunnableTest { // reset data rule = spy(new RuleThatThrows()); configuration = new PMDConfiguration(LanguageRegistry.singleton(ThrowingLanguageModule.INSTANCE)); - reporter = mock(MessageReporter.class); + reporter = mock(PmdReporter.class); configuration.setReporter(reporter); // exceptions thrown on a worker thread are not thrown by the main thread, // so this test only makes sense without separate threads diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/JavaParsingHelper.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/JavaParsingHelper.java index 4a16d064d5..0fd2359166 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/JavaParsingHelper.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/JavaParsingHelper.java @@ -33,7 +33,7 @@ import net.sourceforge.pmd.lang.java.types.TypeSystem; import net.sourceforge.pmd.lang.java.types.internal.infer.TypeInferenceLogger; import net.sourceforge.pmd.lang.java.types.internal.infer.TypeInferenceLogger.SimpleLogger; import net.sourceforge.pmd.lang.java.types.internal.infer.TypeInferenceLogger.VerboseLogger; -import net.sourceforge.pmd.util.log.MessageReporter; +import net.sourceforge.pmd.util.log.PmdReporter; import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter; import kotlin.Pair; @@ -129,7 +129,7 @@ public class JavaParsingHelper extends BaseParsingHelper