[core] Move Rule/RuleSet related type into net.sourceforge.pmd.rule

Refs #3917
This commit is contained in:
Andreas Dangel
2024-01-12 18:14:04 +01:00
parent 6d955d6b9a
commit 9e668c22fc
93 changed files with 196 additions and 181 deletions

View File

@ -151,9 +151,21 @@ in the Migration Guide.
#### API Changes
**Moved classes**
**Moved classes/consolidated packages**
* pmd-core
* The interface {%jdoc core::rule.Rule %} has been moved into the new package {% jdoc_package core::rule %}.
* Many types have been moved from the base package `net.sourceforge.pmd` into the new subpackage {% jdoc_package core::rule %}
* {%jdoc core::rule.Rule %}
* {%jdoc core::rule.RuleFactory %} (moved from `net.sourceforge.pmd.rules`; it has now been hidden from public API)
* {%jdoc core::rule.RulePriority %}
* {%jdoc core::rule.RuleSet %}
* {%jdoc core::rule.RuleSetFactory %}
* {%jdoc core::rule.RuleSetFactoryCompatibility %}
* {%jdoc core::rule.RuleSetLoader %}
* {%jdoc core::rule.RuleSetLoadException %}
* {%jdoc core::rule.RuleSetReference %} (note: this is _not_ public API)
* {%jdoc core::rule.RuleSetReferenceId %} (has been hidden from public API)
* {%jdoc core::rule.RuleSets %} (note: this is _not_ public API)
* {%jdoc core::rule.RuleSetWriter %}
**Removed classes and methods**

View File

@ -17,9 +17,9 @@ import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.types.Resource;
import net.sourceforge.pmd.RulePriority;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.ant.internal.PMDTaskImpl;
import net.sourceforge.pmd.rule.RulePriority;
/**
* PMD Ant task. Setters of this class are interpreted by Ant as properties

View File

@ -23,8 +23,6 @@ import org.slf4j.event.Level;
import net.sourceforge.pmd.PMDConfiguration;
import net.sourceforge.pmd.PmdAnalysis;
import net.sourceforge.pmd.RulePriority;
import net.sourceforge.pmd.RuleSetLoader;
import net.sourceforge.pmd.ant.Formatter;
import net.sourceforge.pmd.ant.PMDTask;
import net.sourceforge.pmd.ant.SourceLanguage;
@ -39,6 +37,8 @@ import net.sourceforge.pmd.reporting.FileAnalysisListener;
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
import net.sourceforge.pmd.reporting.ReportStats;
import net.sourceforge.pmd.reporting.ReportStatsListener;
import net.sourceforge.pmd.rule.RulePriority;
import net.sourceforge.pmd.rule.RuleSetLoader;
public class PMDTaskImpl {

View File

@ -9,9 +9,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.AbstractRuleSetFactoryTest;
import net.sourceforge.pmd.RuleSet;
import net.sourceforge.pmd.RuleSetLoader;
import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest;
import net.sourceforge.pmd.rule.RuleSet;
import net.sourceforge.pmd.rule.RuleSetLoader;
import com.github.stefanbirkner.systemlambda.SystemLambda;

View File

@ -4,7 +4,7 @@
package net.sourceforge.pmd.lang.apex;
import net.sourceforge.pmd.AbstractRuleSetFactoryTest;
import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest;
class RuleSetFactoryTest extends AbstractRuleSetFactoryTest {
// no additional tests yet

View File

@ -16,8 +16,6 @@ import org.junit.jupiter.api.io.TempDir;
import net.sourceforge.pmd.PMDConfiguration;
import net.sourceforge.pmd.PmdAnalysis;
import net.sourceforge.pmd.Report;
import net.sourceforge.pmd.RuleSet;
import net.sourceforge.pmd.RuleSetLoader;
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageVersion;
@ -25,6 +23,8 @@ import net.sourceforge.pmd.lang.apex.ApexLanguageModule;
import net.sourceforge.pmd.lang.apex.ApexLanguageProperties;
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
import net.sourceforge.pmd.rule.Rule;
import net.sourceforge.pmd.rule.RuleSet;
import net.sourceforge.pmd.rule.RuleSetLoader;
import com.nawforce.pkgforce.path.PathFactory;
import com.nawforce.pkgforce.path.PathLike;

View File

@ -20,7 +20,6 @@ import org.slf4j.LoggerFactory;
import net.sourceforge.pmd.PMDConfiguration;
import net.sourceforge.pmd.PmdAnalysis;
import net.sourceforge.pmd.RulePriority;
import net.sourceforge.pmd.benchmark.TextTimingReportRenderer;
import net.sourceforge.pmd.benchmark.TimeTracker;
import net.sourceforge.pmd.benchmark.TimingReport;
@ -37,6 +36,7 @@ import net.sourceforge.pmd.properties.PropertyDescriptor;
import net.sourceforge.pmd.renderers.Renderer;
import net.sourceforge.pmd.renderers.RendererFactory;
import net.sourceforge.pmd.reporting.ReportStats;
import net.sourceforge.pmd.rule.RulePriority;
import net.sourceforge.pmd.util.StringUtil;
import net.sourceforge.pmd.util.log.MessageReporter;
import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter;

View File

@ -8,7 +8,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.sourceforge.pmd.RulePriority;
import net.sourceforge.pmd.rule.RulePriority;
import picocli.CommandLine.ITypeConverter;
import picocli.CommandLine.TypeConversionException;

View File

@ -32,6 +32,8 @@ import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.renderers.Renderer;
import net.sourceforge.pmd.renderers.RendererFactory;
import net.sourceforge.pmd.rule.RulePriority;
import net.sourceforge.pmd.rule.RuleSetLoader;
import net.sourceforge.pmd.util.AssertionUtil;
import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter;

View File

@ -29,6 +29,8 @@ import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.renderers.Renderer;
import net.sourceforge.pmd.renderers.RendererFactory;
import net.sourceforge.pmd.rule.RulePriority;
import net.sourceforge.pmd.rule.RuleSetLoader;
import net.sourceforge.pmd.util.AssertionUtil;
import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter;

View File

@ -50,6 +50,9 @@ import net.sourceforge.pmd.reporting.ListenerInitializer;
import net.sourceforge.pmd.reporting.ReportStats;
import net.sourceforge.pmd.reporting.ReportStatsListener;
import net.sourceforge.pmd.rule.Rule;
import net.sourceforge.pmd.rule.RuleSet;
import net.sourceforge.pmd.rule.RuleSetLoader;
import net.sourceforge.pmd.rule.RuleSets;
import net.sourceforge.pmd.util.AssertionUtil;
import net.sourceforge.pmd.util.StringUtil;
import net.sourceforge.pmd.util.log.MessageReporter;

View File

@ -27,7 +27,6 @@ import org.slf4j.LoggerFactory;
import net.sourceforge.pmd.PMDVersion;
import net.sourceforge.pmd.Report.ProcessingError;
import net.sourceforge.pmd.RuleSets;
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.benchmark.TimeTracker;
@ -39,6 +38,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.reporting.FileAnalysisListener;
import net.sourceforge.pmd.rule.RuleSets;
/**
* Abstract implementation of the analysis cache. Handles all operations, except for persistence.

View File

@ -8,13 +8,13 @@ import java.io.IOException;
import java.util.Collection;
import java.util.List;
import net.sourceforge.pmd.RuleSets;
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.document.TextDocument;
import net.sourceforge.pmd.lang.document.TextFile;
import net.sourceforge.pmd.reporting.FileAnalysisListener;
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
import net.sourceforge.pmd.rule.RuleSets;
/**
* An analysis cache for incremental analysis.

View File

@ -7,11 +7,11 @@ package net.sourceforge.pmd.cache;
import java.io.IOException;
import java.util.Collection;
import net.sourceforge.pmd.RuleSets;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.document.TextFile;
import net.sourceforge.pmd.reporting.FileAnalysisListener;
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
import net.sourceforge.pmd.rule.RuleSets;
/**
* Adapter to wrap {@link AnalysisCache} behaviour in a {@link GlobalAnalysisListener}.

View File

@ -7,9 +7,9 @@ package net.sourceforge.pmd.cache;
import java.util.HashMap;
import java.util.Map;
import net.sourceforge.pmd.RuleSets;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.rule.Rule;
import net.sourceforge.pmd.rule.RuleSets;
/**
* A mapper from rule class names to rule instances for cached rules.

View File

@ -19,7 +19,6 @@ import java.util.Map;
import java.util.stream.Collectors;
import net.sourceforge.pmd.PMDVersion;
import net.sourceforge.pmd.RuleSets;
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.benchmark.TimeTracker;
@ -27,6 +26,7 @@ import net.sourceforge.pmd.benchmark.TimedOperation;
import net.sourceforge.pmd.benchmark.TimedOperationCategory;
import net.sourceforge.pmd.lang.document.FileId;
import net.sourceforge.pmd.lang.document.TextFile;
import net.sourceforge.pmd.rule.RuleSets;
/**
* An analysis cache backed by a regular file.

View File

@ -8,12 +8,12 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import net.sourceforge.pmd.RuleSets;
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.document.TextDocument;
import net.sourceforge.pmd.lang.document.TextFile;
import net.sourceforge.pmd.reporting.FileAnalysisListener;
import net.sourceforge.pmd.rule.RuleSets;
/**
* A NOOP analysis cache. Easier / safer than null-checking.

View File

@ -9,11 +9,11 @@ import java.util.List;
import org.checkerframework.checker.nullness.qual.NonNull;
import net.sourceforge.pmd.RuleSets;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.cache.AnalysisCache;
import net.sourceforge.pmd.lang.document.TextFile;
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
import net.sourceforge.pmd.rule.RuleSets;
import net.sourceforge.pmd.util.log.MessageReporter;
/**

View File

@ -4,9 +4,9 @@
package net.sourceforge.pmd.lang.impl;
import net.sourceforge.pmd.RuleSets;
import net.sourceforge.pmd.lang.LanguageProcessor.AnalysisTask;
import net.sourceforge.pmd.lang.document.TextFile;
import net.sourceforge.pmd.rule.RuleSets;
/**
* @author Romain Pelisse <belaran@gmail.com>

View File

@ -12,9 +12,9 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
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.rule.RuleSets;
import net.sourceforge.pmd.util.log.MessageReporter;

View File

@ -10,7 +10,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.sourceforge.pmd.Report;
import net.sourceforge.pmd.RuleSets;
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.benchmark.TimeTracker;
import net.sourceforge.pmd.benchmark.TimedOperation;
@ -29,6 +28,7 @@ import net.sourceforge.pmd.lang.ast.SemanticException;
import net.sourceforge.pmd.lang.document.TextDocument;
import net.sourceforge.pmd.lang.document.TextFile;
import net.sourceforge.pmd.reporting.FileAnalysisListener;
import net.sourceforge.pmd.rule.RuleSets;
/**
* A processing task for a single file.

View File

@ -8,7 +8,6 @@ import java.util.List;
import java.util.Map;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.RulePriority;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageProcessor;
import net.sourceforge.pmd.lang.LanguageVersion;
@ -16,6 +15,7 @@ import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.properties.PropertyDescriptor;
import net.sourceforge.pmd.properties.PropertySource;
import net.sourceforge.pmd.rule.Rule;
import net.sourceforge.pmd.rule.RulePriority;
/**
* Base class for Rule implementations which delegate to another Rule instance.

View File

@ -16,7 +16,6 @@ import java.util.Set;
import org.checkerframework.checker.nullness.qual.NonNull;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.RulePriority;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageVersion;
import net.sourceforge.pmd.lang.ast.Node;
@ -24,6 +23,7 @@ import net.sourceforge.pmd.lang.ast.RootNode;
import net.sourceforge.pmd.properties.AbstractPropertySource;
import net.sourceforge.pmd.properties.PropertyDescriptor;
import net.sourceforge.pmd.rule.Rule;
import net.sourceforge.pmd.rule.RulePriority;
/**
* Basic abstract implementation of all parser-independent methods of the Rule

View File

@ -12,11 +12,11 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import net.sourceforge.pmd.RulePriority;
import net.sourceforge.pmd.RuleSetReference;
import net.sourceforge.pmd.lang.LanguageVersion;
import net.sourceforge.pmd.properties.PropertyDescriptor;
import net.sourceforge.pmd.rule.Rule;
import net.sourceforge.pmd.rule.RulePriority;
import net.sourceforge.pmd.rule.RuleSetReference;
import net.sourceforge.pmd.util.StringUtil;
/**

View File

@ -13,7 +13,6 @@ import org.slf4j.LoggerFactory;
import net.sourceforge.pmd.Report.ProcessingError;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.RuleSet;
import net.sourceforge.pmd.benchmark.TimeTracker;
import net.sourceforge.pmd.benchmark.TimedOperation;
import net.sourceforge.pmd.benchmark.TimedOperationCategory;
@ -23,6 +22,7 @@ import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.ast.RootNode;
import net.sourceforge.pmd.reporting.FileAnalysisListener;
import net.sourceforge.pmd.rule.Rule;
import net.sourceforge.pmd.rule.RuleSet;
import net.sourceforge.pmd.util.AssertionUtil;
import net.sourceforge.pmd.util.StringUtil;

View File

@ -8,8 +8,8 @@ import java.util.Objects;
import org.checkerframework.checker.nullness.qual.Nullable;
import net.sourceforge.pmd.RuleSetWriter;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.rule.RuleSetWriter;
/**

View File

@ -9,8 +9,6 @@ import java.util.Optional;
import java.util.regex.Pattern;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.RulePriority;
import net.sourceforge.pmd.RuleSet;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageProcessor;
import net.sourceforge.pmd.lang.LanguageVersion;

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.rules;
package net.sourceforge.pmd.rule;
import static net.sourceforge.pmd.util.internal.xml.SchemaConstants.CLASS;
import static net.sourceforge.pmd.util.internal.xml.SchemaConstants.DELIMITER;
@ -41,9 +41,6 @@ import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import net.sourceforge.pmd.RulePriority;
import net.sourceforge.pmd.RuleSetReference;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.LanguageVersion;
@ -56,7 +53,6 @@ import net.sourceforge.pmd.properties.PropertyDescriptor;
import net.sourceforge.pmd.properties.PropertySerializer;
import net.sourceforge.pmd.properties.PropertyTypeId;
import net.sourceforge.pmd.properties.PropertyTypeId.BuilderAndMapper;
import net.sourceforge.pmd.rule.Rule;
import net.sourceforge.pmd.util.ResourceLoader;
import net.sourceforge.pmd.util.StringUtil;
import net.sourceforge.pmd.util.internal.xml.PmdXmlReporter;
@ -75,9 +71,7 @@ import com.github.oowekyala.ooxml.messages.XmlException;
* @author Clément Fournier
* @since 6.0.0
*/
@InternalApi
@Deprecated
public class RuleFactory {
class RuleFactory {
private final ResourceLoader resourceLoader;
private final LanguageRegistry languageRegistry;
@ -85,7 +79,7 @@ public class RuleFactory {
/**
* @param resourceLoader The resource loader to load the rule from jar
*/
public RuleFactory(ResourceLoader resourceLoader,
RuleFactory(ResourceLoader resourceLoader,
LanguageRegistry languageRegistry) {
this.resourceLoader = resourceLoader;
this.languageRegistry = languageRegistry;

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd;
package net.sourceforge.pmd.rule;
/**
* These are the possible Rule priority values.

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd;
package net.sourceforge.pmd.rule;
import java.util.ArrayList;
import java.util.Arrays;
@ -28,7 +28,6 @@ import net.sourceforge.pmd.lang.document.FileId;
import net.sourceforge.pmd.lang.document.TextFile;
import net.sourceforge.pmd.lang.rule.RuleReference;
import net.sourceforge.pmd.lang.rule.XPathRule;
import net.sourceforge.pmd.rule.Rule;
/**
* This class represents a collection of rules along with some optional filter

Some files were not shown because too many files have changed in this diff Show More