From 6d955d6b9adee43a4e6c58ed0c446735dcab366b Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 12 Jan 2024 11:04:02 +0100 Subject: [PATCH 01/23] [core] Move Rule into package net.sourceforge.pmd.rule --- docs/_plugins/javadoc_tag.rb | 8 ++++---- docs/pages/release_notes.md | 4 ++++ .../pmd/lang/apex/ApexViolationSuppressors.java | 2 +- .../pmd/lang/apex/rule/design/UnusedMethodTest.java | 2 +- pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java | 8 ++++++++ .../src/main/java/net/sourceforge/pmd/PmdAnalysis.java | 1 + pmd-core/src/main/java/net/sourceforge/pmd/Report.java | 1 + .../src/main/java/net/sourceforge/pmd/RuleContext.java | 1 + pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java | 1 + .../main/java/net/sourceforge/pmd/RuleSetFactory.java | 1 + .../src/main/java/net/sourceforge/pmd/RuleSetLoader.java | 1 + .../src/main/java/net/sourceforge/pmd/RuleSetWriter.java | 1 + pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java | 1 + .../src/main/java/net/sourceforge/pmd/RuleViolation.java | 1 + .../java/net/sourceforge/pmd/ViolationSuppressor.java | 1 + .../java/net/sourceforge/pmd/cache/CachedRuleMapper.java | 2 +- .../net/sourceforge/pmd/cache/CachedRuleViolation.java | 2 +- .../java/net/sourceforge/pmd/lang/LanguageVersion.java | 2 +- .../sourceforge/pmd/lang/rule/AbstractDelegateRule.java | 2 +- .../java/net/sourceforge/pmd/lang/rule/AbstractRule.java | 2 +- .../pmd/lang/rule/ParametricRuleViolation.java | 2 +- .../net/sourceforge/pmd/lang/rule/RuleReference.java | 2 +- .../sourceforge/pmd/lang/rule/RuleTargetSelector.java | 2 +- .../java/net/sourceforge/pmd/lang/rule/XPathRule.java | 2 +- .../pmd/lang/rule/internal/RuleApplicator.java | 2 +- .../lang/rule/xpath/internal/DeprecatedAttrLogger.java | 2 +- .../net/sourceforge/pmd/properties/PropertySource.java | 4 +++- .../sourceforge/pmd/renderers/CodeClimateRenderer.java | 2 +- .../java/net/sourceforge/pmd/renderers/HTMLRenderer.java | 2 +- .../main/java/net/sourceforge/pmd/{ => rule}/Rule.java | 5 ++++- .../main/java/net/sourceforge/pmd/rules/RuleFactory.java | 2 +- .../java/net/sourceforge/pmd/util/ResourceLoader.java | 2 +- .../test/java/net/sourceforge/pmd/PmdCoreTestUtils.java | 1 + .../src/test/java/net/sourceforge/pmd/ReportTest.java | 1 + .../test/java/net/sourceforge/pmd/ReportTestUtil.java | 1 + .../pmd/RuleSetFactoryDuplicatedRuleLoggingTest.java | 2 ++ .../net/sourceforge/pmd/RuleSetFactoryMessagesTest.java | 1 + .../java/net/sourceforge/pmd/RuleSetFactoryTest.java | 1 + .../src/test/java/net/sourceforge/pmd/RuleSetTest.java | 1 + .../net/sourceforge/pmd/RuleViolationComparatorTest.java | 3 ++- .../test/java/net/sourceforge/pmd/RuleViolationTest.java | 1 + .../java/net/sourceforge/pmd/RulesetFactoryTestBase.java | 1 + .../net/sourceforge/pmd/cache/FileAnalysisCacheTest.java | 9 +++++---- .../net/sourceforge/pmd/lang/rule/XPathRuleTest.java | 3 ++- .../net/sourceforge/pmd/processor/PmdRunnableTest.java | 2 +- .../sourceforge/pmd/properties/PropertySyntaxTest.java | 2 +- .../sourceforge/pmd/renderers/AbstractRendererTest.java | 2 +- .../net/sourceforge/pmd/renderers/SarifRendererTest.java | 2 +- .../sourceforge/pmd/renderers/YAHTMLRendererTest.java | 2 +- .../pmd/reporting/GlobalAnalysisListenerTest.java | 2 +- .../java/net/sourceforge/pmd/docs/RuleDocGenerator.java | 2 +- .../main/java/net/sourceforge/pmd/docs/RuleSetUtils.java | 2 +- .../net/sourceforge/pmd/lang/html/HtmlJavaRuleTest.java | 2 +- .../lang/java/internal/AnnotationSuppressionUtil.java | 2 +- .../test/java/net/sourceforge/pmd/ExcludeLinesTest.java | 1 + .../src/test/java/net/sourceforge/pmd/ReportTest.java | 1 + .../sourceforge/pmd/lang/java/rule/XPathRuleTest.java | 2 +- .../java/rule/documentation/CommentRequiredTest.java | 2 +- .../java/rule/xpath/internal/BaseXPathFunctionTest.java | 2 +- .../rule/xpath/internal/GetModifiersFunctionsTest.java | 2 +- .../java/rule/xpath/internal/HasAnnotationXPathTest.java | 2 +- .../rule/xpath/internal/MatchesSignatureXPathTest.java | 2 +- .../java/rule/xpath/internal/NodeIsFunctionTest.java | 2 +- .../java/rule/xpath/internal/TypeIsFunctionTest.java | 2 +- .../rule/xpath/internal/XPathMetricFunctionTest.java | 2 +- .../src/test/java/net/sourceforge/pmd/ReportTest.java | 1 + .../sourceforge/pmd/lang/jsp/ast/XPathJspRuleTest.java | 2 +- .../sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt | 1 + .../pmd/lang/plsql/rule/errorprone/ToDateToCharTest.java | 2 +- .../rule/errorprone/ToDateWithoutDateFormatTest.java | 2 +- .../errorprone/ToTimestampWithoutDateFormatTest.java | 2 +- .../sourceforge/pmd/test/schema/BaseTestParserImpl.java | 2 +- .../sourceforge/pmd/test/schema/RuleTestDescriptor.java | 2 +- .../sourceforge/pmd/test/schema/TestSchemaParser.java | 2 +- .../net/sourceforge/pmd/AbstractRuleSetFactoryTest.java | 1 + .../net/sourceforge/pmd/testframework/PmdRuleTst.java | 2 +- .../java/net/sourceforge/pmd/testframework/RuleTst.java | 2 +- .../pmd/testframework/SimpleAggregatorTst.java | 2 +- .../net/sourceforge/pmd/testframework/RuleTstTest.java | 2 +- .../pmd/lang/vf/rule/security/VfUnescapeElTest.java | 2 +- .../sourceforge/pmd/lang/xml/rule/XmlXPathRuleTest.java | 2 +- 81 files changed, 106 insertions(+), 61 deletions(-) create mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java rename pmd-core/src/main/java/net/sourceforge/pmd/{ => rule}/Rule.java (98%) diff --git a/docs/_plugins/javadoc_tag.rb b/docs/_plugins/javadoc_tag.rb index c31b9a655f..0ece78d2df 100644 --- a/docs/_plugins/javadoc_tag.rb +++ b/docs/_plugins/javadoc_tag.rb @@ -73,19 +73,19 @@ require_relative 'jdoc_namespace_tag' # * a (args) -> adds the simple name of the argument types for method references, noop for other references # * {% jdoc !a!core::Rule#setName(java.lang.String) %} -> [`setName(String)`](...) # * q (qualify) -> prefix with the fqcn of the class, noop for package references -# * {% jdoc !q!core::Rule %} -> [`net.sourceforge.pmd.Rule`](...) -# * {% jdoc !q!core::Rule#setName(java.lang.String) %} -> [`net.sourceforge.pmd.Rule#setName`](...) +# * {% jdoc !q!core::rule.Rule %} -> [`net.sourceforge.pmd.rule.Rule`](...) +# * {% jdoc !q!core::rule.Rule#setName(java.lang.String) %} -> [`net.sourceforge.pmd.rule.Rule#setName`](...) # * c (class) -> prefix the class name for member references, noop for type and package references, or if "qualify" is specified # * {% jdoc !c!core::Rule#setName(java.lang.String) %} -> [`Rule#setName`](...) # * Empty options ("!!") - > shorthand to a commonly relevant option # * For field or method references, "!!" is the "c" option # * {% jdoc !!core::Rule#setName(java.lang.String) %} -> [`Rule#setName`](...) # * For type references, "!!" is the "q" option -# * {% jdoc !!core::Rule %} -> [`net.sourceforge.pmd.Rule`](...) +# * {% jdoc !!core::rule.Rule %} -> [`net.sourceforge.pmd.rule.Rule`](...) # * For package references, "!!" is a noop, they're always fully qualified # * Several options may be used at once, though this is only useful for method references: # * {% jdoc !ac!core::Rule#setName(java.lang.String) %} -> [`Rule#setName(String)`](...) -# * {% jdoc !aq!core::Rule#setName(java.lang.String) %} -> [`net.sourceforge.pmd.Rule#setName(String)`](...) +# * {% jdoc !aq!core::rule.Rule#setName(java.lang.String) %} -> [`net.sourceforge.pmd.rule.Rule#setName(String)`](...) # # * DO NOT: # - Include spaces in any part of the reference diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 10d7b525fd..544d54f101 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -151,6 +151,10 @@ in the Migration Guide. #### API Changes +**Moved classes** +* pmd-core + * The interface {%jdoc core::rule.Rule %} has been moved into the new package {% jdoc_package core::rule %}. + **Removed classes and methods** The following previously deprecated classes have been removed: diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexViolationSuppressors.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexViolationSuppressors.java index ef792b2cfb..939e0dc0e5 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexViolationSuppressors.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexViolationSuppressors.java @@ -15,7 +15,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Report.SuppressedViolation; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.ViolationSuppressor; import net.sourceforge.pmd.lang.apex.ast.ASTAnnotation; @@ -30,6 +29,7 @@ import net.sourceforge.pmd.lang.apex.ast.ASTUserEnum; import net.sourceforge.pmd.lang.apex.ast.ASTVariableDeclarationStatements; import net.sourceforge.pmd.lang.apex.ast.ApexNode; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.rule.Rule; final class ApexViolationSuppressors { diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java index cda9afc56b..c64c4158db 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java @@ -16,7 +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.Rule; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.RuleSetLoader; import net.sourceforge.pmd.RuleViolation; @@ -25,6 +24,7 @@ import net.sourceforge.pmd.lang.LanguageVersion; 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 com.nawforce.pkgforce.path.PathFactory; import com.nawforce.pkgforce.path.PathLike; diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java new file mode 100644 index 0000000000..75f293395c --- /dev/null +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java @@ -0,0 +1,8 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd; + +public interface Rule extends net.sourceforge.pmd.rule.Rule { +} 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 6a1b013776..5293246812 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java @@ -49,6 +49,7 @@ import net.sourceforge.pmd.reporting.GlobalAnalysisListener; 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.util.AssertionUtil; import net.sourceforge.pmd.util.StringUtil; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/Report.java b/pmd-core/src/main/java/net/sourceforge/pmd/Report.java index d579ec05d7..112e2cf6aa 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/Report.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/Report.java @@ -23,6 +23,7 @@ import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.renderers.AbstractAccumulatingRenderer; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.BaseResultProducingCloseable; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java index 905d38474f..542732bc23 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java @@ -26,6 +26,7 @@ import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.ViolationDecorator; +import net.sourceforge.pmd.rule.Rule; /** * The API for rules to report violations or errors during analysis. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java index 8d7e370a4d..3f5f149e7b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java @@ -28,6 +28,7 @@ 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 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..81e7b1675a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java @@ -48,6 +48,7 @@ import org.xml.sax.InputSource; import net.sourceforge.pmd.RuleSet.RuleSetBuilder; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.rule.RuleReference; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.rules.RuleFactory; import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.StringUtil; 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..08032a14b6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetLoader.java @@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.CollectionUtil; import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java index 6bf03db1a0..88e3757635 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java @@ -40,6 +40,7 @@ import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertySerializer; import net.sourceforge.pmd.properties.PropertySource; import net.sourceforge.pmd.properties.PropertyTypeId; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; /** 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..062c527635 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java @@ -21,6 +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.rule.Rule; import net.sourceforge.pmd.util.log.MessageReporter; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java index 3b0f1518a7..a0a63b0d0a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java @@ -10,6 +10,7 @@ import java.util.Map; import net.sourceforge.pmd.annotation.DeprecatedUntil700; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.FileLocation; +import net.sourceforge.pmd.rule.Rule; /** * A RuleViolation is created by a Rule when it identifies a violation of the diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/ViolationSuppressor.java b/pmd-core/src/main/java/net/sourceforge/pmd/ViolationSuppressor.java index 4d6c0edb30..94c74422e5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/ViolationSuppressor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/ViolationSuppressor.java @@ -18,6 +18,7 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; import net.sourceforge.pmd.lang.rule.xpath.internal.DeprecatedAttrLogger; import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery; +import net.sourceforge.pmd.rule.Rule; /** * An object that suppresses rule violations. Suppressors are used by diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java index aa1be53825..31c41174eb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java @@ -7,9 +7,9 @@ package net.sourceforge.pmd.cache; import java.util.HashMap; import java.util.Map; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleSets; import net.sourceforge.pmd.annotation.InternalApi; +import net.sourceforge.pmd.rule.Rule; /** * A mapper from rule class names to rule instances for cached rules. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleViolation.java index f53d56492e..e1f5bdbd21 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleViolation.java @@ -14,12 +14,12 @@ import java.util.Map.Entry; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextRange2d; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.StringUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java index d14f147ec9..a94cb809d5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang; import java.util.List; import java.util.Objects; -import net.sourceforge.pmd.Rule; +import net.sourceforge.pmd.rule.Rule; /** * Represents a version of a {@link Language}. Language instances provide diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java index a780a65178..a1b2386402 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java @@ -7,7 +7,6 @@ package net.sourceforge.pmd.lang.rule; import java.util.List; import java.util.Map; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.lang.Language; @@ -16,6 +15,7 @@ import net.sourceforge.pmd.lang.LanguageVersion; 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; /** * Base class for Rule implementations which delegate to another Rule instance. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java index fd0573ed7b..cf7db90d0b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java @@ -15,7 +15,6 @@ import java.util.Set; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.lang.Language; @@ -24,6 +23,7 @@ import net.sourceforge.pmd.lang.ast.Node; 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; /** * Basic abstract implementation of all parser-independent methods of the Rule diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java index 6697ff7728..09e67cfa7f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java @@ -7,11 +7,11 @@ package net.sourceforge.pmd.lang.rule; import java.util.Collections; import java.util.Map; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.reporting.Reportable; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.AssertionUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java index 4572a31ce5..a0f9b75734 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java @@ -12,11 +12,11 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import net.sourceforge.pmd.Rule; 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.util.StringUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleTargetSelector.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleTargetSelector.java index 7e01c2071e..23f958d42e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleTargetSelector.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleTargetSelector.java @@ -12,12 +12,12 @@ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Set; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.rule.internal.TargetSelectorInternal; import net.sourceforge.pmd.lang.rule.internal.TreeIndex; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.CollectionUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java index e5cc2ea252..1a15b99921 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java @@ -16,7 +16,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.annotation.DeprecatedUntil700; import net.sourceforge.pmd.lang.LanguageProcessor; @@ -27,6 +26,7 @@ import net.sourceforge.pmd.lang.rule.xpath.internal.DeprecatedAttrLogger; import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.rule.Rule; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java index 6da5e290d8..a1b9f089fd 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java @@ -12,7 +12,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import net.sourceforge.pmd.Report.ProcessingError; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.benchmark.TimeTracker; @@ -23,6 +22,7 @@ import net.sourceforge.pmd.lang.LanguageVersion; 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.util.AssertionUtil; import net.sourceforge.pmd.util.StringUtil; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java index 5b0a6c3dc8..f808d375a5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java @@ -10,9 +10,9 @@ import java.util.concurrent.ConcurrentMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.Attribute; +import net.sourceforge.pmd.rule.Rule; /** * Records usages of deprecated attributes in XPath rules. This needs diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertySource.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertySource.java index 9d5ad1413a..896dd7fcc7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertySource.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertySource.java @@ -7,6 +7,8 @@ package net.sourceforge.pmd.properties; import java.util.List; import java.util.Map; +import net.sourceforge.pmd.rule.Rule; + /** * Entity that manages a list of properties. Properties are described by @@ -18,7 +20,7 @@ import java.util.Map; * *

Bad configuration of the properties may be reported by {@link #dysfunctionReason()}. * - *

Notable instances of this interface are {@linkplain net.sourceforge.pmd.Rule rules} and + *

Notable instances of this interface are {@linkplain Rule rules} and * {@linkplain net.sourceforge.pmd.renderers.Renderer renderers}. * * @author Brian Remedios diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java index e2f4334206..4ff5571e3f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java @@ -12,9 +12,9 @@ import java.util.List; import org.apache.commons.lang3.StringUtils; import net.sourceforge.pmd.PMDVersion; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.rule.Rule; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java index 24e44a4c62..e38119f9f1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java @@ -16,11 +16,11 @@ import org.apache.commons.lang3.StringUtils; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.rule.Rule; /** * Renderer to basic HTML format. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/Rule.java similarity index 98% rename from pmd-core/src/main/java/net/sourceforge/pmd/Rule.java rename to pmd-core/src/main/java/net/sourceforge/pmd/rule/Rule.java index e6ceb8753e..0a8fee6e5b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/Rule.java @@ -2,12 +2,15 @@ * 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.List; 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; 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..d918629299 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 @@ -41,7 +41,6 @@ import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.Node; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.RuleSetReference; import net.sourceforge.pmd.annotation.InternalApi; @@ -57,6 +56,7 @@ 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; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/ResourceLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ResourceLoader.java index d9d4d7e5b0..4ce16d32ef 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/ResourceLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ResourceLoader.java @@ -17,8 +17,8 @@ import java.util.Objects; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.annotation.InternalApi; +import net.sourceforge.pmd.rule.Rule; /** * @deprecated Is internal API diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/PmdCoreTestUtils.java b/pmd-core/src/test/java/net/sourceforge/pmd/PmdCoreTestUtils.java index 45af7d3594..b6e8d747d1 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/PmdCoreTestUtils.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/PmdCoreTestUtils.java @@ -7,6 +7,7 @@ package net.sourceforge.pmd; import net.sourceforge.pmd.lang.Dummy2LanguageModule; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.rule.Rule; /** * Helper methods. diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/ReportTest.java index b3a10c642d..5b3bf0228e 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/ReportTest.java @@ -26,6 +26,7 @@ import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.renderers.XMLRenderer; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; +import net.sourceforge.pmd.rule.Rule; class ReportTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java b/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java index 752d4d580c..fd455f4811 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java @@ -10,6 +10,7 @@ import net.sourceforge.pmd.lang.LanguageProcessorRegistry; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.document.TestMessageReporter; +import net.sourceforge.pmd.rule.Rule; public final class ReportTestUtil { private ReportTestUtil() { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryDuplicatedRuleLoggingTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryDuplicatedRuleLoggingTest.java index 71696847e0..7b2296242b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryDuplicatedRuleLoggingTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryDuplicatedRuleLoggingTest.java @@ -12,6 +12,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; +import net.sourceforge.pmd.rule.Rule; + import com.github.stefanbirkner.systemlambda.SystemLambda; class RuleSetFactoryDuplicatedRuleLoggingTest extends RulesetFactoryTestBase { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryMessagesTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryMessagesTest.java index ed094cac91..5d35ef24aa 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryMessagesTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryMessagesTest.java @@ -12,6 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.rule.MockRule; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; import net.sourceforge.pmd.util.internal.xml.XmlErrorMessages; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java index 541f88b477..80070f3b83 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java @@ -28,6 +28,7 @@ import org.mockito.Mockito; import net.sourceforge.pmd.lang.rule.MockRule; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java index ca94ab2f1f..ce0effc4d0 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java @@ -49,6 +49,7 @@ import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.RuleTargetSelector; +import net.sourceforge.pmd.rule.Rule; class RuleSetTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationComparatorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationComparatorTest.java index 8e431d4a7f..77940a7fc8 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationComparatorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationComparatorTest.java @@ -21,6 +21,7 @@ import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.MockRule; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; +import net.sourceforge.pmd.rule.Rule; class RuleViolationComparatorTest { @@ -71,7 +72,7 @@ class RuleViolationComparatorTest { } private RuleViolation createJavaRuleViolation(Rule rule, String fileName, int beginLine, String description, - int beginColumn, int endLine, int endColumn) { + int beginColumn, int endLine, int endColumn) { FileLocation loc = FileLocation.range(FileId.fromPathLikeString(fileName), TextRange2d.range2d(beginLine, beginColumn, endLine, endColumn)); return new ParametricRuleViolation(rule, loc, description, Collections.emptyMap()); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationTest.java index 278b888d7e..98f0722a6c 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationTest.java @@ -21,6 +21,7 @@ import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.MockRule; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; +import net.sourceforge.pmd.rule.Rule; class RuleViolationTest { 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..33ad66894c 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RulesetFactoryTestBase.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RulesetFactoryTestBase.java @@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory; import org.slf4j.event.Level; import net.sourceforge.pmd.lang.DummyLanguageModule; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.internal.xml.SchemaConstant; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java index 171219ad1f..069f51f48b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java @@ -48,6 +48,7 @@ import net.sourceforge.pmd.lang.document.TextFileContent; import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.reporting.FileAnalysisListener; +import net.sourceforge.pmd.rule.Rule; class FileAnalysisCacheTest { @@ -123,7 +124,7 @@ class FileAnalysisCacheTest { final RuleViolation rv = mock(RuleViolation.class); final TextRange2d textLocation = TextRange2d.range2d(1, 2, 3, 4); when(rv.getLocation()).thenReturn(FileLocation.range(sourceFile.getFileId(), textLocation)); - final net.sourceforge.pmd.Rule rule = mock(net.sourceforge.pmd.Rule.class, Mockito.RETURNS_SMART_NULLS); + final Rule rule = mock(Rule.class, Mockito.RETURNS_SMART_NULLS); when(rule.getLanguage()).thenReturn(mock(Language.class)); when(rv.getRule()).thenReturn(rule); @@ -153,7 +154,7 @@ class FileAnalysisCacheTest { // id is saved into the cache file, and the cache implementation updates the // display name of the violations to match their current display name. - final net.sourceforge.pmd.Rule rule = mock(net.sourceforge.pmd.Rule.class, Mockito.RETURNS_SMART_NULLS); + final Rule rule = mock(Rule.class, Mockito.RETURNS_SMART_NULLS); when(rule.getLanguage()).thenReturn(mock(Language.class)); final TextRange2d textLocation = TextRange2d.range2d(1, 2, 3, 4); @@ -281,7 +282,7 @@ class FileAnalysisCacheTest { // Make sure the auxclasspath file is not empty Files.write(classpathFile.toPath(), "some text".getBytes()); - final net.sourceforge.pmd.Rule r = mock(net.sourceforge.pmd.Rule.class); + final Rule r = mock(Rule.class); when(r.getLanguage()).thenReturn(mock(Language.class)); when(rs.getAllRules()).thenReturn(Collections.singleton(r)); reloadedCache.checkValidity(rs, cl, Collections.emptySet()); @@ -297,7 +298,7 @@ class FileAnalysisCacheTest { final File classpathFile = Files.createTempFile(tempFolder, null, "foo.class").toFile(); when(cl.getURLs()).thenReturn(new URL[] { classpathFile.toURI().toURL(), }); - final net.sourceforge.pmd.Rule r = mock(net.sourceforge.pmd.Rule.class); + final Rule r = mock(Rule.class); when(r.getLanguage()).thenReturn(mock(Language.class)); when(rs.getAllRules()).thenReturn(Collections.singleton(r)); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java index ccbb20cdb2..dd0059fdab 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java @@ -21,6 +21,7 @@ import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; import net.sourceforge.pmd.lang.ast.DummyNodeWithDeprecatedAttribute; import net.sourceforge.pmd.lang.document.TextRegion; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; +import net.sourceforge.pmd.rule.Rule; import com.github.stefanbirkner.systemlambda.SystemLambda; @@ -138,7 +139,7 @@ class XPathRuleTest { assertThat(report.getViolations(), hasSize(1)); } - Report executeRule(net.sourceforge.pmd.Rule rule, DummyNode node) { + Report executeRule(Rule rule, DummyNode node) { return getReportForRuleApply(rule, node); } 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..71e4388659 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 @@ -28,7 +28,6 @@ import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Report.ProcessingError; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.internal.SystemProps; @@ -41,6 +40,7 @@ import net.sourceforge.pmd.lang.ast.RootNode; 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.rule.Rule; import net.sourceforge.pmd.util.ContextedAssertionError; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java index ae266e5a65..a6e7582f5d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java @@ -13,8 +13,8 @@ import java.util.ArrayList; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RulesetFactoryTestBase; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.internal.xml.XmlErrorMessages; /** diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java index 411be7336a..6f16fa705e 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java @@ -25,7 +25,6 @@ import net.sourceforge.pmd.FooRule; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Report.ConfigurationError; import net.sourceforge.pmd.Report.ProcessingError; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.RuleWithProperties; @@ -39,6 +38,7 @@ import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; +import net.sourceforge.pmd.rule.Rule; abstract class AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java index a3b786f8a0..13c8c3d9c2 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java @@ -12,8 +12,8 @@ import java.util.function.Consumer; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.reporting.FileAnalysisListener; +import net.sourceforge.pmd.rule.Rule; import com.github.stefanbirkner.systemlambda.SystemLambda; import com.google.gson.Gson; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java index 414983ad92..894c24fb58 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java @@ -22,11 +22,11 @@ import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.FooRule; import net.sourceforge.pmd.Report.ConfigurationError; import net.sourceforge.pmd.Report.ProcessingError; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.CollectionUtil; class YAHTMLRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java index 71e6fedfc9..70a776bf49 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java @@ -21,7 +21,6 @@ import org.mockito.Mockito; import net.sourceforge.pmd.FooRule; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.cache.AnalysisCache; @@ -29,6 +28,7 @@ import net.sourceforge.pmd.cache.NoopAnalysisCache; import net.sourceforge.pmd.lang.ast.FileAnalysisException; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.document.FileId; +import net.sourceforge.pmd.rule.Rule; class GlobalAnalysisListenerTest { diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java index 8858ba9a69..59c5635a0b 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java @@ -32,7 +32,6 @@ import org.apache.commons.text.StringEscapeUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.RuleSetLoadException; import net.sourceforge.pmd.RuleSetLoader; @@ -42,6 +41,7 @@ import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.rule.Rule; public class RuleDocGenerator { private static final Logger LOG = LoggerFactory.getLogger(RuleDocGenerator.class); diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java index f581ae6776..f4b1d326ea 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java @@ -10,10 +10,10 @@ import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.SystemUtils; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.rule.RuleReference; +import net.sourceforge.pmd.rule.Rule; public final class RuleSetUtils { diff --git a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlJavaRuleTest.java b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlJavaRuleTest.java index 9132774ed7..5a02e639f3 100644 --- a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlJavaRuleTest.java +++ b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlJavaRuleTest.java @@ -11,13 +11,13 @@ import java.util.List; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.html.ast.ASTHtmlElement; import net.sourceforge.pmd.lang.html.ast.HtmlParsingHelper; import net.sourceforge.pmd.lang.html.rule.AbstractHtmlRule; import net.sourceforge.pmd.lang.rule.xpath.Attribute; +import net.sourceforge.pmd.rule.Rule; class HtmlJavaRuleTest { // from https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.js_props_getter diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/AnnotationSuppressionUtil.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/AnnotationSuppressionUtil.java index 48dad01c73..bc8615dd38 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/AnnotationSuppressionUtil.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/AnnotationSuppressionUtil.java @@ -16,7 +16,6 @@ import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Report.SuppressedViolation; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.ViolationSuppressor; import net.sourceforge.pmd.lang.ast.Node; @@ -32,6 +31,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; import net.sourceforge.pmd.lang.java.ast.Annotatable; import net.sourceforge.pmd.lang.java.rule.errorprone.ImplicitSwitchFallThroughRule; import net.sourceforge.pmd.lang.java.types.TypeTestUtil; +import net.sourceforge.pmd.rule.Rule; /** * Helper methods to suppress violations based on annotations. diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/ExcludeLinesTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/ExcludeLinesTest.java index 8a48b275d9..effe537a49 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/ExcludeLinesTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/ExcludeLinesTest.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.java.BaseParserTest; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; +import net.sourceforge.pmd.rule.Rule; class ExcludeLinesTest extends BaseParserTest { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/ReportTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/ReportTest.java index aa2c5ffa50..e4c74ece70 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/ReportTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/ReportTest.java @@ -14,6 +14,7 @@ import java.util.regex.Pattern; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.java.JavaParsingHelper; +import net.sourceforge.pmd.rule.Rule; class ReportTest { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java index 1b8de97629..8d19b6a867 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java @@ -13,7 +13,6 @@ import java.util.List; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.ast.Node; @@ -27,6 +26,7 @@ import net.sourceforge.pmd.lang.rule.xpath.internal.DeprecatedAttrLogger; import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.rule.Rule; /** * @author daniels diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredTest.java index 06c910c7c3..e2fa5092ea 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredTest.java @@ -12,8 +12,8 @@ import java.util.List; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.testframework.PmdRuleTst; class CommentRequiredTest extends PmdRuleTst { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java index 037cb92c30..3010f64656 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java @@ -14,7 +14,6 @@ import java.util.function.Consumer; import org.checkerframework.checker.nullness.qual.NonNull; import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.ast.FileAnalysisException; import net.sourceforge.pmd.lang.ast.test.TestUtilsKt; @@ -24,6 +23,7 @@ import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; +import net.sourceforge.pmd.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFunctionsTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFunctionsTest.java index f1b3883e35..4f5f019e25 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFunctionsTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFunctionsTest.java @@ -10,8 +10,8 @@ import static org.hamcrest.MatcherAssert.assertThat; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase; +import net.sourceforge.pmd.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/HasAnnotationXPathTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/HasAnnotationXPathTest.java index 51e396e4a0..4d41253b87 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/HasAnnotationXPathTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/HasAnnotationXPathTest.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.java.rule.xpath.internal; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Rule; +import net.sourceforge.pmd.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MatchesSignatureXPathTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MatchesSignatureXPathTest.java index 62d4610315..a7e180a6d9 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MatchesSignatureXPathTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MatchesSignatureXPathTest.java @@ -9,10 +9,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase; +import net.sourceforge.pmd.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/NodeIsFunctionTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/NodeIsFunctionTest.java index 58fc98e9f8..70fb0e1e2e 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/NodeIsFunctionTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/NodeIsFunctionTest.java @@ -10,8 +10,8 @@ import static org.hamcrest.MatcherAssert.assertThat; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase; +import net.sourceforge.pmd.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/TypeIsFunctionTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/TypeIsFunctionTest.java index 2f2ceb597a..e626b56a4f 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/TypeIsFunctionTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/TypeIsFunctionTest.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.java.rule.xpath.internal; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Rule; +import net.sourceforge.pmd.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/XPathMetricFunctionTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/XPathMetricFunctionTest.java index 7f7b00b6df..1c1c3b5ca5 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/XPathMetricFunctionTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/XPathMetricFunctionTest.java @@ -9,7 +9,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Rule; +import net.sourceforge.pmd.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-javascript/src/test/java/net/sourceforge/pmd/ReportTest.java b/pmd-javascript/src/test/java/net/sourceforge/pmd/ReportTest.java index afcbe068d3..2d7cd6f5bf 100644 --- a/pmd-javascript/src/test/java/net/sourceforge/pmd/ReportTest.java +++ b/pmd-javascript/src/test/java/net/sourceforge/pmd/ReportTest.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.ecmascript.ast.ASTFunctionNode; import net.sourceforge.pmd.lang.ecmascript.ast.EcmascriptParserTestBase; import net.sourceforge.pmd.lang.ecmascript.rule.AbstractEcmascriptRule; +import net.sourceforge.pmd.rule.Rule; class ReportTest extends EcmascriptParserTestBase { diff --git a/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/ast/XPathJspRuleTest.java b/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/ast/XPathJspRuleTest.java index 0fed9e17ae..3202ba6231 100644 --- a/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/ast/XPathJspRuleTest.java +++ b/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/ast/XPathJspRuleTest.java @@ -9,8 +9,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.rule.Rule; class XPathJspRuleTest extends AbstractJspNodesTst { diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt index 46c3d9b272..6636e487a6 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt @@ -16,6 +16,7 @@ import net.sourceforge.pmd.lang.document.TextDocument import net.sourceforge.pmd.lang.rule.XPathRule import net.sourceforge.pmd.lang.rule.xpath.XPathVersion import net.sourceforge.pmd.reporting.GlobalAnalysisListener +import net.sourceforge.pmd.rule.Rule import java.io.InputStream import java.nio.charset.StandardCharsets import java.nio.file.Files diff --git a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateToCharTest.java b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateToCharTest.java index 430413de15..e795cdacab 100644 --- a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateToCharTest.java +++ b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateToCharTest.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.plsql.rule.errorprone; import java.util.Collections; import java.util.List; -import net.sourceforge.pmd.Rule; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.testframework.PmdRuleTst; class ToDateToCharTest extends PmdRuleTst { diff --git a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateWithoutDateFormatTest.java b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateWithoutDateFormatTest.java index ffa7b579e6..1f2fc9e7b4 100644 --- a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateWithoutDateFormatTest.java +++ b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateWithoutDateFormatTest.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.plsql.rule.errorprone; import java.util.Collections; import java.util.List; -import net.sourceforge.pmd.Rule; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.testframework.PmdRuleTst; class ToDateWithoutDateFormatTest extends PmdRuleTst { diff --git a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToTimestampWithoutDateFormatTest.java b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToTimestampWithoutDateFormatTest.java index fbe970e5af..ad347a7756 100644 --- a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToTimestampWithoutDateFormatTest.java +++ b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToTimestampWithoutDateFormatTest.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.plsql.rule.errorprone; import java.util.Collections; import java.util.List; -import net.sourceforge.pmd.Rule; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.testframework.PmdRuleTst; class ToTimestampWithoutDateFormatTest extends PmdRuleTst { diff --git a/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/BaseTestParserImpl.java b/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/BaseTestParserImpl.java index 86467b06e8..ec32dd3723 100644 --- a/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/BaseTestParserImpl.java +++ b/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/BaseTestParserImpl.java @@ -20,12 +20,12 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertySource; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.test.schema.TestSchemaParser.PmdXmlReporter; import com.github.oowekyala.ooxml.DomUtils; diff --git a/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/RuleTestDescriptor.java b/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/RuleTestDescriptor.java index 01baf8f00c..ee73bdfc5f 100644 --- a/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/RuleTestDescriptor.java +++ b/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/RuleTestDescriptor.java @@ -7,8 +7,8 @@ package net.sourceforge.pmd.test.schema; import java.util.List; import java.util.Properties; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/TestSchemaParser.java b/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/TestSchemaParser.java index 4d1688c940..78b1556f02 100644 --- a/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/TestSchemaParser.java +++ b/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/TestSchemaParser.java @@ -13,8 +13,8 @@ import javax.xml.parsers.ParserConfigurationException; import org.xml.sax.InputSource; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.annotation.Experimental; +import net.sourceforge.pmd.rule.Rule; import com.github.oowekyala.ooxml.messages.NiceXmlMessageSpec; import com.github.oowekyala.ooxml.messages.OoxmlFacade; diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java index dd5f81745c..6b6e04c25b 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java @@ -48,6 +48,7 @@ import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.log.internal.MessageReporterBase; /** diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/PmdRuleTst.java b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/PmdRuleTst.java index dfd7e4fc7c..a614049af2 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/PmdRuleTst.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/PmdRuleTst.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.testframework; import java.util.Collections; import java.util.List; -import net.sourceforge.pmd.Rule; +import net.sourceforge.pmd.rule.Rule; public class PmdRuleTst extends RuleTst { diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java index 546d77c7f2..46443793b2 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java @@ -27,7 +27,6 @@ import org.xml.sax.InputSource; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.RuleSetLoadException; import net.sourceforge.pmd.RuleSetLoader; @@ -38,6 +37,7 @@ import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.renderers.TextRenderer; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.test.schema.RuleTestCollection; import net.sourceforge.pmd.test.schema.RuleTestDescriptor; import net.sourceforge.pmd.test.schema.TestSchemaParser; diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/SimpleAggregatorTst.java b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/SimpleAggregatorTst.java index fc547bf983..ec145ec27a 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/SimpleAggregatorTst.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/SimpleAggregatorTst.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.testframework; import java.util.ArrayList; import java.util.List; -import net.sourceforge.pmd.Rule; +import net.sourceforge.pmd.rule.Rule; /** * Simple setup for a rule unit test, diff --git a/pmd-test/src/test/java/net/sourceforge/pmd/testframework/RuleTstTest.java b/pmd-test/src/test/java/net/sourceforge/pmd/testframework/RuleTstTest.java index 7d19147c12..d0e6c31f6d 100644 --- a/pmd-test/src/test/java/net/sourceforge/pmd/testframework/RuleTstTest.java +++ b/pmd-test/src/test/java/net/sourceforge/pmd/testframework/RuleTstTest.java @@ -16,7 +16,6 @@ import java.util.Collections; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageProcessor; @@ -25,6 +24,7 @@ import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.lang.rule.RuleTargetSelector; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.test.schema.RuleTestDescriptor; class RuleTstTest { diff --git a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/rule/security/VfUnescapeElTest.java b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/rule/security/VfUnescapeElTest.java index b1032c5d26..b9cec819c2 100644 --- a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/rule/security/VfUnescapeElTest.java +++ b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/rule/security/VfUnescapeElTest.java @@ -13,10 +13,10 @@ import java.util.List; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.vf.VFTestUtils; import net.sourceforge.pmd.lang.vf.ast.VfParsingHelper; +import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.testframework.PmdRuleTst; class VfUnescapeElTest extends PmdRuleTst { diff --git a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRuleTest.java b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRuleTest.java index 36bdb5fb49..c7925512b4 100644 --- a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRuleTest.java +++ b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRuleTest.java @@ -9,9 +9,9 @@ import static net.sourceforge.pmd.lang.ast.test.TestUtilsKt.assertSize; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.xml.XmlParsingHelper; +import net.sourceforge.pmd.rule.Rule; class XmlXPathRuleTest { From 9e668c22fc0ce85d354405fce5e8281e15538d1a Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 12 Jan 2024 18:14:04 +0100 Subject: [PATCH 02/23] [core] Move Rule/RuleSet related type into net.sourceforge.pmd.rule Refs #3917 --- docs/pages/release_notes.md | 16 +++++++- .../java/net/sourceforge/pmd/ant/PMDTask.java | 2 +- .../pmd/ant/internal/PMDTaskImpl.java | 4 +- .../pmd/lang/apex/DefaultRulesetTest.java | 6 +-- .../pmd/lang/apex/RuleSetFactoryTest.java | 2 +- .../apex/rule/design/UnusedMethodTest.java | 4 +- .../pmd/cli/commands/internal/PmdCommand.java | 2 +- .../internal/RulePriorityTypeSupport.java | 2 +- .../net/sourceforge/pmd/PMDConfiguration.java | 2 + .../net/sourceforge/pmd/PMDConfiguration.java | 2 + .../java/net/sourceforge/pmd/PmdAnalysis.java | 3 ++ .../pmd/cache/AbstractAnalysisCache.java | 2 +- .../sourceforge/pmd/cache/AnalysisCache.java | 2 +- .../pmd/cache/AnalysisCacheListener.java | 2 +- .../pmd/cache/CachedRuleMapper.java | 2 +- .../pmd/cache/FileAnalysisCache.java | 2 +- .../pmd/cache/NoopAnalysisCache.java | 2 +- .../pmd/lang/LanguageProcessor.java | 2 +- .../pmd/lang/impl/MonoThreadProcessor.java | 2 +- .../pmd/lang/impl/MultiThreadProcessor.java | 2 +- .../pmd/lang/impl/PmdRunnable.java | 2 +- .../pmd/lang/rule/AbstractDelegateRule.java | 2 +- .../pmd/lang/rule/AbstractRule.java | 2 +- .../pmd/lang/rule/RuleReference.java | 4 +- .../lang/rule/internal/RuleApplicator.java | 2 +- .../pmd/properties/PropertyDescriptor.java | 2 +- .../java/net/sourceforge/pmd/rule/Rule.java | 2 - .../pmd/{rules => rule}/RuleFactory.java | 12 ++---- .../pmd/{ => rule}/RulePriority.java | 2 +- .../sourceforge/pmd/{ => rule}/RuleSet.java | 3 +- .../pmd/{ => rule}/RuleSetFactory.java | 7 ++-- .../RuleSetFactoryCompatibility.java | 2 +- .../pmd/{ => rule}/RuleSetLoadException.java | 2 +- .../pmd/{ => rule}/RuleSetLoader.java | 4 +- .../pmd/{ => rule}/RuleSetReference.java | 2 +- .../pmd/{ => rule}/RuleSetReferenceId.java | 14 +++---- .../pmd/{ => rule}/RuleSetWriter.java | 3 +- .../sourceforge/pmd/{ => rule}/RuleSets.java | 3 +- .../net/sourceforge/pmd/AbstractRuleTest.java | 1 + .../net/sourceforge/pmd/PmdAnalysisTest.java | 3 +- .../sourceforge/pmd/PmdConfigurationTest.java | 1 + .../net/sourceforge/pmd/ReportTestUtil.java | 2 + .../pmd/cache/FileAnalysisCacheTest.java | 2 +- .../lang/impl/AbstractPMDProcessorTest.java | 2 +- .../lang/impl/MonoThreadProcessorTest.java | 2 +- .../lang/impl/MultiThreadProcessorTest.java | 2 +- .../sourceforge/pmd/lang/rule/MockRule.java | 2 +- .../lang/rule/MockRuleWithNoProperties.java | 2 +- .../pmd/processor/PmdRunnableTest.java | 2 +- .../pmd/properties/PropertySyntaxTest.java | 2 +- .../pmd/renderers/AbstractRendererTest.java | 2 +- .../reporting/GlobalAnalysisListenerTest.java | 2 +- .../net/sourceforge/pmd/rule/MockRule.java | 24 ++++++++++++ .../pmd/{ => rule}/RuleReferenceTest.java | 2 +- .../RuleSetFactoryCompatibilityTest.java | 2 +- ...leSetFactoryDuplicatedRuleLoggingTest.java | 4 +- .../RuleSetFactoryMessagesTest.java | 3 +- .../pmd/{ => rule}/RuleSetFactoryTest.java | 37 ++++++++++--------- .../{ => rule}/RuleSetReferenceIdTest.java | 2 +- .../pmd/{ => rule}/RuleSetTest.java | 32 ++++------------ .../pmd/{ => rule}/RuleSetWriterTest.java | 6 +-- .../{ => rule}/RulesetFactoryTestBase.java | 5 ++- .../pmd/{ => rule}/TestRuleset1.xml | 8 ++-- .../pmd/{ => rule}/TestRuleset2.xml | 0 .../pmd/{ => rule}/TestRuleset3.xml | 0 .../pmd/{ => rule}/TestRuleset4.xml | 0 .../{ => rule}/external-reference-ruleset.xml | 4 +- .../{rulesets => rule}/reference-ruleset.xml | 20 +++++----- .../pmd/docs/GenerateRuleDocsCmd.java | 4 +- .../pmd/docs/RuleDocGenerator.java | 6 +-- .../sourceforge/pmd/docs/RuleSetUtils.java | 2 +- .../pmd/docs/SidebarGenerator.java | 2 +- .../pmd/docs/RuleDocGeneratorTest.java | 4 +- .../pmd/docs/RuleSetResolverTest.java | 2 +- .../pmd/docs/SidebarGeneratorTest.java | 2 +- .../pmd/lang/html/RuleSetFactoryTest.java | 2 +- .../pmd/lang/java/PMD5RulesetTest.java | 4 +- .../pmd/lang/java/QuickstartRulesetTest.java | 6 +-- .../pmd/lang/java/RuleSetFactoryTest.java | 2 +- .../lang/ecmascript/RuleSetFactoryTest.java | 2 +- .../pmd/lang/jsp/RuleSetFactoryTest.java | 2 +- .../pmd/lang/kotlin/RuleSetFactoryTest.java | 2 +- .../pmd/lang/ast/test/BaseParsingHelper.kt | 1 + .../pmd/lang/modelica/RuleSetFactoryTest.java | 2 +- .../pmd/lang/plsql/RuleSetFactoryTest.java | 2 +- .../pmd/lang/scala/RulesetFactoryTest.java | 2 +- .../pmd/lang/swift/RuleSetFactoryTest.java | 2 +- .../pmd/AbstractLanguageVersionTest.java | 2 + .../AbstractRuleSetFactoryTest.java | 3 +- .../pmd/testframework/RuleTst.java | 6 +-- .../pmd/lang/vf/RuleSetFactoryTest.java | 2 +- .../pmd/lang/vm/RuleSetFactoryTest.java | 2 +- .../pmd/lang/xml/RuleSetFactoryTest.java | 2 +- 93 files changed, 196 insertions(+), 181 deletions(-) rename pmd-core/src/main/java/net/sourceforge/pmd/{rules => rule}/RuleFactory.java (98%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => rule}/RulePriority.java (99%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => rule}/RuleSet.java (99%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => rule}/RuleSetFactory.java (99%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => rule}/RuleSetFactoryCompatibility.java (99%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => rule}/RuleSetLoadException.java (96%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => rule}/RuleSetLoader.java (99%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => rule}/RuleSetReference.java (97%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => rule}/RuleSetReferenceId.java (98%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => rule}/RuleSetWriter.java (99%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => rule}/RuleSets.java (99%) create mode 100644 pmd-core/src/test/java/net/sourceforge/pmd/rule/MockRule.java rename pmd-core/src/test/java/net/sourceforge/pmd/{ => rule}/RuleReferenceTest.java (99%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => rule}/RuleSetFactoryCompatibilityTest.java (99%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => rule}/RuleSetFactoryDuplicatedRuleLoggingTest.java (98%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => rule}/RuleSetFactoryMessagesTest.java (98%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => rule}/RuleSetFactoryTest.java (97%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => rule}/RuleSetReferenceIdTest.java (99%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => rule}/RuleSetTest.java (96%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => rule}/RuleSetWriterTest.java (97%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => rule}/RulesetFactoryTestBase.java (98%) rename pmd-core/src/test/resources/net/sourceforge/pmd/{ => rule}/TestRuleset1.xml (88%) rename pmd-core/src/test/resources/net/sourceforge/pmd/{ => rule}/TestRuleset2.xml (100%) rename pmd-core/src/test/resources/net/sourceforge/pmd/{ => rule}/TestRuleset3.xml (100%) rename pmd-core/src/test/resources/net/sourceforge/pmd/{ => rule}/TestRuleset4.xml (100%) rename pmd-core/src/test/resources/net/sourceforge/pmd/{ => rule}/external-reference-ruleset.xml (87%) rename pmd-core/src/test/resources/net/sourceforge/pmd/{rulesets => rule}/reference-ruleset.xml (65%) rename pmd-test/src/main/java/net/sourceforge/pmd/{ => rule}/AbstractRuleSetFactoryTest.java (99%) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 544d54f101..befd17d68d 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -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** diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java index db10833ff7..215f2929f0 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java @@ -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 diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java index 3bd399fc64..1f48d23553 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java @@ -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 { diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/DefaultRulesetTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/DefaultRulesetTest.java index 3ca9685389..f2b360cba9 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/DefaultRulesetTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/DefaultRulesetTest.java @@ -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; diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/RuleSetFactoryTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/RuleSetFactoryTest.java index fb955369af..38383cb831 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/RuleSetFactoryTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/RuleSetFactoryTest.java @@ -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 diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java index c64c4158db..f6d18cf2da 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java @@ -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; 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..4536ad05c0 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 @@ -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; diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/RulePriorityTypeSupport.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/RulePriorityTypeSupport.java index 48ee080be9..82660c26be 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/RulePriorityTypeSupport.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/RulePriorityTypeSupport.java @@ -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; diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/PMDConfiguration.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/PMDConfiguration.java index 87175d7405..90954321a7 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/PMDConfiguration.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/PMDConfiguration.java @@ -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; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java index b262878dfe..8eaa7de870 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java @@ -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; 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 5293246812..23bac0ab59 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java @@ -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; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java index 7a8b7a9498..21904f6756 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java @@ -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. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java index 2b7e0e1b5a..4eaf19bb27 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java @@ -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. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCacheListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCacheListener.java index 702631244c..af16b0c944 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCacheListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCacheListener.java @@ -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}. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java index 31c41174eb..456abfade1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java @@ -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. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java index b1fcc12ed0..2e2eb73a3c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java @@ -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. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java index ea8896501d..005e408616 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java @@ -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. 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 ccdc14248d..68e6f1de86 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 @@ -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; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java index fe26c289f6..72315336c8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java @@ -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> 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..c115d21415 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 @@ -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; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java index 8059d94e2b..6c085cdfbd 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java @@ -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. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java index a1b2386402..f3f11349e0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java @@ -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. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java index cf7db90d0b..081696930e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java @@ -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 diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java index a0f9b75734..374a26208d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java @@ -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; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java index a1b9f089fd..8036814d7a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java @@ -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; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java index 5bd40d48fb..a8c3d51264 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java @@ -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; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/Rule.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/Rule.java index 0a8fee6e5b..6d2ed5c65d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/Rule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/Rule.java @@ -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; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rules/RuleFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleFactory.java similarity index 98% rename from pmd-core/src/main/java/net/sourceforge/pmd/rules/RuleFactory.java rename to pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleFactory.java index d918629299..4f15ad3420 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rules/RuleFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleFactory.java @@ -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; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RulePriority.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RulePriority.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/RulePriority.java rename to pmd-core/src/main/java/net/sourceforge/pmd/rule/RulePriority.java index 8f8b97996b..08cde9f3ee 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RulePriority.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RulePriority.java @@ -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. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSet.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java rename to pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSet.java index 3f5f149e7b..9c44c29d7e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSet.java @@ -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 diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactory.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java rename to pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactory.java index 81e7b1675a..20a2e1ab7e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactory.java @@ -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 static net.sourceforge.pmd.util.CollectionUtil.setOf; import static net.sourceforge.pmd.util.internal.xml.SchemaConstants.DESCRIPTION; @@ -45,11 +45,10 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; -import net.sourceforge.pmd.RuleSet.RuleSetBuilder; +import net.sourceforge.pmd.PMDVersion; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.rule.RuleReference; -import net.sourceforge.pmd.rule.Rule; -import net.sourceforge.pmd.rules.RuleFactory; +import net.sourceforge.pmd.rule.RuleSet.RuleSetBuilder; import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.StringUtil; import net.sourceforge.pmd.util.internal.xml.PmdXmlReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactoryCompatibility.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactoryCompatibility.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactoryCompatibility.java rename to pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactoryCompatibility.java index 610676a92c..11f2c9c37f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactoryCompatibility.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactoryCompatibility.java @@ -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.text.MessageFormat; import java.util.ArrayList; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetLoadException.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoadException.java similarity index 96% rename from pmd-core/src/main/java/net/sourceforge/pmd/RuleSetLoadException.java rename to pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoadException.java index b83355e1c6..dd4156cceb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetLoadException.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoadException.java @@ -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 org.checkerframework.checker.nullness.qual.NonNull; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoader.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/RuleSetLoader.java rename to pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoader.java index 08032a14b6..9f238348a1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoader.java @@ -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.io.ByteArrayInputStream; import java.io.IOException; @@ -21,10 +21,10 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; -import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.CollectionUtil; import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetReference.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReference.java similarity index 97% rename from pmd-core/src/main/java/net/sourceforge/pmd/RuleSetReference.java rename to pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReference.java index cdc6e5f77c..5e6d7cd3cd 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetReference.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReference.java @@ -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.Collections; import java.util.LinkedHashSet; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReferenceId.java similarity index 98% rename from pmd-core/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java rename to pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReferenceId.java index 7afa4f78b2..c21f7f7254 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReferenceId.java @@ -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.io.File; import java.io.FileNotFoundException; @@ -17,7 +17,6 @@ import java.util.Objects; import org.apache.commons.lang3.StringUtils; 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; @@ -74,11 +73,9 @@ import net.sourceforge.pmd.util.log.MessageReporter; * * * - * @deprecated This is part of the internals of the {@link RuleSetLoader}. + *

Note: This is part of the internals of the {@link RuleSetLoader}. */ -@Deprecated -@InternalApi -public class RuleSetReferenceId { +class RuleSetReferenceId { // todo this class has issues... What is even an "external" ruleset? // terminology and API should be clarified. @@ -99,8 +96,7 @@ public class RuleSetReferenceId { * @throws IllegalArgumentException * If the ID contains a comma character. */ - public RuleSetReferenceId(final String id) { - + RuleSetReferenceId(final String id) { this(id, null, null); } @@ -127,7 +123,7 @@ public class RuleSetReferenceId { * @throws IllegalArgumentException If the ID is not Rule reference when there is an external * RuleSetReferenceId. */ - public RuleSetReferenceId(final String id, final RuleSetReferenceId externalRuleSetReferenceId) { + RuleSetReferenceId(final String id, final RuleSetReferenceId externalRuleSetReferenceId) { this(id, externalRuleSetReferenceId, null); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetWriter.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java rename to pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetWriter.java index 88e3757635..55b24ba0ad 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetWriter.java @@ -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.io.OutputStream; import java.util.HashSet; @@ -40,7 +40,6 @@ import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertySerializer; import net.sourceforge.pmd.properties.PropertySource; import net.sourceforge.pmd.properties.PropertyTypeId; -import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSets.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java rename to pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSets.java index 062c527635..74d696e327 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSets.java @@ -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.Collection; @@ -21,7 +21,6 @@ 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.rule.Rule; import net.sourceforge.pmd.util.log.MessageReporter; /** diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java index bc82f3452c..aa90355377 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java @@ -29,6 +29,7 @@ import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; import net.sourceforge.pmd.reporting.FileAnalysisListener; +import net.sourceforge.pmd.rule.RulePriority; class AbstractRuleTest { 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..4dabeccf99 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java @@ -22,7 +22,6 @@ import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatchers; import org.mockito.Mockito; -import net.sourceforge.pmd.RuleSetTest.MockRule; import net.sourceforge.pmd.lang.Dummy2LanguageModule; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.Language; @@ -33,6 +32,8 @@ 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.rule.MockRule; +import net.sourceforge.pmd.rule.RuleSet; import net.sourceforge.pmd.util.log.MessageReporter; /** diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java index 036a03ee85..8ab1020315 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java @@ -35,6 +35,7 @@ import net.sourceforge.pmd.cache.NoopAnalysisCache; import net.sourceforge.pmd.internal.util.ClasspathClassLoader; import net.sourceforge.pmd.renderers.CSVRenderer; import net.sourceforge.pmd.renderers.Renderer; +import net.sourceforge.pmd.rule.RulePriority; class PmdConfigurationTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java b/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java index fd455f4811..91c56afacb 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java @@ -11,6 +11,8 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.document.TestMessageReporter; import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.rule.RuleSet; +import net.sourceforge.pmd.rule.RuleSets; public final class ReportTestUtil { private ReportTestUtil() { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java index 069f51f48b..b1cf43bf29 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java @@ -36,7 +36,6 @@ import org.junit.jupiter.api.io.TempDir; import org.mockito.Mockito; import net.sourceforge.pmd.PmdCoreTestUtils; -import net.sourceforge.pmd.RuleSets; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageVersion; @@ -49,6 +48,7 @@ import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.rule.RuleSets; class FileAnalysisCacheTest { 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..a4be8f6a8a 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 @@ -17,7 +17,6 @@ import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.RuleContext; -import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageProcessor; @@ -28,6 +27,7 @@ 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.rule.RuleSet; import net.sourceforge.pmd.util.log.MessageReporter; abstract class AbstractPMDProcessorTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java index 755003142b..073ee36199 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; import net.sourceforge.pmd.PmdAnalysis; -import net.sourceforge.pmd.RuleSet; +import net.sourceforge.pmd.rule.RuleSet; class MonoThreadProcessorTest extends AbstractPMDProcessorTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java index 12e381fac1..8feda5a284 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java @@ -15,9 +15,9 @@ import org.mockito.Mockito; import net.sourceforge.pmd.PmdAnalysis; import net.sourceforge.pmd.RuleContext; -import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.rule.RuleSet; class MultiThreadProcessorTest extends AbstractPMDProcessorTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java index e3b760674d..bea03e58ff 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java @@ -7,10 +7,10 @@ package net.sourceforge.pmd.lang.rule; import static net.sourceforge.pmd.properties.NumericConstraints.inRange; import net.sourceforge.pmd.RuleContext; -import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.rule.RulePriority; /** diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java index ec4f081756..891657072a 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java @@ -5,8 +5,8 @@ package net.sourceforge.pmd.lang.rule; import net.sourceforge.pmd.RuleContext; -import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.rule.RulePriority; /** 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 71e4388659..dbfde85c78 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 @@ -29,7 +29,6 @@ import net.sourceforge.pmd.PmdAnalysis; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.RuleContext; -import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.internal.SystemProps; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageRegistry; @@ -41,6 +40,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.rule.Rule; +import net.sourceforge.pmd.rule.RuleSet; import net.sourceforge.pmd.util.ContextedAssertionError; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java index a6e7582f5d..204a1b6bd8 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java @@ -13,8 +13,8 @@ import java.util.ArrayList; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.RulesetFactoryTestBase; import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.rule.RulesetFactoryTestBase; import net.sourceforge.pmd.util.internal.xml.XmlErrorMessages; /** diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java index 6f16fa705e..cb98fafa56 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java @@ -25,7 +25,6 @@ import net.sourceforge.pmd.FooRule; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Report.ConfigurationError; import net.sourceforge.pmd.Report.ProcessingError; -import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.RuleWithProperties; import net.sourceforge.pmd.internal.util.IOUtil; @@ -39,6 +38,7 @@ import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.rule.RulePriority; abstract class AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java index 70a776bf49..3da7d7b0da 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java @@ -22,13 +22,13 @@ import net.sourceforge.pmd.FooRule; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; import net.sourceforge.pmd.RuleContext; -import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.cache.AnalysisCache; import net.sourceforge.pmd.cache.NoopAnalysisCache; import net.sourceforge.pmd.lang.ast.FileAnalysisException; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.rule.RuleSet; class GlobalAnalysisListenerTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/rule/MockRule.java b/pmd-core/src/test/java/net/sourceforge/pmd/rule/MockRule.java new file mode 100644 index 0000000000..93395bc1dc --- /dev/null +++ b/pmd-core/src/test/java/net/sourceforge/pmd/rule/MockRule.java @@ -0,0 +1,24 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.rule; + +import net.sourceforge.pmd.lang.DummyLanguageModule; + +public class MockRule extends net.sourceforge.pmd.lang.rule.MockRule { + public MockRule() { + super(); + setLanguage(DummyLanguageModule.getInstance()); + } + + public MockRule(String name, String description, String message, String ruleSetName, RulePriority priority) { + super(name, description, message, ruleSetName, priority); + setLanguage(DummyLanguageModule.getInstance()); + } + + public MockRule(String name, String description, String message, String ruleSetName) { + super(name, description, message, ruleSetName); + setLanguage(DummyLanguageModule.getInstance()); + } +} diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleReferenceTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleReferenceTest.java similarity index 99% rename from pmd-core/src/test/java/net/sourceforge/pmd/RuleReferenceTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleReferenceTest.java index 038481b979..17f4eacfe3 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleReferenceTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleReferenceTest.java @@ -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 static net.sourceforge.pmd.PmdCoreTestUtils.dummyLanguage; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryCompatibilityTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryCompatibilityTest.java similarity index 99% rename from pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryCompatibilityTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryCompatibilityTest.java index f9e3c089bb..6f46cad48b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryCompatibilityTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryCompatibilityTest.java @@ -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 static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryDuplicatedRuleLoggingTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryDuplicatedRuleLoggingTest.java similarity index 98% rename from pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryDuplicatedRuleLoggingTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryDuplicatedRuleLoggingTest.java index 7b2296242b..e305bfe8c9 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryDuplicatedRuleLoggingTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryDuplicatedRuleLoggingTest.java @@ -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 static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; @@ -12,8 +12,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.rule.Rule; - import com.github.stefanbirkner.systemlambda.SystemLambda; class RuleSetFactoryDuplicatedRuleLoggingTest extends RulesetFactoryTestBase { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryMessagesTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryMessagesTest.java similarity index 98% rename from pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryMessagesTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryMessagesTest.java index 5d35ef24aa..1091ced2de 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryMessagesTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryMessagesTest.java @@ -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 static net.sourceforge.pmd.util.CollectionUtil.listOf; import static org.hamcrest.MatcherAssert.assertThat; @@ -12,7 +12,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.rule.MockRule; -import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; import net.sourceforge.pmd.util.internal.xml.XmlErrorMessages; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryTest.java similarity index 97% rename from pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryTest.java index 80070f3b83..63b8580dfa 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryTest.java @@ -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 static net.sourceforge.pmd.PmdCoreTestUtils.dummyLanguage; import static net.sourceforge.pmd.util.CollectionUtil.listOf; @@ -28,36 +28,37 @@ import org.mockito.Mockito; import net.sourceforge.pmd.lang.rule.MockRule; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.properties.PropertyDescriptor; -import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; import com.github.stefanbirkner.systemlambda.SystemLambda; class RuleSetFactoryTest extends RulesetFactoryTestBase { + private static final String TEST_RULESET_1 = "net/sourceforge/pmd/rule/TestRuleset1.xml"; + private static final String REFERENCE_RULESET = "net/sourceforge/pmd/rule/reference-ruleset.xml"; @Test void testRuleSetFileName() { RuleSet rs = new RuleSetLoader().loadFromString("dummyRuleset.xml", EMPTY_RULESET); assertEquals("dummyRuleset.xml", rs.getFileName()); - rs = new RuleSetLoader().loadFromResource("net/sourceforge/pmd/TestRuleset1.xml"); - assertEquals(rs.getFileName(), "net/sourceforge/pmd/TestRuleset1.xml", "wrong RuleSet file name"); + rs = new RuleSetLoader().loadFromResource(TEST_RULESET_1); + assertEquals(rs.getFileName(), TEST_RULESET_1, "wrong RuleSet file name"); } @Test void testRefs() { - RuleSet rs = new RuleSetLoader().loadFromResource("net/sourceforge/pmd/TestRuleset1.xml"); + RuleSet rs = new RuleSetLoader().loadFromResource(TEST_RULESET_1); assertNotNull(rs.getRuleByName("TestRuleRef")); } @Test void testExtendedReferences() throws Exception { - InputStream in = new ResourceLoader().loadClassPathResourceAsStream("net/sourceforge/pmd/rulesets/reference-ruleset.xml"); + InputStream in = new ResourceLoader().loadClassPathResourceAsStream(REFERENCE_RULESET); assertNotNull(in, "Test ruleset not found - can't continue with test!"); in.close(); - RuleSet rs = new RuleSetLoader().loadFromResource("net/sourceforge/pmd/rulesets/reference-ruleset.xml"); + RuleSet rs = new RuleSetLoader().loadFromResource(REFERENCE_RULESET); // added by referencing a complete ruleset (TestRuleset1.xml) assertNotNull(rs.getRuleByName("MockRule1")); assertNotNull(rs.getRuleByName("MockRule2")); @@ -781,7 +782,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { void testExternalReferences() { RuleSet rs = loadRuleSet( rulesetXml( - ruleRef("net/sourceforge/pmd/external-reference-ruleset.xml/MockRule") + ruleRef("net/sourceforge/pmd/rule/external-reference-ruleset.xml/MockRule") ) ); assertEquals(1, rs.size()); @@ -858,7 +859,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { @Test void testWrongRuleNameReferenced() { assertCannotParse(rulesetXml( - ruleRef("net/sourceforge/pmd/TestRuleset1.xml/ThisRuleDoesNotExist") + ruleRef("net/sourceforge/pmd/rule/TestRuleset1.xml/ThisRuleDoesNotExist") )); } @@ -896,7 +897,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:schemaLocation=\"http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd\">\n" + " Custom ruleset for tests\n" - + " \n" + + " \n" + " \n" + " \n" + "\n"); assertEquals(4, ruleset.getRules().size()); @@ -997,7 +998,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { + " testdesc\n" + " \n" + + " ref=\"net/sourceforge/pmd/rule/TestRuleset1.xml/MockRule1\" message=\"TestMessageOverride\"> \n" + "\n" + " \n" + ""; @@ -1007,14 +1008,14 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { + "\n" + " testdesc\n" + " \n" + + " ref=\"net/sourceforge/pmd/rule/TestRuleset1.xml/FooMockRule1\"> \n" + " \n" + ""; private static final String REF_OVERRIDE_ORIGINAL_NAME_ONE_ELEM = "\n" + "\n" + " testdesc\n" - + " \n" + + " \n" + "\n" + ""; @@ -1022,7 +1023,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { + "\n" + " testdesc\n" + " \n" @@ -1042,7 +1043,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { + "\n" + " testdesc\n" + " \n" @@ -1088,7 +1089,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { + "\n" + + "ref=\"net/sourceforge/pmd/rule/TestRuleset1.xml/MockRule1\"/>\n" + " \n" + ""; @@ -1098,7 +1099,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { + "\n" + + "ref=\"net/sourceforge/pmd/rule/TestRuleset2.xml/TestRule\"/>\n" + " 2 \n" + "\n" + " 1 \n" @@ -1158,7 +1159,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { // Note: Update this RuleSet name to a different RuleSet with deprecated // Rules when the Rules are finally removed. - private static final String DEPRECATED_RULE_RULESET_NAME = "net/sourceforge/pmd/TestRuleset1.xml"; + private static final String DEPRECATED_RULE_RULESET_NAME = "net/sourceforge/pmd/rule/TestRuleset1.xml"; // Note: Update this Rule name to a different deprecated Rule when the one // listed here is finally removed. diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetReferenceIdTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetReferenceIdTest.java similarity index 99% rename from pmd-core/src/test/java/net/sourceforge/pmd/RuleSetReferenceIdTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetReferenceIdTest.java index 4e271dbbba..ac182bb402 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetReferenceIdTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetReferenceIdTest.java @@ -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 static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.findAll; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetTest.java similarity index 96% rename from pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetTest.java index ce0effc4d0..8c29db3399 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetTest.java @@ -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 static net.sourceforge.pmd.PmdCoreTestUtils.dummyLanguage; import static net.sourceforge.pmd.PmdCoreTestUtils.dummyLanguage2; @@ -40,16 +40,19 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import net.sourceforge.pmd.DummyParsingHelper; +import net.sourceforge.pmd.FooRule; +import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Report.ProcessingError; -import net.sourceforge.pmd.RuleSet.RuleSetBuilder; -import net.sourceforge.pmd.lang.DummyLanguageModule; +import net.sourceforge.pmd.RuleContext; +import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.RuleTargetSelector; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.rule.RuleSet.RuleSetBuilder; class RuleSetTest { @@ -573,25 +576,4 @@ class RuleSetTest { assertThat(report.getViolations(), hasSize(1)); } - - - static class MockRule extends net.sourceforge.pmd.lang.rule.MockRule { - - MockRule() { - super(); - setLanguage(DummyLanguageModule.getInstance()); - } - - MockRule(String name, String description, String message, String ruleSetName, RulePriority priority) { - super(name, description, message, ruleSetName, priority); - setLanguage(DummyLanguageModule.getInstance()); - } - - MockRule(String name, String description, String message, String ruleSetName) { - super(name, description, message, ruleSetName); - setLanguage(DummyLanguageModule.getInstance()); - } - - } - } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetWriterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetWriterTest.java similarity index 97% rename from pmd-core/src/test/java/net/sourceforge/pmd/RuleSetWriterTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetWriterTest.java index b762837b10..0772737633 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetWriterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetWriterTest.java @@ -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 static net.sourceforge.pmd.util.CollectionUtil.mapOf; import static org.hamcrest.MatcherAssert.assertThat; @@ -18,9 +18,9 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.RuleSet.RuleSetBuilder; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.XPathRule; +import net.sourceforge.pmd.rule.RuleSet.RuleSetBuilder; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; /** @@ -59,7 +59,7 @@ class RuleSetWriterTest extends RulesetFactoryTestBase { */ @Test void testWrite() throws Exception { - RuleSet braces = new RuleSetLoader().loadFromResource("net/sourceforge/pmd/TestRuleset1.xml"); + RuleSet braces = new RuleSetLoader().loadFromResource("net/sourceforge/pmd/rule/TestRuleset1.xml"); RuleSet ruleSet = new RuleSetBuilder(new Random().nextLong()) .withName("ruleset") .withDescription("ruleset description") diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RulesetFactoryTestBase.java b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RulesetFactoryTestBase.java similarity index 98% rename from pmd-core/src/test/java/net/sourceforge/pmd/RulesetFactoryTestBase.java rename to pmd-core/src/test/java/net/sourceforge/pmd/rule/RulesetFactoryTestBase.java index 33ad66894c..39c078b1a8 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RulesetFactoryTestBase.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RulesetFactoryTestBase.java @@ -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 static net.sourceforge.pmd.util.CollectionUtil.buildMap; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -27,8 +27,9 @@ import org.mockito.verification.VerificationMode; import org.slf4j.LoggerFactory; import org.slf4j.event.Level; +import net.sourceforge.pmd.PMDConfiguration; +import net.sourceforge.pmd.PmdAnalysis; import net.sourceforge.pmd.lang.DummyLanguageModule; -import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.internal.xml.SchemaConstant; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/TestRuleset1.xml b/pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset1.xml similarity index 88% rename from pmd-core/src/test/resources/net/sourceforge/pmd/TestRuleset1.xml rename to pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset1.xml index 8055258242..feb2f9396d 100644 --- a/pmd-core/src/test/resources/net/sourceforge/pmd/TestRuleset1.xml +++ b/pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset1.xml @@ -3,8 +3,8 @@ xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd"> - Ruleset used by test net.sourceforge.pmd.RuleSetWriter and RuleSetFactoryTest - + Ruleset used by test net.sourceforge.pmd.rule.RuleSetWriter and RuleSetFactoryTest + @@ -30,7 +30,7 @@ Just for test - + - + diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/TestRuleset2.xml b/pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset2.xml similarity index 100% rename from pmd-core/src/test/resources/net/sourceforge/pmd/TestRuleset2.xml rename to pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset2.xml diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/TestRuleset3.xml b/pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset3.xml similarity index 100% rename from pmd-core/src/test/resources/net/sourceforge/pmd/TestRuleset3.xml rename to pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset3.xml diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/TestRuleset4.xml b/pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset4.xml similarity index 100% rename from pmd-core/src/test/resources/net/sourceforge/pmd/TestRuleset4.xml rename to pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset4.xml diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/external-reference-ruleset.xml b/pmd-core/src/test/resources/net/sourceforge/pmd/rule/external-reference-ruleset.xml similarity index 87% rename from pmd-core/src/test/resources/net/sourceforge/pmd/external-reference-ruleset.xml rename to pmd-core/src/test/resources/net/sourceforge/pmd/rule/external-reference-ruleset.xml index 6515a57737..d9a32bbb12 100644 --- a/pmd-core/src/test/resources/net/sourceforge/pmd/external-reference-ruleset.xml +++ b/pmd-core/src/test/resources/net/sourceforge/pmd/rule/external-reference-ruleset.xml @@ -3,8 +3,8 @@ xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd"> - Ruleset used by test net.sourceforge.pmd.RuleSetFactoryTest - + Ruleset used by test net.sourceforge.pmd.rule.RuleSetFactoryTest + diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/rulesets/reference-ruleset.xml b/pmd-core/src/test/resources/net/sourceforge/pmd/rule/reference-ruleset.xml similarity index 65% rename from pmd-core/src/test/resources/net/sourceforge/pmd/rulesets/reference-ruleset.xml rename to pmd-core/src/test/resources/net/sourceforge/pmd/rule/reference-ruleset.xml index aff963c994..962d1a8366 100644 --- a/pmd-core/src/test/resources/net/sourceforge/pmd/rulesets/reference-ruleset.xml +++ b/pmd-core/src/test/resources/net/sourceforge/pmd/rule/reference-ruleset.xml @@ -5,45 +5,45 @@ xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd"> - This ruleset checks my code for bad stuff + This ruleset checks my code for bad stuff. Used by net.sourceforge.pmd.rule.RuleSetFactoryTest. - + - + 2 - + - + - + - + 5 - + 2 - \ No newline at end of file + diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java index ebe55f4abd..3eb570bc1b 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java @@ -17,9 +17,9 @@ import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; -import net.sourceforge.pmd.RuleSet; -import net.sourceforge.pmd.RuleSetLoader; import net.sourceforge.pmd.internal.util.IOUtil; +import net.sourceforge.pmd.rule.RuleSet; +import net.sourceforge.pmd.rule.RuleSetLoader; public final class GenerateRuleDocsCmd { diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java index 59c5635a0b..80af73520c 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java @@ -32,9 +32,6 @@ import org.apache.commons.text.StringEscapeUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.RuleSet; -import net.sourceforge.pmd.RuleSetLoadException; -import net.sourceforge.pmd.RuleSetLoader; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; @@ -42,6 +39,9 @@ import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.rule.RuleSet; +import net.sourceforge.pmd.rule.RuleSetLoadException; +import net.sourceforge.pmd.rule.RuleSetLoader; public class RuleDocGenerator { private static final Logger LOG = LoggerFactory.getLogger(RuleDocGenerator.class); diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java index f4b1d326ea..a575efd90a 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java @@ -10,10 +10,10 @@ import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.SystemUtils; -import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.rule.RuleSet; public final class RuleSetUtils { diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/SidebarGenerator.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/SidebarGenerator.java index bcec609c44..d514aac017 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/SidebarGenerator.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/SidebarGenerator.java @@ -25,8 +25,8 @@ import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.SafeConstructor; import org.yaml.snakeyaml.representer.Representer; -import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.lang.Language; +import net.sourceforge.pmd.rule.RuleSet; public class SidebarGenerator { private static final String SIDEBAR_YML = "docs/_data/sidebars/pmd_sidebar.yml"; diff --git a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java index 69665c54b5..726b63120c 100644 --- a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java +++ b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java @@ -19,10 +19,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import net.sourceforge.pmd.RuleSet; -import net.sourceforge.pmd.RuleSetLoader; import net.sourceforge.pmd.docs.MockedFileWriter.FileEntry; import net.sourceforge.pmd.internal.util.IOUtil; +import net.sourceforge.pmd.rule.RuleSet; +import net.sourceforge.pmd.rule.RuleSetLoader; class RuleDocGeneratorTest { diff --git a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java index f5baf81b34..6bfa114a1a 100644 --- a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java +++ b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java @@ -14,8 +14,8 @@ import java.util.List; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.RuleSetLoader; import net.sourceforge.pmd.internal.util.IOUtil; +import net.sourceforge.pmd.rule.RuleSetLoader; class RuleSetResolverTest { diff --git a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java index 8fe3a7d5ef..cdbce4d764 100644 --- a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java +++ b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java @@ -26,10 +26,10 @@ import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.SafeConstructor; import org.yaml.snakeyaml.representer.Representer; -import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; +import net.sourceforge.pmd.rule.RuleSet; class SidebarGeneratorTest { private MockedFileWriter writer = new MockedFileWriter(); diff --git a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/RuleSetFactoryTest.java b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/RuleSetFactoryTest.java index 7205edf858..4e479ff041 100644 --- a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/RuleSetFactoryTest.java +++ b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.html; -import net.sourceforge.pmd.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; class RuleSetFactoryTest extends AbstractRuleSetFactoryTest { // no additional tests yet diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/PMD5RulesetTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/PMD5RulesetTest.java index 9334683d33..25714b6e53 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/PMD5RulesetTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/PMD5RulesetTest.java @@ -9,8 +9,8 @@ import static org.junit.jupiter.api.Assertions.assertNull; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.RuleSet; -import net.sourceforge.pmd.RuleSetLoader; +import net.sourceforge.pmd.rule.RuleSet; +import net.sourceforge.pmd.rule.RuleSetLoader; class PMD5RulesetTest { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/QuickstartRulesetTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/QuickstartRulesetTest.java index 2b7ffdc9fd..eb5b22ef17 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/QuickstartRulesetTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/QuickstartRulesetTest.java @@ -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; diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/RuleSetFactoryTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/RuleSetFactoryTest.java index d6cafa265a..f11518cf1d 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/RuleSetFactoryTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.java; -import net.sourceforge.pmd.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; /** * Test java's rulesets diff --git a/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/RuleSetFactoryTest.java b/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/RuleSetFactoryTest.java index 551b583deb..46a9adae40 100644 --- a/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/RuleSetFactoryTest.java +++ b/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.ecmascript; -import net.sourceforge.pmd.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; /** * Test javascript's rulesets diff --git a/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/RuleSetFactoryTest.java b/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/RuleSetFactoryTest.java index 80b8ecbf7a..df499f7f42 100644 --- a/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/RuleSetFactoryTest.java +++ b/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.jsp; -import net.sourceforge.pmd.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; /** * Test jsp's rulesets diff --git a/pmd-kotlin/src/test/java/net/sourceforge/pmd/lang/kotlin/RuleSetFactoryTest.java b/pmd-kotlin/src/test/java/net/sourceforge/pmd/lang/kotlin/RuleSetFactoryTest.java index 9655674f8a..3faa6b6ab2 100644 --- a/pmd-kotlin/src/test/java/net/sourceforge/pmd/lang/kotlin/RuleSetFactoryTest.java +++ b/pmd-kotlin/src/test/java/net/sourceforge/pmd/lang/kotlin/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.kotlin; -import net.sourceforge.pmd.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; class RuleSetFactoryTest extends AbstractRuleSetFactoryTest { // no additional tests yet diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt index 6636e487a6..4b00719190 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt @@ -17,6 +17,7 @@ import net.sourceforge.pmd.lang.rule.XPathRule import net.sourceforge.pmd.lang.rule.xpath.XPathVersion import net.sourceforge.pmd.reporting.GlobalAnalysisListener import net.sourceforge.pmd.rule.Rule +import net.sourceforge.pmd.rule.RuleSet import java.io.InputStream import java.nio.charset.StandardCharsets import java.nio.file.Files diff --git a/pmd-modelica/src/test/java/net/sourceforge/pmd/lang/modelica/RuleSetFactoryTest.java b/pmd-modelica/src/test/java/net/sourceforge/pmd/lang/modelica/RuleSetFactoryTest.java index d515ff6597..6932fa08a1 100644 --- a/pmd-modelica/src/test/java/net/sourceforge/pmd/lang/modelica/RuleSetFactoryTest.java +++ b/pmd-modelica/src/test/java/net/sourceforge/pmd/lang/modelica/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.modelica; -import net.sourceforge.pmd.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; class RuleSetFactoryTest extends AbstractRuleSetFactoryTest { // no additional tests yet diff --git a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/RuleSetFactoryTest.java b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/RuleSetFactoryTest.java index 2fa3b962eb..59518c00bd 100644 --- a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/RuleSetFactoryTest.java +++ b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.plsql; -import net.sourceforge.pmd.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; /** * Test plsql's rulesets diff --git a/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/RulesetFactoryTest.java b/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/RulesetFactoryTest.java index ff8a253296..93ac55200c 100644 --- a/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/RulesetFactoryTest.java +++ b/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/RulesetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.scala; -import net.sourceforge.pmd.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; /** * Test scala rulesets diff --git a/pmd-swift/src/test/java/net/sourceforge/pmd/lang/swift/RuleSetFactoryTest.java b/pmd-swift/src/test/java/net/sourceforge/pmd/lang/swift/RuleSetFactoryTest.java index f800ac2bea..bd9fb82f51 100644 --- a/pmd-swift/src/test/java/net/sourceforge/pmd/lang/swift/RuleSetFactoryTest.java +++ b/pmd-swift/src/test/java/net/sourceforge/pmd/lang/swift/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.swift; -import net.sourceforge.pmd.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; class RuleSetFactoryTest extends AbstractRuleSetFactoryTest { // no additional unit tests diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractLanguageVersionTest.java b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractLanguageVersionTest.java index 54f0b83b6f..c3eed72f00 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractLanguageVersionTest.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractLanguageVersionTest.java @@ -19,6 +19,8 @@ import net.sourceforge.pmd.ant.SourceLanguage; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.rule.RuleSet; +import net.sourceforge.pmd.rule.RuleSetLoader; /** * Base test class for {@link LanguageVersion} implementations.
diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java b/pmd-test/src/main/java/net/sourceforge/pmd/rule/AbstractRuleSetFactoryTest.java similarity index 99% rename from pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java rename to pmd-test/src/main/java/net/sourceforge/pmd/rule/AbstractRuleSetFactoryTest.java index 6b6e04c25b..067e1cd78a 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/rule/AbstractRuleSetFactoryTest.java @@ -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 static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.emptyString; @@ -48,7 +48,6 @@ import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.properties.PropertyDescriptor; -import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.log.internal.MessageReporterBase; /** diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java index 46443793b2..08d48ff1e7 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java @@ -27,9 +27,6 @@ import org.xml.sax.InputSource; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleSet; -import net.sourceforge.pmd.RuleSetLoadException; -import net.sourceforge.pmd.RuleSetLoader; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.document.FileId; @@ -38,6 +35,9 @@ import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.renderers.TextRenderer; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.rule.RuleSet; +import net.sourceforge.pmd.rule.RuleSetLoadException; +import net.sourceforge.pmd.rule.RuleSetLoader; import net.sourceforge.pmd.test.schema.RuleTestCollection; import net.sourceforge.pmd.test.schema.RuleTestDescriptor; import net.sourceforge.pmd.test.schema.TestSchemaParser; diff --git a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/RuleSetFactoryTest.java b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/RuleSetFactoryTest.java index 3b020f99b1..ff5782044f 100644 --- a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/RuleSetFactoryTest.java +++ b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/RuleSetFactoryTest.java @@ -4,8 +4,8 @@ package net.sourceforge.pmd.lang.vf; -import net.sourceforge.pmd.AbstractRuleSetFactoryTest; import net.sourceforge.pmd.lang.apex.ApexLanguageModule; +import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; class RuleSetFactoryTest extends AbstractRuleSetFactoryTest { RuleSetFactoryTest() { diff --git a/pmd-vm/src/test/java/net/sourceforge/pmd/lang/vm/RuleSetFactoryTest.java b/pmd-vm/src/test/java/net/sourceforge/pmd/lang/vm/RuleSetFactoryTest.java index 75037cd663..987532babc 100644 --- a/pmd-vm/src/test/java/net/sourceforge/pmd/lang/vm/RuleSetFactoryTest.java +++ b/pmd-vm/src/test/java/net/sourceforge/pmd/lang/vm/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.vm; -import net.sourceforge.pmd.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; /** * Test velocity's rulesets. diff --git a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/RuleSetFactoryTest.java b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/RuleSetFactoryTest.java index b2c4b70e68..9b9934c738 100644 --- a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/RuleSetFactoryTest.java +++ b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.xml; -import net.sourceforge.pmd.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; /** * Test xml's and xslt's rulesets From 301678fe01b0cd10a2723e296b71b395132ba3e3 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 13 Jan 2024 18:00:08 +0100 Subject: [PATCH 03/23] [compat6] Make maven-pmd-plugin work again Provide some extra bridge methods for backwards compatible getter, e.g. RuleViolation#getRule() or PMDConfiguration#getMinimumPriority() --- docs/pages/release_notes.md | 2 +- pmd-compat6/pom.xml | 14 + .../src/it/pmd-for-java/invoker.properties | 2 +- .../net/sourceforge/pmd/PMDConfiguration.java | 16 +- .../main/java/net/sourceforge/pmd/Rule.java | 316 +++++++++++++++++- .../net/sourceforge/pmd/RulePriority.java | 136 ++++++++ .../sourceforge/pmd/RuleSetLoadException.java | 17 + .../net/sourceforge/pmd/RuleSetLoader.java | 32 ++ .../sourceforge/pmd/RuleSetReferenceId.java | 15 + .../net/sourceforge/pmd/RuleViolation.java | 11 +- .../sourceforge/pmd/cpd/JavaTokenizer.java | 6 +- .../sourceforge/pmd/cpd/LanguageFactory.java | 22 ++ .../java/net/sourceforge/pmd/rule/Rule.java | 11 + .../pmd/rule/RuleSetLoadException.java | 2 +- .../pmd/rule/RuleSetReferenceId.java | 11 +- 15 files changed, 597 insertions(+), 16 deletions(-) create mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/RulePriority.java create mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoadException.java create mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoader.java create mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java create mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/LanguageFactory.java create mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/rule/Rule.java diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index befd17d68d..61139b3a22 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -163,7 +163,7 @@ in the Migration Guide. * {%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.RuleSetReferenceId %} (note: this is _not_ public API) * {%jdoc core::rule.RuleSets %} (note: this is _not_ public API) * {%jdoc core::rule.RuleSetWriter %} diff --git a/pmd-compat6/pom.xml b/pmd-compat6/pom.xml index 9f682a8768..10d2fc34c3 100644 --- a/pmd-compat6/pom.xml +++ b/pmd-compat6/pom.xml @@ -43,6 +43,20 @@ + + org.jboss.bridger + bridger + 1.6.Final + + + weave + process-classes + + transform + + + + org.apache.maven.plugins maven-invoker-plugin diff --git a/pmd-compat6/src/it/pmd-for-java/invoker.properties b/pmd-compat6/src/it/pmd-for-java/invoker.properties index bfaaa1661c..d03166a079 100644 --- a/pmd-compat6/src/it/pmd-for-java/invoker.properties +++ b/pmd-compat6/src/it/pmd-for-java/invoker.properties @@ -1,4 +1,4 @@ -invoker.goals.1 = verify +invoker.goals.1 = verify -e invoker.goals.2 = pmd:check -Dformat=csv invoker.goals.3 = pmd:check -Dformat=txt invoker.buildResult = failure diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/PMDConfiguration.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/PMDConfiguration.java index 90954321a7..34d4665b93 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/PMDConfiguration.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/PMDConfiguration.java @@ -3,7 +3,10 @@ */ // This class has been taken from 7.0.0-SNAPSHOT -// Changes: setSourceEncoding +// Changes: +// - setSourceEncoding +// - setBenchmark (non-functional) +// - getMinimumPriority package net.sourceforge.pmd; @@ -32,7 +35,6 @@ 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; @@ -587,4 +589,14 @@ public class PMDConfiguration extends AbstractConfiguration { public void setSourceEncoding(String sourceEncoding) { setSourceEncoding(Charset.forName(Objects.requireNonNull(sourceEncoding))); } + + @Deprecated + public void setBenchmark(boolean benchmark) { + // ignored + } + + // new method to be compatible with PMD 7 - RulePriority has changed package + public net.sourceforge.pmd.rule.RulePriority getMinimumPriority$$bridge() { // SUPPRESS CHECKSTYLE ignore + return minimumPriority.asPMD7RulePriority(); + } } diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java index 75f293395c..8dcd4d8aaf 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java @@ -1,8 +1,320 @@ -/* +/** * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ +// Old version of this class. In PMD 7, this has been moved into sub-package "rule". +// Changes: +// - deepCopy + package net.sourceforge.pmd; -public interface Rule extends net.sourceforge.pmd.rule.Rule { +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; + +import net.sourceforge.pmd.lang.Language; +import net.sourceforge.pmd.lang.LanguageProcessor; +import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.rule.RuleTargetSelector; +import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.properties.PropertySource; +import net.sourceforge.pmd.rule.RulePriority; +import net.sourceforge.pmd.rule.RuleSet; + +/** + * This is the basic Rule interface for PMD rules. + * + *

+ * Thread safety: PMD will create one instance of a rule per + * thread. The instances are not shared across different threads. However, a + * single rule instance is reused for analyzing multiple files. + *

+ */ +public interface Rule extends PropertySource { + + // TODO these should not be properties + + /** + * The property descriptor to universally suppress violations with messages + * matching a regular expression. + */ + PropertyDescriptor> VIOLATION_SUPPRESS_REGEX_DESCRIPTOR = + PropertyFactory.regexProperty("violationSuppressRegex") + .desc("Suppress violations with messages matching a regular expression") + .toOptional("") + .defaultValue(Optional.empty()) + .build(); + + /** + * Name of the property to universally suppress violations on nodes which + * match a given relative XPath expression. + */ + PropertyDescriptor> VIOLATION_SUPPRESS_XPATH_DESCRIPTOR = + PropertyFactory.stringProperty("violationSuppressXPath") + .desc("Suppress violations on nodes which match a given relative XPath expression.") + .toOptional("") + .defaultValue(Optional.empty()) + .build(); + + /** + * Get the Language of this Rule. + * + * @return the language + */ + Language getLanguage(); + + /** + * Set the Language of this Rule. + * + * @param language + * the language + */ + void setLanguage(Language language); + + /** + * Get the minimum LanguageVersion to which this Rule applies. If this value + * is null it indicates there is no minimum bound. + * + * @return the minimum language version + */ + LanguageVersion getMinimumLanguageVersion(); + + /** + * Set the minimum LanguageVersion to which this Rule applies. + * + * @param minimumLanguageVersion + * the minimum language version + */ + void setMinimumLanguageVersion(LanguageVersion minimumLanguageVersion); + + /** + * Get the maximum LanguageVersion to which this Rule applies. If this value + * is null it indicates there is no maximum bound. + * + * @return the maximum language version + */ + LanguageVersion getMaximumLanguageVersion(); + + /** + * Set the maximum LanguageVersion to which this Rule applies. + * + * @param maximumLanguageVersion + * the maximum language version + */ + void setMaximumLanguageVersion(LanguageVersion maximumLanguageVersion); + + /** + * Gets whether this Rule is deprecated. A deprecated Rule is one which: + *
    + *
  • is scheduled for removal in a future version of PMD
  • + *
  • or, has been removed and replaced with a non-functioning place-holder + * and will be completely removed in a future version of PMD
  • + *
  • or, has been renamed/moved and the old name will be completely + * removed in a future version of PMD
  • + *
+ * + * @return true if this rule is deprecated + */ + boolean isDeprecated(); + + /** + * Sets whether this Rule is deprecated. + * + * @param deprecated + * whether this rule is deprecated + */ + void setDeprecated(boolean deprecated); + + /** + * Get the name of this Rule. + * + * @return the name + */ + @Override + String getName(); + + /** + * Set the name of this Rule. + * + * @param name + * the name + */ + void setName(String name); + + /** + * Get the version of PMD in which this Rule was added. Return + * null if not applicable. + * + * @return version of PMD since when this rule was added + */ + String getSince(); + + /** + * Set the version of PMD in which this Rule was added. + * + * @param since + * the version of PMD since when this rule was added + */ + void setSince(String since); + + /** + * Get the implementation class of this Rule. + * + * @return the implementation class name of this rule. + */ + String getRuleClass(); + + /** + * Set the class of this Rule. + * + * @param ruleClass + * the class name of this rule. + */ + void setRuleClass(String ruleClass); + + /** + * Get the name of the RuleSet containing this Rule. + * + * @return the name of th ruleset containing this rule. + * @see RuleSet + */ + String getRuleSetName(); + + /** + * Set the name of the RuleSet containing this Rule. + * + * @param name + * the name of the ruleset containing this rule. + * @see RuleSet + */ + void setRuleSetName(String name); + + /** + * Get the message to show when this Rule identifies a violation. + * + * @return the message to show for a violation. + */ + String getMessage(); + + /** + * Set the message to show when this Rule identifies a violation. + * + * @param message + * the message to show for a violation. + */ + void setMessage(String message); + + /** + * Get the description of this Rule. + * + * @return the description + */ + String getDescription(); + + /** + * Set the description of this Rule. + * + * @param description + * the description + */ + void setDescription(String description); + + /** + * Get the list of examples for this Rule. + * + * @return the list of examples for this rule. + */ + List getExamples(); + + /** + * Add a single example for this Rule. + * + * @param example + * a single example to add + */ + void addExample(String example); + + /** + * Get a URL for external information about this Rule. + * + * @return the URL for external information about this rule. + */ + String getExternalInfoUrl(); + + /** + * Set a URL for external information about this Rule. + * + * @param externalInfoUrl + * the URL for external information about this rule. + */ + void setExternalInfoUrl(String externalInfoUrl); + + /** + * Get the priority of this Rule. + * + * @return the priority + */ + RulePriority getPriority(); + + /** + * Set the priority of this Rule. + * + * @param priority + * the priority + */ + void setPriority(RulePriority priority); + + + /** + * Returns the object that selects the nodes to which this rule applies. + * The selected nodes will be handed to {@link #apply(Node, RuleContext)}. + */ + RuleTargetSelector getTargetSelector(); + + /** + * Initialize the rule using the language processor if needed. + * + * @param languageProcessor The processor for the rule's language + */ + default void initialize(LanguageProcessor languageProcessor) { + // by default do nothing + } + + /** + * Start processing. Called once per file, before apply() is first called. + * + * @param ctx the rule context + */ + void start(RuleContext ctx); + + + /** + * Process the given node. The nodes that are fed to this method + * are the nodes selected by {@link #getTargetSelector()}. + * + * @param target Node on which to apply the rule + * @param ctx Rule context, handling violations + */ + void apply(Node target, RuleContext ctx); + + /** + * End processing. Called once per file, after apply() is last called. + * + * @param ctx + * the rule context + */ + void end(RuleContext ctx); + + /** + * Creates a new copy of this rule. + * @return A new exact copy of this rule + */ + net.sourceforge.pmd.rule.Rule deepCopy(); + + // new method to be compatible with PMD 6 - Rule has changed package + default Rule deepCopy$$bridge() { // SUPPRESS CHECKSTYLE ignore + return deepCopy(); + } } diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/RulePriority.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/RulePriority.java new file mode 100644 index 0000000000..3e35b306ad --- /dev/null +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/RulePriority.java @@ -0,0 +1,136 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +// Copy of net.sourceforge.pmd.rule.RulePriority +// Added method: +// - asPMD7RulePriority + +package net.sourceforge.pmd; + +/** + * These are the possible Rule priority values. + * + * For backward compatibility, priorities range in value from 1 to 5, with 5 + * being the lowest priority. This means the ordinal value of the Enum should be + * avoided in favor of {@link RulePriority#getPriority()} and + * {@link RulePriority#valueOf(int)} + * + * @see How + * to define rules priority + */ +public enum RulePriority { + + /** High: Change absolutely required. Behavior is critically broken/buggy */ + HIGH(1, "High"), + /** + * Medium to high: Change highly recommended. Behavior is quite likely to be + * broken/buggy. + */ + MEDIUM_HIGH(2, "Medium High"), + /** + * Medium: Change recommended. Behavior is confusing, perhaps buggy, and/or + * against standards/best practices. + */ + MEDIUM(3, "Medium"), + /** + * Medium to low: Change optional. Behavior is not likely to be buggy, but + * more just flies in the face of standards/style/good taste. + */ + MEDIUM_LOW(4, "Medium Low"), + /** + * Low: Change highly optional. Nice to have, such as a consistent naming + * policy for package/class/fields... + */ + LOW(5, "Low"); + + private final int priority; + private final String name; + + RulePriority(int priority, String name) { + this.priority = priority; + this.name = name; + } + + /** + * Get the priority value as a number. This is the value to be used in the + * externalized form of a priority (e.g. in RuleSet XML). + * + * @return The int value of the priority. + */ + public int getPriority() { + return priority; + } + + /** + * Get the descriptive name of this priority. + * + * @return The descriptive name. + */ + public String getName() { + return name; + } + + /** + * Returns the descriptive name of the priority. + * + * @return descriptive name of the priority + * @see #getName() + */ + @Override + public String toString() { + return name; + } + + /** + * Get the priority which corresponds to the given number as returned by + * {@link RulePriority#getPriority()}. If the number is an invalid value, + * then {@link RulePriority#LOW} will be returned. + * + * @param priority + * The numeric priority value. + * @return The priority. + */ + public static RulePriority valueOf(int priority) { + try { + return RulePriority.values()[priority - 1]; + } catch (ArrayIndexOutOfBoundsException e) { + return LOW; + } + } + + /** + * Returns the priority which corresponds to the given number as returned by + * {@link RulePriority#getPriority()}. If the number is an invalid value, + * then null will be returned. + * + * @param priority The numeric priority value. + */ + public static RulePriority valueOfNullable(int priority) { + try { + return RulePriority.values()[priority - 1]; + } catch (ArrayIndexOutOfBoundsException e) { + return null; + } + } + + /** + * Returns the priority which corresponds to the given number as returned by + * {@link RulePriority#getPriority()}. If the number is an invalid value, + * then null will be returned. + * + * @param priority The numeric priority value. + */ + public static RulePriority valueOfNullable(String priority) { + try { + int integer = Integer.parseInt(priority); + return RulePriority.values()[integer - 1]; + } catch (ArrayIndexOutOfBoundsException | NumberFormatException e) { + return null; + } + } + + public net.sourceforge.pmd.rule.RulePriority asPMD7RulePriority() { + return net.sourceforge.pmd.rule.RulePriority.valueOf(name()); + } +} diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoadException.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoadException.java new file mode 100644 index 0000000000..db5d0b76fb --- /dev/null +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoadException.java @@ -0,0 +1,17 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd; + +import org.checkerframework.checker.nullness.qual.NonNull; + +public class RuleSetLoadException extends net.sourceforge.pmd.rule.RuleSetLoadException { + public RuleSetLoadException(RuleSetReferenceId rsetId, @NonNull Throwable cause) { + super(rsetId, cause); + } + + public RuleSetLoadException(RuleSetReferenceId rsetId, String message) { + super(rsetId, message); + } +} diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoader.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoader.java new file mode 100644 index 0000000000..00f73ad2fa --- /dev/null +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoader.java @@ -0,0 +1,32 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +// Copy from PMD 7 with minimized functionality. +// Only the methods called by maven-pmd-plugin are kept, +// but they do nothing. That means, that maven-pmd-plugin can't report deprecated +// rules properly anymore. +// The ruleset for actual PMD analysis is loaded by PMD itself later on, and not +// through this class. + +package net.sourceforge.pmd; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import net.sourceforge.pmd.rule.RuleSet; + +public final class RuleSetLoader { + public RuleSetLoader warnDeprecated(boolean warn) { + return this; + } + + public List loadFromResources(Collection paths) { + return Collections.emptyList(); + } + + public static RuleSetLoader fromPmdConfig(PMDConfiguration configuration) { + return new RuleSetLoader(); + } +} diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java new file mode 100644 index 0000000000..39eebb0963 --- /dev/null +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java @@ -0,0 +1,15 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd; + +public class RuleSetReferenceId extends net.sourceforge.pmd.rule.RuleSetReferenceId { + public RuleSetReferenceId(String id) { + super(id); + } + + public RuleSetReferenceId(String id, RuleSetReferenceId externalRuleSetReferenceId) { + super(id, externalRuleSetReferenceId); + } +} diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleViolation.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleViolation.java index dcb3030052..0664b0fc34 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleViolation.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleViolation.java @@ -3,7 +3,9 @@ */ // This class has been taken from 7.0.0-SNAPSHOT -// Changes: getFilename +// Changes: +// - getFilename +// - getRule returns n.s.pmd.rule.Rule or the old n.s.pmd.Rule package net.sourceforge.pmd; @@ -68,7 +70,7 @@ public interface RuleViolation { * * @return The identifying Rule. */ - Rule getRule(); + net.sourceforge.pmd.rule.Rule getRule(); /** * Get the description of this violation. @@ -193,4 +195,9 @@ public interface RuleViolation { default String getFilename() { return getLocation().getFileId().getFileName(); } + + // returns the PMD 6 compatible Rule + default net.sourceforge.pmd.Rule getRule$$bridge() { // SUPPRESS CHECKSTYLE ignore + return getRule(); + } } diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/JavaTokenizer.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/JavaTokenizer.java index 113663cffa..51bea914d5 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/JavaTokenizer.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/JavaTokenizer.java @@ -14,9 +14,9 @@ public class JavaTokenizer extends net.sourceforge.pmd.lang.java.cpd.JavaTokeniz super(convertLanguageProperties(properties)); } - private static final String IGNORE_LITERALS = "ignore_literals"; - private static final String IGNORE_IDENTIFIERS = "ignore_identifiers"; - private static final String IGNORE_ANNOTATIONS = "ignore_annotations"; + public static final String IGNORE_LITERALS = "ignore_literals"; + public static final String IGNORE_IDENTIFIERS = "ignore_identifiers"; + public static final String IGNORE_ANNOTATIONS = "ignore_annotations"; private static JavaLanguageProperties convertLanguageProperties(Properties properties) { boolean ignoreAnnotations = Boolean.parseBoolean(properties.getProperty(IGNORE_ANNOTATIONS, "false")); diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/LanguageFactory.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/LanguageFactory.java new file mode 100644 index 0000000000..09769cd57b --- /dev/null +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/cpd/LanguageFactory.java @@ -0,0 +1,22 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +// This class is here just to make maven-pmd-plugin compile with +// pmd 7.0.0 including this compat6 module. +// It would only be used, if a custom language (other than java, jsp or javascript) +// would be requested. + +package net.sourceforge.pmd.cpd; + +import java.util.Properties; + +public final class LanguageFactory { + private LanguageFactory() { + // utility class + } + + public static Language createLanguage(String name, Properties properties) { + throw new UnsupportedOperationException(); + } +} diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/rule/Rule.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/rule/Rule.java new file mode 100644 index 0000000000..b24bd39487 --- /dev/null +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/rule/Rule.java @@ -0,0 +1,11 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +// The class net.sourceforge.pmd.Rule has been moved into sub-package rule +// in 7.0.0-SNAPSHOT. All rules should be interchangeable. + +package net.sourceforge.pmd.rule; + +public interface Rule extends net.sourceforge.pmd.Rule { +} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoadException.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoadException.java index dd4156cceb..f61b2d849b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoadException.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoadException.java @@ -14,7 +14,7 @@ import net.sourceforge.pmd.annotation.InternalApi; * XML is not well-formed, does not respect the ruleset schema, is * not a valid ruleset or is otherwise unparsable. */ -public final class RuleSetLoadException extends RuntimeException { +public class RuleSetLoadException extends RuntimeException { /** Constructors are internal. */ @InternalApi diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReferenceId.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReferenceId.java index c21f7f7254..65bcf72f00 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReferenceId.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReferenceId.java @@ -17,6 +17,7 @@ import java.util.Objects; import org.apache.commons.lang3.StringUtils; 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; @@ -73,9 +74,11 @@ import net.sourceforge.pmd.util.log.MessageReporter; * * * - *

Note: This is part of the internals of the {@link RuleSetLoader}. + * @deprecated This is part of the internals of the {@link RuleSetLoader}. */ -class RuleSetReferenceId { +@Deprecated +@InternalApi +public class RuleSetReferenceId { // todo this class has issues... What is even an "external" ruleset? // terminology and API should be clarified. @@ -96,7 +99,7 @@ class RuleSetReferenceId { * @throws IllegalArgumentException * If the ID contains a comma character. */ - RuleSetReferenceId(final String id) { + public RuleSetReferenceId(final String id) { this(id, null, null); } @@ -123,7 +126,7 @@ class RuleSetReferenceId { * @throws IllegalArgumentException If the ID is not Rule reference when there is an external * RuleSetReferenceId. */ - RuleSetReferenceId(final String id, final RuleSetReferenceId externalRuleSetReferenceId) { + public RuleSetReferenceId(final String id, final RuleSetReferenceId externalRuleSetReferenceId) { this(id, externalRuleSetReferenceId, null); } From 2461a4d00eb64fccfdee29ec1e60d60f6b8aa8ae Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 13 Jan 2024 18:50:29 +0100 Subject: [PATCH 04/23] [core] Move RuleSets/RuleSetReference into internal sub-package --- docs/pages/release_notes.md | 16 ++++++++++++---- .../net/sourceforge/pmd/RuleSetReferenceId.java | 2 +- .../java/net/sourceforge/pmd/PmdAnalysis.java | 2 +- .../pmd/cache/AbstractAnalysisCache.java | 2 +- .../net/sourceforge/pmd/cache/AnalysisCache.java | 2 +- .../pmd/cache/AnalysisCacheListener.java | 2 +- .../sourceforge/pmd/cache/CachedRuleMapper.java | 2 +- .../sourceforge/pmd/cache/FileAnalysisCache.java | 2 +- .../sourceforge/pmd/cache/NoopAnalysisCache.java | 2 +- .../sourceforge/pmd/lang/LanguageProcessor.java | 2 +- .../pmd/lang/impl/MonoThreadProcessor.java | 2 +- .../pmd/lang/impl/MultiThreadProcessor.java | 2 +- .../sourceforge/pmd/lang/impl/PmdRunnable.java | 2 +- .../sourceforge/pmd/lang/rule/RuleReference.java | 2 +- .../java/net/sourceforge/pmd/package-info.java | 11 +++++++++++ .../main/java/net/sourceforge/pmd/package.html | 12 ------------ .../net/sourceforge/pmd/rule/RuleFactory.java | 1 + .../java/net/sourceforge/pmd/rule/RuleSet.java | 4 +++- .../net/sourceforge/pmd/rule/RuleSetFactory.java | 2 ++ .../pmd/rule/RuleSetLoadException.java | 1 + .../net/sourceforge/pmd/rule/RuleSetLoader.java | 1 + .../net/sourceforge/pmd/rule/RuleSetWriter.java | 1 + .../rule/{ => internal}/RuleSetReference.java | 8 +++----- .../rule/{ => internal}/RuleSetReferenceId.java | 14 ++++++-------- .../pmd/rule/{ => internal}/RuleSets.java | 9 +++------ .../net/sourceforge/pmd/rule/package-info.java | 9 +++++++++ .../java/net/sourceforge/pmd/ReportTestUtil.java | 2 +- .../pmd/cache/FileAnalysisCacheTest.java | 2 +- .../sourceforge/pmd/rule/RuleReferenceTest.java | 1 + .../net/sourceforge/pmd/rule/RuleSetTest.java | 1 + .../sourceforge/pmd/rule/RuleSetWriterTest.java | 1 + .../{ => internal}/RuleSetReferenceIdTest.java | 2 +- 32 files changed, 72 insertions(+), 52 deletions(-) create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/package-info.java delete mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/package.html rename pmd-core/src/main/java/net/sourceforge/pmd/rule/{ => internal}/RuleSetReference.java (86%) rename pmd-core/src/main/java/net/sourceforge/pmd/rule/{ => internal}/RuleSetReferenceId.java (98%) rename pmd-core/src/main/java/net/sourceforge/pmd/rule/{ => internal}/RuleSets.java (97%) create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/rule/package-info.java rename pmd-core/src/test/java/net/sourceforge/pmd/rule/{ => internal}/RuleSetReferenceIdTest.java (99%) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 61139b3a22..9dcfe7ea9a 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -152,21 +152,29 @@ in the Migration Guide. #### API Changes **Moved classes/consolidated packages** + * pmd-core * 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 %} (note: this is _not_ public API) - * {%jdoc core::rule.RuleSets %} (note: this is _not_ public API) * {%jdoc core::rule.RuleSetWriter %} +**Internalized classes** + +These were marked as `@InternalApi` previously. + +* pmd-core + * `RuleFactory`: moved from `net.sourceforge.pmd.rules`; it has now been hidden from public API. + * Many types have been moved from the base package `net.sourceforge.pmd` into the new subpackage `rule.internal`. + * `RuleSetReference` + * `RuleSetReferenceId` + * `RuleSets` + **Removed classes and methods** The following previously deprecated classes have been removed: diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java index 39eebb0963..e9b6e0e84f 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd; -public class RuleSetReferenceId extends net.sourceforge.pmd.rule.RuleSetReferenceId { +public class RuleSetReferenceId extends net.sourceforge.pmd.rule.internal.RuleSetReferenceId { public RuleSetReferenceId(String id) { super(id); } 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 23bac0ab59..68aa482683 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java @@ -52,7 +52,7 @@ 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.rule.internal.RuleSets; import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.StringUtil; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java index 21904f6756..d61dab0ace 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java @@ -38,7 +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; +import net.sourceforge.pmd.rule.internal.RuleSets; /** * Abstract implementation of the analysis cache. Handles all operations, except for persistence. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java index 4eaf19bb27..d2ad94ba43 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java @@ -14,7 +14,7 @@ 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; +import net.sourceforge.pmd.rule.internal.RuleSets; /** * An analysis cache for incremental analysis. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCacheListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCacheListener.java index af16b0c944..bf20e3fb5b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCacheListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCacheListener.java @@ -11,7 +11,7 @@ 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; +import net.sourceforge.pmd.rule.internal.RuleSets; /** * Adapter to wrap {@link AnalysisCache} behaviour in a {@link GlobalAnalysisListener}. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java index 456abfade1..405bdf439e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java @@ -9,7 +9,7 @@ import java.util.Map; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.rule.Rule; -import net.sourceforge.pmd.rule.RuleSets; +import net.sourceforge.pmd.rule.internal.RuleSets; /** * A mapper from rule class names to rule instances for cached rules. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java index 2e2eb73a3c..99128f0924 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java @@ -26,7 +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; +import net.sourceforge.pmd.rule.internal.RuleSets; /** * An analysis cache backed by a regular file. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java index 005e408616..c4a56353b4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java @@ -13,7 +13,7 @@ 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; +import net.sourceforge.pmd.rule.internal.RuleSets; /** * A NOOP analysis cache. Easier / safer than null-checking. 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 68e6f1de86..16aeb8722f 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 @@ -13,7 +13,7 @@ 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.rule.internal.RuleSets; import net.sourceforge.pmd.util.log.MessageReporter; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java index 72315336c8..e4d8257c6e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.impl; import net.sourceforge.pmd.lang.LanguageProcessor.AnalysisTask; import net.sourceforge.pmd.lang.document.TextFile; -import net.sourceforge.pmd.rule.RuleSets; +import net.sourceforge.pmd.rule.internal.RuleSets; /** * @author Romain Pelisse <belaran@gmail.com> 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 c115d21415..1a7159c61b 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 @@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit; import net.sourceforge.pmd.lang.LanguageProcessor.AnalysisTask; import net.sourceforge.pmd.lang.document.TextFile; -import net.sourceforge.pmd.rule.RuleSets; +import net.sourceforge.pmd.rule.internal.RuleSets; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java index 6c085cdfbd..5fbe65a1a8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java @@ -28,7 +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; +import net.sourceforge.pmd.rule.internal.RuleSets; /** * A processing task for a single file. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java index 374a26208d..4c13a70874 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java @@ -16,7 +16,7 @@ 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.rule.internal.RuleSetReference; import net.sourceforge.pmd.util.StringUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/package-info.java b/pmd-core/src/main/java/net/sourceforge/pmd/package-info.java new file mode 100644 index 0000000000..330b372655 --- /dev/null +++ b/pmd-core/src/main/java/net/sourceforge/pmd/package-info.java @@ -0,0 +1,11 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +/** + * This is the PMD programming mistake detector. + * + *

Use it through {@link net.sourceforge.pmd.PmdAnalysis} and + * {@link net.sourceforge.pmd.cpd.CpdAnalysis}. + */ +package net.sourceforge.pmd; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/package.html b/pmd-core/src/main/java/net/sourceforge/pmd/package.html deleted file mode 100644 index a9ba343fd3..0000000000 --- a/pmd-core/src/main/java/net/sourceforge/pmd/package.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - PMD - - -

This is the PMD programming mistake detector. In order to use it, - create a new instance of {@link net.sourceforge.pmd.PMD} and use its - {@link net.sourceforge.pmd.PMD#processFiles} method.

- - diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleFactory.java index 4f15ad3420..f48978dd9c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleFactory.java @@ -53,6 +53,7 @@ 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.internal.RuleSetReference; import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.StringUtil; import net.sourceforge.pmd.util.internal.xml.PmdXmlReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSet.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSet.java index 9c44c29d7e..aa662784a7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSet.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSet.java @@ -28,6 +28,7 @@ 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.internal.RuleSetReference; /** * This class represents a collection of rules along with some optional filter @@ -626,7 +627,8 @@ public class RuleSet implements ChecksumAware { * @return true if the file should be checked, * false otherwise */ - boolean applies(TextFile file) { + @InternalApi + public boolean applies(TextFile file) { return applies(file.getFileId()); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactory.java index 20a2e1ab7e..89bf589406 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactory.java @@ -49,6 +49,8 @@ import net.sourceforge.pmd.PMDVersion; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.rule.RuleSet.RuleSetBuilder; +import net.sourceforge.pmd.rule.internal.RuleSetReference; +import net.sourceforge.pmd.rule.internal.RuleSetReferenceId; import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.StringUtil; import net.sourceforge.pmd.util.internal.xml.PmdXmlReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoadException.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoadException.java index f61b2d849b..e579c9fa76 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoadException.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoadException.java @@ -7,6 +7,7 @@ package net.sourceforge.pmd.rule; import org.checkerframework.checker.nullness.qual.NonNull; import net.sourceforge.pmd.annotation.InternalApi; +import net.sourceforge.pmd.rule.internal.RuleSetReferenceId; /** * An exception that is thrown when something wrong occurs while diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoader.java index 9f238348a1..7462cc55e7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoader.java @@ -25,6 +25,7 @@ import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; +import net.sourceforge.pmd.rule.internal.RuleSetReferenceId; import net.sourceforge.pmd.util.CollectionUtil; import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetWriter.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetWriter.java index 55b24ba0ad..43a44079b5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetWriter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetWriter.java @@ -40,6 +40,7 @@ import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertySerializer; import net.sourceforge.pmd.properties.PropertySource; import net.sourceforge.pmd.properties.PropertyTypeId; +import net.sourceforge.pmd.rule.internal.RuleSetReference; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReference.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSetReference.java similarity index 86% rename from pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReference.java rename to pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSetReference.java index 5e6d7cd3cd..4cf4aac419 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReference.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSetReference.java @@ -2,21 +2,19 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.rule.internal; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; -import net.sourceforge.pmd.annotation.InternalApi; +import net.sourceforge.pmd.rule.RuleSetLoader; /** * This class represents a reference to RuleSet. * - * @deprecated This is part of the internals of the {@link RuleSetLoader}. + *

Note: This is part of the internals of the {@link RuleSetLoader}. */ -@Deprecated -@InternalApi public class RuleSetReference { private final String ruleSetFileName; private final boolean allRules; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReferenceId.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSetReferenceId.java similarity index 98% rename from pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReferenceId.java rename to pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSetReferenceId.java index 65bcf72f00..a22c3933d2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetReferenceId.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSetReferenceId.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.rule.internal; import java.io.File; import java.io.FileNotFoundException; @@ -17,7 +17,7 @@ import java.util.Objects; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.annotation.InternalApi; +import net.sourceforge.pmd.rule.RuleSetLoader; import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.log.MessageReporter; @@ -74,10 +74,8 @@ import net.sourceforge.pmd.util.log.MessageReporter; * * * - * @deprecated This is part of the internals of the {@link RuleSetLoader}. + *

Note: This is part of the internals of the {@link RuleSetLoader}. */ -@Deprecated -@InternalApi public class RuleSetReferenceId { // todo this class has issues... What is even an "external" ruleset? @@ -144,7 +142,7 @@ public class RuleSetReferenceId { * @throws IllegalArgumentException If the ID is not Rule reference when there is an external * RuleSetReferenceId. */ - RuleSetReferenceId(final String id, + public RuleSetReferenceId(final String id, final RuleSetReferenceId externalRuleSetReferenceId, final @Nullable MessageReporter err) { this.originalRef = id; @@ -253,7 +251,7 @@ public class RuleSetReferenceId { this.externalRuleSetReferenceId = externalRuleSetReferenceId; } - @Nullable RuleSetReferenceId getParentRulesetIfThisIsARule() { + public @Nullable RuleSetReferenceId getParentRulesetIfThisIsARule() { if (ruleName == null) { return null; } @@ -378,7 +376,7 @@ public class RuleSetReferenceId { return parse(referenceString, null); } - static List parse(String referenceString, + public static List parse(String referenceString, MessageReporter err) { List references = new ArrayList<>(); if (referenceString != null && referenceString.trim().length() > 0) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSets.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSets.java similarity index 97% rename from pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSets.java rename to pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSets.java index 74d696e327..830d5c4c7d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSets.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSets.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.rule.internal; import java.util.ArrayList; import java.util.Collection; @@ -12,7 +12,6 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.benchmark.TimeTracker; import net.sourceforge.pmd.benchmark.TimedOperation; import net.sourceforge.pmd.benchmark.TimedOperationCategory; @@ -21,17 +20,15 @@ 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.rule.Rule; +import net.sourceforge.pmd.rule.RuleSet; import net.sourceforge.pmd.util.log.MessageReporter; /** * Grouping of Rules per Language in a RuleSet. * * @author pieter_van_raemdonck - Application Engineers NV/SA - www.ae.be - * - * @deprecated Internal API */ -@Deprecated -@InternalApi public class RuleSets { private final List ruleSets; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/package-info.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/package-info.java new file mode 100644 index 0000000000..29f5848708 --- /dev/null +++ b/pmd-core/src/main/java/net/sourceforge/pmd/rule/package-info.java @@ -0,0 +1,9 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +/** + * Contains {@link net.sourceforge.pmd.rule.Rule} and {@link net.sourceforge.pmd.rule.RuleSet} + * related classes. + */ +package net.sourceforge.pmd.rule; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java b/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java index 91c56afacb..0c9a3ac4f9 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.document.TestMessageReporter; import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.rule.RuleSet; -import net.sourceforge.pmd.rule.RuleSets; +import net.sourceforge.pmd.rule.internal.RuleSets; public final class ReportTestUtil { private ReportTestUtil() { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java index b1cf43bf29..e29197bb56 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java @@ -48,7 +48,7 @@ import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.rule.Rule; -import net.sourceforge.pmd.rule.RuleSets; +import net.sourceforge.pmd.rule.internal.RuleSets; class FileAnalysisCacheTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleReferenceTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleReferenceTest.java index 17f4eacfe3..742e6e54a3 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleReferenceTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleReferenceTest.java @@ -19,6 +19,7 @@ import net.sourceforge.pmd.lang.rule.MockRule; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.rule.internal.RuleSetReference; class RuleReferenceTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetTest.java index 8c29db3399..6971de6912 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetTest.java @@ -53,6 +53,7 @@ import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.RuleTargetSelector; import net.sourceforge.pmd.rule.RuleSet.RuleSetBuilder; +import net.sourceforge.pmd.rule.internal.RuleSets; class RuleSetTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetWriterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetWriterTest.java index 0772737633..87d314cf7a 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetWriterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetWriterTest.java @@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.rule.RuleSet.RuleSetBuilder; +import net.sourceforge.pmd.rule.internal.RuleSetReference; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; /** diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetReferenceIdTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/rule/internal/RuleSetReferenceIdTest.java similarity index 99% rename from pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetReferenceIdTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/rule/internal/RuleSetReferenceIdTest.java index ac182bb402..e55828e8b8 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetReferenceIdTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/rule/internal/RuleSetReferenceIdTest.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.rule.internal; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.findAll; From 7b680eecafb90f69d3810f1fb5e221911575dfb9 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 13 Jan 2024 18:51:56 +0100 Subject: [PATCH 05/23] [doc] Update release notes (#3917) --- docs/pages/release_notes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 9dcfe7ea9a..4ee3c83395 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -105,6 +105,7 @@ in the Migration Guide. * [#4723](https://github.com/pmd/pmd/issues/4723): \[cli] Launch fails for "bash pmd" * core * [#1027](https://github.com/pmd/pmd/issues/1027): \[core] Apply the new PropertyDescriptor<Pattern> type where applicable + * [#3917](https://github.com/pmd/pmd/issues/3917): \[core] Consolidate `n.s.pmd.lang.rule` package * [#4674](https://github.com/pmd/pmd/issues/4674): \[core] WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass * [#4694](https://github.com/pmd/pmd/pull/4694): \[core] Fix line/col numbers in TokenMgrError * [#4717](https://github.com/pmd/pmd/issues/4717): \[core] XSLTRenderer doesn't close report file @@ -588,6 +589,7 @@ See also [Detailed Release Notes for PMD 7]({{ baseurl }}pmd_release_notes_pmd7. * [#3815](https://github.com/pmd/pmd/issues/3815): \[core] Update Saxon HE to 10.7 * [#3893](https://github.com/pmd/pmd/pull/3893): \[core] Text documents * [#3902](https://github.com/pmd/pmd/issues/3902): \[core] Violation decorators + * [#3917](https://github.com/pmd/pmd/issues/3917): \[core] Consolidate `n.s.pmd.lang.rule` package * [#3918](https://github.com/pmd/pmd/issues/3918): \[core] Make LanguageRegistry non static * [#3919](https://github.com/pmd/pmd/issues/3919): \[core] Merge CPD and PMD language * [#3922](https://github.com/pmd/pmd/pull/3922): \[core] Better error reporting for the ruleset parser From faaec5ed6de785e47760242eda80b03a398b0b12 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 13 Jan 2024 20:07:44 +0100 Subject: [PATCH 06/23] [core] Actually move into correct package `lang.rule` --- docs/_plugins/javadoc_tag.rb | 8 ++--- docs/pages/release_notes.md | 23 +++++++------- .../java/net/sourceforge/pmd/ant/PMDTask.java | 2 +- .../pmd/ant/internal/PMDTaskImpl.java | 4 +-- .../lang/apex/ApexViolationSuppressors.java | 2 +- .../pmd/lang/apex/DefaultRulesetTest.java | 6 ++-- .../pmd/lang/apex/RuleSetFactoryTest.java | 2 +- .../apex/rule/design/UnusedMethodTest.java | 6 ++-- .../pmd/cli/commands/internal/PmdCommand.java | 2 +- .../internal/RulePriorityTypeSupport.java | 2 +- .../net/sourceforge/pmd/PMDConfiguration.java | 4 +-- .../main/java/net/sourceforge/pmd/Rule.java | 6 ++-- .../net/sourceforge/pmd/RulePriority.java | 8 +++-- .../sourceforge/pmd/RuleSetLoadException.java | 2 +- .../net/sourceforge/pmd/RuleSetLoader.java | 2 +- .../sourceforge/pmd/RuleSetReferenceId.java | 2 +- .../net/sourceforge/pmd/RuleViolation.java | 2 +- .../sourceforge/pmd/{ => lang}/rule/Rule.java | 2 +- .../net/sourceforge/pmd/PMDConfiguration.java | 4 +-- .../java/net/sourceforge/pmd/PmdAnalysis.java | 8 ++--- .../main/java/net/sourceforge/pmd/Report.java | 2 +- .../java/net/sourceforge/pmd/RuleContext.java | 2 +- .../net/sourceforge/pmd/RuleViolation.java | 2 +- .../sourceforge/pmd/ViolationSuppressor.java | 2 +- .../pmd/cache/AbstractAnalysisCache.java | 2 +- .../sourceforge/pmd/cache/AnalysisCache.java | 2 +- .../pmd/cache/AnalysisCacheListener.java | 2 +- .../pmd/cache/CachedRuleMapper.java | 4 +-- .../pmd/cache/CachedRuleViolation.java | 2 +- .../pmd/cache/FileAnalysisCache.java | 2 +- .../pmd/cache/NoopAnalysisCache.java | 2 +- .../pmd/lang/LanguageProcessor.java | 2 +- .../sourceforge/pmd/lang/LanguageVersion.java | 2 +- .../pmd/lang/impl/MonoThreadProcessor.java | 2 +- .../pmd/lang/impl/MultiThreadProcessor.java | 2 +- .../pmd/lang/impl/PmdRunnable.java | 2 +- .../pmd/lang/rule/AbstractDelegateRule.java | 2 -- .../pmd/lang/rule/AbstractRule.java | 2 -- .../lang/rule/ParametricRuleViolation.java | 1 - .../sourceforge/pmd/{ => lang}/rule/Rule.java | 3 +- .../pmd/{ => lang}/rule/RuleFactory.java | 5 ++-- .../pmd/{ => lang}/rule/RulePriority.java | 2 +- .../pmd/lang/rule/RuleReference.java | 4 +-- .../pmd/{ => lang}/rule/RuleSet.java | 6 ++-- .../pmd/{ => lang}/rule/RuleSetFactory.java | 9 +++--- .../rule/RuleSetFactoryCompatibility.java | 2 +- .../{ => lang}/rule/RuleSetLoadException.java | 4 +-- .../pmd/{ => lang}/rule/RuleSetLoader.java | 4 +-- .../pmd/{ => lang}/rule/RuleSetWriter.java | 5 ++-- .../pmd/lang/rule/RuleTargetSelector.java | 1 - .../sourceforge/pmd/lang/rule/XPathRule.java | 1 - .../lang/rule/internal/RuleApplicator.java | 4 +-- .../rule/internal/RuleSetReference.java | 4 +-- .../rule/internal/RuleSetReferenceId.java | 4 +-- .../{ => lang}/rule/internal/RuleSets.java | 7 ++--- .../pmd/lang/rule/package-info.java | 9 ++++++ .../xpath/internal/DeprecatedAttrLogger.java | 2 +- .../pmd/properties/PropertyDescriptor.java | 2 +- .../pmd/properties/PropertySource.java | 2 +- .../pmd/renderers/CodeClimateRenderer.java | 2 +- .../pmd/renderers/HTMLRenderer.java | 2 +- .../sourceforge/pmd/rule/package-info.java | 9 ------ .../sourceforge/pmd/util/ResourceLoader.java | 2 +- .../net/sourceforge/pmd/AbstractRuleTest.java | 2 +- .../net/sourceforge/pmd/PmdAnalysisTest.java | 4 +-- .../sourceforge/pmd/PmdConfigurationTest.java | 2 +- .../net/sourceforge/pmd/PmdCoreTestUtils.java | 2 +- .../java/net/sourceforge/pmd/ReportTest.java | 2 +- .../net/sourceforge/pmd/ReportTestUtil.java | 6 ++-- .../pmd/RuleViolationComparatorTest.java | 2 +- .../sourceforge/pmd/RuleViolationTest.java | 2 +- .../pmd/cache/FileAnalysisCacheTest.java | 4 +-- .../lang/impl/AbstractPMDProcessorTest.java | 2 +- .../lang/impl/MonoThreadProcessorTest.java | 2 +- .../lang/impl/MultiThreadProcessorTest.java | 2 +- .../sourceforge/pmd/lang/rule/MockRule.java | 6 ++-- .../lang/rule/MockRuleWithNoProperties.java | 1 - .../{ => lang}/rule/RuleReferenceTest.java | 6 ++-- .../rule/RuleSetFactoryCompatibilityTest.java | 2 +- ...leSetFactoryDuplicatedRuleLoggingTest.java | 2 +- .../rule/RuleSetFactoryMessagesTest.java | 3 +- .../{ => lang}/rule/RuleSetFactoryTest.java | 30 +++++++++---------- .../pmd/{ => lang}/rule/RuleSetTest.java | 8 ++--- .../{ => lang}/rule/RuleSetWriterTest.java | 10 +++---- .../rule/RulesetFactoryTestBase.java | 2 +- .../pmd/lang/rule/XPathRuleTest.java | 1 - .../rule/internal/RuleSetReferenceIdTest.java | 2 +- .../pmd/processor/PmdRunnableTest.java | 4 +-- .../pmd/properties/PropertySyntaxTest.java | 4 +-- .../pmd/renderers/AbstractRendererTest.java | 4 +-- .../pmd/renderers/SarifRendererTest.java | 2 +- .../pmd/renderers/YAHTMLRendererTest.java | 2 +- .../reporting/GlobalAnalysisListenerTest.java | 4 +-- .../net/sourceforge/pmd/rule/MockRule.java | 24 --------------- .../pmd/{ => lang}/rule/TestRuleset1.xml | 6 ++-- .../pmd/{ => lang}/rule/TestRuleset2.xml | 0 .../pmd/{ => lang}/rule/TestRuleset3.xml | 0 .../pmd/{ => lang}/rule/TestRuleset4.xml | 0 .../rule/external-reference-ruleset.xml | 2 +- .../pmd/{ => lang}/rule/reference-ruleset.xml | 18 +++++------ .../pmd/docs/GenerateRuleDocsCmd.java | 4 +-- .../pmd/docs/RuleDocGenerator.java | 8 ++--- .../sourceforge/pmd/docs/RuleSetUtils.java | 4 +-- .../pmd/docs/SidebarGenerator.java | 2 +- .../pmd/docs/RuleDocGeneratorTest.java | 4 +-- .../pmd/docs/RuleSetResolverTest.java | 2 +- .../pmd/docs/SidebarGeneratorTest.java | 2 +- .../pmd/lang/html/HtmlJavaRuleTest.java | 2 +- .../pmd/lang/html/RuleSetFactoryTest.java | 2 +- .../internal/AnnotationSuppressionUtil.java | 2 +- .../net/sourceforge/pmd/ExcludeLinesTest.java | 2 +- .../java/net/sourceforge/pmd/ReportTest.java | 2 +- .../pmd/lang/java/PMD5RulesetTest.java | 4 +-- .../pmd/lang/java/QuickstartRulesetTest.java | 6 ++-- .../pmd/lang/java/RuleSetFactoryTest.java | 2 +- .../pmd/lang/java/rule/XPathRuleTest.java | 2 +- .../documentation/CommentRequiredTest.java | 2 +- .../xpath/internal/BaseXPathFunctionTest.java | 2 +- .../internal/GetModifiersFunctionsTest.java | 2 +- .../internal/HasAnnotationXPathTest.java | 2 +- .../internal/MatchesSignatureXPathTest.java | 2 +- .../xpath/internal/NodeIsFunctionTest.java | 2 +- .../xpath/internal/TypeIsFunctionTest.java | 2 +- .../internal/XPathMetricFunctionTest.java | 2 +- .../java/net/sourceforge/pmd/ReportTest.java | 2 +- .../lang/ecmascript/RuleSetFactoryTest.java | 2 +- .../pmd/lang/jsp/RuleSetFactoryTest.java | 2 +- .../pmd/lang/jsp/ast/XPathJspRuleTest.java | 2 +- .../pmd/lang/kotlin/RuleSetFactoryTest.java | 2 +- .../pmd/lang/ast/test/BaseParsingHelper.kt | 4 +-- .../pmd/lang/modelica/RuleSetFactoryTest.java | 2 +- .../pmd/lang/plsql/RuleSetFactoryTest.java | 2 +- .../rule/errorprone/ToDateToCharTest.java | 2 +- .../ToDateWithoutDateFormatTest.java | 2 +- .../ToTimestampWithoutDateFormatTest.java | 2 +- .../pmd/lang/scala/RulesetFactoryTest.java | 2 +- .../pmd/lang/swift/RuleSetFactoryTest.java | 2 +- .../pmd/test/schema/BaseTestParserImpl.java | 2 +- .../pmd/test/schema/RuleTestDescriptor.java | 2 +- .../pmd/test/schema/TestSchemaParser.java | 2 +- .../pmd/AbstractLanguageVersionTest.java | 4 +-- .../rule/AbstractRuleSetFactoryTest.java | 4 +-- .../pmd/testframework/PmdRuleTst.java | 2 +- .../pmd/testframework/RuleTst.java | 8 ++--- .../testframework/SimpleAggregatorTst.java | 2 +- .../pmd/testframework/RuleTstTest.java | 2 +- .../pmd/lang/vf/RuleSetFactoryTest.java | 2 +- .../vf/rule/security/VfUnescapeElTest.java | 2 +- .../pmd/lang/vm/RuleSetFactoryTest.java | 2 +- .../pmd/lang/xml/RuleSetFactoryTest.java | 2 +- .../pmd/lang/xml/rule/XmlXPathRuleTest.java | 2 +- 151 files changed, 245 insertions(+), 293 deletions(-) rename pmd-compat6/src/main/java/net/sourceforge/pmd/{ => lang}/rule/Rule.java (87%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => lang}/rule/Rule.java (98%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => lang}/rule/RuleFactory.java (99%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => lang}/rule/RulePriority.java (98%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => lang}/rule/RuleSet.java (99%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => lang}/rule/RuleSetFactory.java (99%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => lang}/rule/RuleSetFactoryCompatibility.java (99%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => lang}/rule/RuleSetLoadException.java (90%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => lang}/rule/RuleSetLoader.java (99%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => lang}/rule/RuleSetWriter.java (99%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => lang}/rule/internal/RuleSetReference.java (92%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => lang}/rule/internal/RuleSetReferenceId.java (99%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => lang}/rule/internal/RuleSets.java (97%) create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/package-info.java delete mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/rule/package-info.java rename pmd-core/src/test/java/net/sourceforge/pmd/{ => lang}/rule/RuleReferenceTest.java (98%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => lang}/rule/RuleSetFactoryCompatibilityTest.java (99%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => lang}/rule/RuleSetFactoryDuplicatedRuleLoggingTest.java (98%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => lang}/rule/RuleSetFactoryMessagesTest.java (98%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => lang}/rule/RuleSetFactoryTest.java (97%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => lang}/rule/RuleSetTest.java (98%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => lang}/rule/RuleSetWriterTest.java (94%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => lang}/rule/RulesetFactoryTestBase.java (99%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => lang}/rule/internal/RuleSetReferenceIdTest.java (99%) delete mode 100644 pmd-core/src/test/java/net/sourceforge/pmd/rule/MockRule.java rename pmd-core/src/test/resources/net/sourceforge/pmd/{ => lang}/rule/TestRuleset1.xml (88%) rename pmd-core/src/test/resources/net/sourceforge/pmd/{ => lang}/rule/TestRuleset2.xml (100%) rename pmd-core/src/test/resources/net/sourceforge/pmd/{ => lang}/rule/TestRuleset3.xml (100%) rename pmd-core/src/test/resources/net/sourceforge/pmd/{ => lang}/rule/TestRuleset4.xml (100%) rename pmd-core/src/test/resources/net/sourceforge/pmd/{ => lang}/rule/external-reference-ruleset.xml (89%) rename pmd-core/src/test/resources/net/sourceforge/pmd/{ => lang}/rule/reference-ruleset.xml (64%) rename pmd-test/src/main/java/net/sourceforge/pmd/{ => lang}/rule/AbstractRuleSetFactoryTest.java (99%) diff --git a/docs/_plugins/javadoc_tag.rb b/docs/_plugins/javadoc_tag.rb index 0ece78d2df..e4dd63e0de 100644 --- a/docs/_plugins/javadoc_tag.rb +++ b/docs/_plugins/javadoc_tag.rb @@ -73,19 +73,19 @@ require_relative 'jdoc_namespace_tag' # * a (args) -> adds the simple name of the argument types for method references, noop for other references # * {% jdoc !a!core::Rule#setName(java.lang.String) %} -> [`setName(String)`](...) # * q (qualify) -> prefix with the fqcn of the class, noop for package references -# * {% jdoc !q!core::rule.Rule %} -> [`net.sourceforge.pmd.rule.Rule`](...) -# * {% jdoc !q!core::rule.Rule#setName(java.lang.String) %} -> [`net.sourceforge.pmd.rule.Rule#setName`](...) +# * {% jdoc !q!core::rule.Rule %} -> [`net.sourceforge.pmd.lang.rule.Rule`](...) +# * {% jdoc !q!core::rule.Rule#setName(java.lang.String) %} -> [`net.sourceforge.pmd.lang.rule.Rule#setName`](...) # * c (class) -> prefix the class name for member references, noop for type and package references, or if "qualify" is specified # * {% jdoc !c!core::Rule#setName(java.lang.String) %} -> [`Rule#setName`](...) # * Empty options ("!!") - > shorthand to a commonly relevant option # * For field or method references, "!!" is the "c" option # * {% jdoc !!core::Rule#setName(java.lang.String) %} -> [`Rule#setName`](...) # * For type references, "!!" is the "q" option -# * {% jdoc !!core::rule.Rule %} -> [`net.sourceforge.pmd.rule.Rule`](...) +# * {% jdoc !!core::rule.Rule %} -> [`net.sourceforge.pmd.lang.rule.Rule`](...) # * For package references, "!!" is a noop, they're always fully qualified # * Several options may be used at once, though this is only useful for method references: # * {% jdoc !ac!core::Rule#setName(java.lang.String) %} -> [`Rule#setName(String)`](...) -# * {% jdoc !aq!core::rule.Rule#setName(java.lang.String) %} -> [`net.sourceforge.pmd.rule.Rule#setName(String)`](...) +# * {% jdoc !aq!core::rule.Rule#setName(java.lang.String) %} -> [`net.sourceforge.pmd.lang.rule.Rule#setName(String)`](...) # # * DO NOT: # - Include spaces in any part of the reference diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 4ee3c83395..267cdf33b3 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -155,23 +155,24 @@ in the Migration Guide. **Moved classes/consolidated packages** * pmd-core - * 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.RulePriority %} - * {%jdoc core::rule.RuleSet %} - * {%jdoc core::rule.RuleSetFactory %} - * {%jdoc core::rule.RuleSetFactoryCompatibility %} - * {%jdoc core::rule.RuleSetLoader %} - * {%jdoc core::rule.RuleSetLoadException %} - * {%jdoc core::rule.RuleSetWriter %} + * Many types have been moved from the base package `net.sourceforge.pmd` into subpackage {% jdoc_package core::lang.rule %} + * {%jdoc core::lang.rule.Rule %} + * {%jdoc core::lang.rule.RulePriority %} + * {%jdoc core::lang.rule.RuleSet %} + * {%jdoc core::lang.rule.RuleSetFactory %} + * {%jdoc core::lang.rule.RuleSetFactoryCompatibility %} + * {%jdoc core::lang.rule.RuleSetLoader %} + * {%jdoc core::lang.rule.RuleSetLoadException %} + * {%jdoc core::lang.rule.RuleSetWriter %} **Internalized classes** These were marked as `@InternalApi` previously. * pmd-core - * `RuleFactory`: moved from `net.sourceforge.pmd.rules`; it has now been hidden from public API. - * Many types have been moved from the base package `net.sourceforge.pmd` into the new subpackage `rule.internal`. + * `RuleFactory`: moved from `net.sourceforge.pmd.rules` into subpackage `lang.rule`. + It has now been hidden completely from public API. + * Many types have been moved from the base package `net.sourceforge.pmd` into subpackage `lang.rule.internal`. * `RuleSetReference` * `RuleSetReferenceId` * `RuleSets` diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java index 215f2929f0..a6d8871ad3 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java @@ -19,7 +19,7 @@ import org.apache.tools.ant.types.Resource; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.ant.internal.PMDTaskImpl; -import net.sourceforge.pmd.rule.RulePriority; +import net.sourceforge.pmd.lang.rule.RulePriority; /** * PMD Ant task. Setters of this class are interpreted by Ant as properties diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java index 1f48d23553..8fda9fc29d 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java @@ -33,12 +33,12 @@ import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.document.TextFile; +import net.sourceforge.pmd.lang.rule.RulePriority; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; 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 { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexViolationSuppressors.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexViolationSuppressors.java index 939e0dc0e5..e70da5a124 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexViolationSuppressors.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexViolationSuppressors.java @@ -29,7 +29,7 @@ import net.sourceforge.pmd.lang.apex.ast.ASTUserEnum; import net.sourceforge.pmd.lang.apex.ast.ASTVariableDeclarationStatements; import net.sourceforge.pmd.lang.apex.ast.ApexNode; import net.sourceforge.pmd.lang.ast.Node; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; final class ApexViolationSuppressors { diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/DefaultRulesetTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/DefaultRulesetTest.java index f2b360cba9..dcf51a3770 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/DefaultRulesetTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/DefaultRulesetTest.java @@ -9,9 +9,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; -import net.sourceforge.pmd.rule.RuleSet; -import net.sourceforge.pmd.rule.RuleSetLoader; +import net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.lang.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/RuleSetFactoryTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/RuleSetFactoryTest.java index 38383cb831..c3dd9beaa2 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/RuleSetFactoryTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.apex; -import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest; class RuleSetFactoryTest extends AbstractRuleSetFactoryTest { // no additional tests yet diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java index f6d18cf2da..345c2947d5 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java @@ -21,10 +21,10 @@ import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.apex.ApexLanguageModule; import net.sourceforge.pmd.lang.apex.ApexLanguageProperties; +import net.sourceforge.pmd.lang.rule.Rule; +import net.sourceforge.pmd.lang.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; 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; 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 4536ad05c0..29d9f3ec66 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 @@ -32,11 +32,11 @@ import net.sourceforge.pmd.cli.internal.ProgressBarListener; import net.sourceforge.pmd.internal.LogMessages; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.lang.rule.RulePriority; 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; diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/RulePriorityTypeSupport.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/RulePriorityTypeSupport.java index 82660c26be..67c3e41337 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/RulePriorityTypeSupport.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/RulePriorityTypeSupport.java @@ -8,7 +8,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import net.sourceforge.pmd.rule.RulePriority; +import net.sourceforge.pmd.lang.rule.RulePriority; import picocli.CommandLine.ITypeConverter; import picocli.CommandLine.TypeConversionException; diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/PMDConfiguration.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/PMDConfiguration.java index 34d4665b93..42d38e7754 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/PMDConfiguration.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/PMDConfiguration.java @@ -33,9 +33,9 @@ import net.sourceforge.pmd.cache.NoopAnalysisCache; import net.sourceforge.pmd.internal.util.ClasspathClassLoader; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.renderers.RendererFactory; -import net.sourceforge.pmd.rule.RuleSetLoader; import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter; @@ -596,7 +596,7 @@ public class PMDConfiguration extends AbstractConfiguration { } // new method to be compatible with PMD 7 - RulePriority has changed package - public net.sourceforge.pmd.rule.RulePriority getMinimumPriority$$bridge() { // SUPPRESS CHECKSTYLE ignore + public net.sourceforge.pmd.lang.rule.RulePriority getMinimumPriority$$bridge() { // SUPPRESS CHECKSTYLE ignore return minimumPriority.asPMD7RulePriority(); } } diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java index 8dcd4d8aaf..f81c5a7cfb 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java @@ -16,12 +16,12 @@ import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.rule.RulePriority; +import net.sourceforge.pmd.lang.rule.RuleSet; import net.sourceforge.pmd.lang.rule.RuleTargetSelector; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; import net.sourceforge.pmd.properties.PropertySource; -import net.sourceforge.pmd.rule.RulePriority; -import net.sourceforge.pmd.rule.RuleSet; /** * This is the basic Rule interface for PMD rules. @@ -311,7 +311,7 @@ public interface Rule extends PropertySource { * Creates a new copy of this rule. * @return A new exact copy of this rule */ - net.sourceforge.pmd.rule.Rule deepCopy(); + net.sourceforge.pmd.lang.rule.Rule deepCopy(); // new method to be compatible with PMD 6 - Rule has changed package default Rule deepCopy$$bridge() { // SUPPRESS CHECKSTYLE ignore diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/RulePriority.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/RulePriority.java index 3e35b306ad..c624f1200e 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/RulePriority.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/RulePriority.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -// Copy of net.sourceforge.pmd.rule.RulePriority +// Copy of net.sourceforge.pmd.lang.rule.RulePriority // Added method: // - asPMD7RulePriority @@ -130,7 +130,9 @@ public enum RulePriority { } } - public net.sourceforge.pmd.rule.RulePriority asPMD7RulePriority() { - return net.sourceforge.pmd.rule.RulePriority.valueOf(name()); + // ---- compatibility extensions + + public net.sourceforge.pmd.lang.rule.RulePriority asPMD7RulePriority() { + return net.sourceforge.pmd.lang.rule.RulePriority.valueOf(name()); } } diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoadException.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoadException.java index db5d0b76fb..4af60a4d22 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoadException.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoadException.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd; import org.checkerframework.checker.nullness.qual.NonNull; -public class RuleSetLoadException extends net.sourceforge.pmd.rule.RuleSetLoadException { +public class RuleSetLoadException extends net.sourceforge.pmd.lang.rule.RuleSetLoadException { public RuleSetLoadException(RuleSetReferenceId rsetId, @NonNull Throwable cause) { super(rsetId, cause); } diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoader.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoader.java index 00f73ad2fa..20e91f3069 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoader.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetLoader.java @@ -15,7 +15,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import net.sourceforge.pmd.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSet; public final class RuleSetLoader { public RuleSetLoader warnDeprecated(boolean warn) { diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java index e9b6e0e84f..0cb348899a 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd; -public class RuleSetReferenceId extends net.sourceforge.pmd.rule.internal.RuleSetReferenceId { +public class RuleSetReferenceId extends net.sourceforge.pmd.lang.rule.internal.RuleSetReferenceId { public RuleSetReferenceId(String id) { super(id); } diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleViolation.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleViolation.java index 0664b0fc34..b1d685bf46 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleViolation.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleViolation.java @@ -70,7 +70,7 @@ public interface RuleViolation { * * @return The identifying Rule. */ - net.sourceforge.pmd.rule.Rule getRule(); + net.sourceforge.pmd.lang.rule.Rule getRule(); /** * Get the description of this violation. diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/rule/Rule.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/Rule.java similarity index 87% rename from pmd-compat6/src/main/java/net/sourceforge/pmd/rule/Rule.java rename to pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/Rule.java index b24bd39487..a152534e5f 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/rule/Rule.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/Rule.java @@ -5,7 +5,7 @@ // The class net.sourceforge.pmd.Rule has been moved into sub-package rule // in 7.0.0-SNAPSHOT. All rules should be interchangeable. -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; public interface Rule extends net.sourceforge.pmd.Rule { } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java index 8eaa7de870..dadfe809ef 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java @@ -27,10 +27,10 @@ import net.sourceforge.pmd.cache.NoopAnalysisCache; import net.sourceforge.pmd.internal.util.ClasspathClassLoader; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; +import net.sourceforge.pmd.lang.rule.RulePriority; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; 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; 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 68aa482683..7601624b26 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java @@ -42,6 +42,10 @@ import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.LanguageVersionDiscoverer; import net.sourceforge.pmd.lang.document.FileCollector; import net.sourceforge.pmd.lang.document.TextFile; +import net.sourceforge.pmd.lang.rule.Rule; +import net.sourceforge.pmd.lang.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; +import net.sourceforge.pmd.lang.rule.internal.RuleSets; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.reporting.ConfigurableFileNameRenderer; import net.sourceforge.pmd.reporting.FileAnalysisListener; @@ -49,10 +53,6 @@ import net.sourceforge.pmd.reporting.GlobalAnalysisListener; 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.internal.RuleSets; import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.StringUtil; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/Report.java b/pmd-core/src/main/java/net/sourceforge/pmd/Report.java index 112e2cf6aa..cec38d6246 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/Report.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/Report.java @@ -20,10 +20,10 @@ import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.TextFile; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.renderers.AbstractAccumulatingRenderer; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; -import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.BaseResultProducingCloseable; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java index 542732bc23..3a787740e0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java @@ -23,10 +23,10 @@ import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.ViolationDecorator; -import net.sourceforge.pmd.rule.Rule; /** * The API for rules to report violations or errors during analysis. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java index a0a63b0d0a..495c5f1ba8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java @@ -10,7 +10,7 @@ import java.util.Map; import net.sourceforge.pmd.annotation.DeprecatedUntil700; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.FileLocation; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; /** * A RuleViolation is created by a Rule when it identifies a violation of the diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/ViolationSuppressor.java b/pmd-core/src/main/java/net/sourceforge/pmd/ViolationSuppressor.java index 94c74422e5..ee07535ab1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/ViolationSuppressor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/ViolationSuppressor.java @@ -15,10 +15,10 @@ import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.Report.SuppressedViolation; import net.sourceforge.pmd.lang.ast.AstInfo; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; import net.sourceforge.pmd.lang.rule.xpath.internal.DeprecatedAttrLogger; import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery; -import net.sourceforge.pmd.rule.Rule; /** * An object that suppresses rule violations. Suppressors are used by diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java index d61dab0ace..ecc073692e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java @@ -37,8 +37,8 @@ import net.sourceforge.pmd.internal.util.IOUtil; 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.lang.rule.internal.RuleSets; import net.sourceforge.pmd.reporting.FileAnalysisListener; -import net.sourceforge.pmd.rule.internal.RuleSets; /** * Abstract implementation of the analysis cache. Handles all operations, except for persistence. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java index d2ad94ba43..bfa339c2cf 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java @@ -12,9 +12,9 @@ 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.lang.rule.internal.RuleSets; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; -import net.sourceforge.pmd.rule.internal.RuleSets; /** * An analysis cache for incremental analysis. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCacheListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCacheListener.java index bf20e3fb5b..b7f52ac4dc 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCacheListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCacheListener.java @@ -9,9 +9,9 @@ import java.util.Collection; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.document.TextFile; +import net.sourceforge.pmd.lang.rule.internal.RuleSets; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; -import net.sourceforge.pmd.rule.internal.RuleSets; /** * Adapter to wrap {@link AnalysisCache} behaviour in a {@link GlobalAnalysisListener}. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java index 405bdf439e..f035ecc9e0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java @@ -8,8 +8,8 @@ import java.util.HashMap; import java.util.Map; import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.rule.Rule; -import net.sourceforge.pmd.rule.internal.RuleSets; +import net.sourceforge.pmd.lang.rule.Rule; +import net.sourceforge.pmd.lang.rule.internal.RuleSets; /** * A mapper from rule class names to rule instances for cached rules. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleViolation.java index e1f5bdbd21..5965a508e8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleViolation.java @@ -19,7 +19,7 @@ import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextRange2d; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.util.StringUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java index 99128f0924..5a8437d64f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java @@ -26,7 +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.internal.RuleSets; +import net.sourceforge.pmd.lang.rule.internal.RuleSets; /** * An analysis cache backed by a regular file. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java index c4a56353b4..27e9247b08 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java @@ -12,8 +12,8 @@ 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.lang.rule.internal.RuleSets; import net.sourceforge.pmd.reporting.FileAnalysisListener; -import net.sourceforge.pmd.rule.internal.RuleSets; /** * A NOOP analysis cache. Easier / safer than null-checking. 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 16aeb8722f..080a42ef6b 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 @@ -12,8 +12,8 @@ import org.checkerframework.checker.nullness.qual.NonNull; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.cache.AnalysisCache; import net.sourceforge.pmd.lang.document.TextFile; +import net.sourceforge.pmd.lang.rule.internal.RuleSets; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; -import net.sourceforge.pmd.rule.internal.RuleSets; import net.sourceforge.pmd.util.log.MessageReporter; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java index a94cb809d5..4867572717 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang; import java.util.List; import java.util.Objects; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; /** * Represents a version of a {@link Language}. Language instances provide diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java index e4d8257c6e..8e629fb06d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.impl; import net.sourceforge.pmd.lang.LanguageProcessor.AnalysisTask; import net.sourceforge.pmd.lang.document.TextFile; -import net.sourceforge.pmd.rule.internal.RuleSets; +import net.sourceforge.pmd.lang.rule.internal.RuleSets; /** * @author Romain Pelisse <belaran@gmail.com> 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 1a7159c61b..a11a8bb6a0 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 @@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit; import net.sourceforge.pmd.lang.LanguageProcessor.AnalysisTask; import net.sourceforge.pmd.lang.document.TextFile; -import net.sourceforge.pmd.rule.internal.RuleSets; +import net.sourceforge.pmd.lang.rule.internal.RuleSets; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java index 5fbe65a1a8..b252977569 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java @@ -27,8 +27,8 @@ import net.sourceforge.pmd.lang.ast.SemanticErrorReporter; 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.lang.rule.internal.RuleSets; import net.sourceforge.pmd.reporting.FileAnalysisListener; -import net.sourceforge.pmd.rule.internal.RuleSets; /** * A processing task for a single file. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java index f3f11349e0..8d0efe44b4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java @@ -14,8 +14,6 @@ import net.sourceforge.pmd.lang.LanguageVersion; 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. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java index 081696930e..1999658ee0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java @@ -22,8 +22,6 @@ import net.sourceforge.pmd.lang.ast.Node; 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 diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java index 09e67cfa7f..5e469c3985 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java @@ -11,7 +11,6 @@ import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.reporting.Reportable; -import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.AssertionUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/Rule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/Rule.java similarity index 98% rename from pmd-core/src/main/java/net/sourceforge/pmd/rule/Rule.java rename to pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/Rule.java index 6d2ed5c65d..7be90df34e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/Rule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/Rule.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import java.util.List; import java.util.Optional; @@ -13,7 +13,6 @@ import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.ast.Node; -import net.sourceforge.pmd.lang.rule.RuleTargetSelector; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; import net.sourceforge.pmd.properties.PropertySource; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleFactory.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleFactory.java rename to pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleFactory.java index f48978dd9c..c1dd7d709b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleFactory.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import static net.sourceforge.pmd.util.internal.xml.SchemaConstants.CLASS; import static net.sourceforge.pmd.util.internal.xml.SchemaConstants.DELIMITER; @@ -44,7 +44,7 @@ import org.w3c.dom.Node; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersion; -import net.sourceforge.pmd.lang.rule.RuleReference; +import net.sourceforge.pmd.lang.rule.internal.RuleSetReference; import net.sourceforge.pmd.properties.ConstraintViolatedException; import net.sourceforge.pmd.properties.NumericConstraints; import net.sourceforge.pmd.properties.PropertyBuilder; @@ -53,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.internal.RuleSetReference; import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.StringUtil; import net.sourceforge.pmd.util.internal.xml.PmdXmlReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RulePriority.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RulePriority.java similarity index 98% rename from pmd-core/src/main/java/net/sourceforge/pmd/rule/RulePriority.java rename to pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RulePriority.java index 08cde9f3ee..2007fcf0aa 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RulePriority.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RulePriority.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; /** * These are the possible Rule priority values. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java index 4c13a70874..075f88fbf4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java @@ -13,10 +13,8 @@ import java.util.Map; import java.util.Objects; import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.lang.rule.internal.RuleSetReference; import net.sourceforge.pmd.properties.PropertyDescriptor; -import net.sourceforge.pmd.rule.Rule; -import net.sourceforge.pmd.rule.RulePriority; -import net.sourceforge.pmd.rule.internal.RuleSetReference; import net.sourceforge.pmd.util.StringUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSet.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSet.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSet.java rename to pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSet.java index aa662784a7..095e207224 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSet.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSet.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import java.util.ArrayList; import java.util.Arrays; @@ -26,9 +26,7 @@ import net.sourceforge.pmd.internal.util.PredicateUtil; import net.sourceforge.pmd.lang.LanguageVersion; 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.internal.RuleSetReference; +import net.sourceforge.pmd.lang.rule.internal.RuleSetReference; /** * This class represents a collection of rules along with some optional filter diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetFactory.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactory.java rename to pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetFactory.java index 89bf589406..31e112c4cf 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetFactory.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import static net.sourceforge.pmd.util.CollectionUtil.setOf; import static net.sourceforge.pmd.util.internal.xml.SchemaConstants.DESCRIPTION; @@ -47,10 +47,9 @@ import org.xml.sax.InputSource; import net.sourceforge.pmd.PMDVersion; import net.sourceforge.pmd.lang.LanguageRegistry; -import net.sourceforge.pmd.lang.rule.RuleReference; -import net.sourceforge.pmd.rule.RuleSet.RuleSetBuilder; -import net.sourceforge.pmd.rule.internal.RuleSetReference; -import net.sourceforge.pmd.rule.internal.RuleSetReferenceId; +import net.sourceforge.pmd.lang.rule.RuleSet.RuleSetBuilder; +import net.sourceforge.pmd.lang.rule.internal.RuleSetReference; +import net.sourceforge.pmd.lang.rule.internal.RuleSetReferenceId; import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.StringUtil; import net.sourceforge.pmd.util.internal.xml.PmdXmlReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactoryCompatibility.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryCompatibility.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactoryCompatibility.java rename to pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryCompatibility.java index 11f2c9c37f..b98f45e682 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetFactoryCompatibility.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryCompatibility.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import java.text.MessageFormat; import java.util.ArrayList; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoadException.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetLoadException.java similarity index 90% rename from pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoadException.java rename to pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetLoadException.java index e579c9fa76..c87ba35118 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoadException.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetLoadException.java @@ -2,12 +2,12 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import org.checkerframework.checker.nullness.qual.NonNull; import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.rule.internal.RuleSetReferenceId; +import net.sourceforge.pmd.lang.rule.internal.RuleSetReferenceId; /** * An exception that is thrown when something wrong occurs while diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetLoader.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoader.java rename to pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetLoader.java index 7462cc55e7..433ab5042e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetLoader.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -25,7 +25,7 @@ import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; -import net.sourceforge.pmd.rule.internal.RuleSetReferenceId; +import net.sourceforge.pmd.lang.rule.internal.RuleSetReferenceId; import net.sourceforge.pmd.util.CollectionUtil; import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetWriter.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetWriter.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetWriter.java rename to pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetWriter.java index 43a44079b5..66fedc4333 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/RuleSetWriter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetWriter.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import java.io.OutputStream; import java.util.HashSet; @@ -34,13 +34,12 @@ import org.w3c.dom.Text; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageVersion; -import net.sourceforge.pmd.lang.rule.RuleReference; +import net.sourceforge.pmd.lang.rule.internal.RuleSetReference; import net.sourceforge.pmd.properties.PropertyConstraint; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertySerializer; import net.sourceforge.pmd.properties.PropertySource; import net.sourceforge.pmd.properties.PropertyTypeId; -import net.sourceforge.pmd.rule.internal.RuleSetReference; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleTargetSelector.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleTargetSelector.java index 23f958d42e..b130e3abdf 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleTargetSelector.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleTargetSelector.java @@ -17,7 +17,6 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.rule.internal.TargetSelectorInternal; import net.sourceforge.pmd.lang.rule.internal.TreeIndex; -import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.util.CollectionUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java index 1a15b99921..7c959b87d2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java @@ -26,7 +26,6 @@ import net.sourceforge.pmd.lang.rule.xpath.internal.DeprecatedAttrLogger; import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; -import net.sourceforge.pmd.rule.Rule; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java index 8036814d7a..6be7178347 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java @@ -20,9 +20,9 @@ import net.sourceforge.pmd.internal.SystemProps; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; +import net.sourceforge.pmd.lang.rule.Rule; +import net.sourceforge.pmd.lang.rule.RuleSet; 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; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSetReference.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReference.java similarity index 92% rename from pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSetReference.java rename to pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReference.java index 4cf4aac419..89590dd04a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSetReference.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReference.java @@ -2,13 +2,13 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule.internal; +package net.sourceforge.pmd.lang.rule.internal; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; -import net.sourceforge.pmd.rule.RuleSetLoader; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; /** * This class represents a reference to RuleSet. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSetReferenceId.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReferenceId.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSetReferenceId.java rename to pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReferenceId.java index a22c3933d2..6867ffccd2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSetReferenceId.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReferenceId.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule.internal; +package net.sourceforge.pmd.lang.rule.internal; import java.io.File; import java.io.FileNotFoundException; @@ -17,7 +17,7 @@ import java.util.Objects; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.rule.RuleSetLoader; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSets.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSets.java similarity index 97% rename from pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSets.java rename to pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSets.java index 830d5c4c7d..3dcfe27cf7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/internal/RuleSets.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSets.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule.internal; +package net.sourceforge.pmd.lang.rule.internal; import java.util.ArrayList; import java.util.Collection; @@ -18,10 +18,9 @@ import net.sourceforge.pmd.benchmark.TimedOperationCategory; import net.sourceforge.pmd.lang.LanguageProcessorRegistry; 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.lang.rule.Rule; +import net.sourceforge.pmd.lang.rule.RuleSet; import net.sourceforge.pmd.reporting.FileAnalysisListener; -import net.sourceforge.pmd.rule.Rule; -import net.sourceforge.pmd.rule.RuleSet; import net.sourceforge.pmd.util.log.MessageReporter; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/package-info.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/package-info.java new file mode 100644 index 0000000000..a802199683 --- /dev/null +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/package-info.java @@ -0,0 +1,9 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +/** + * Contains {@link net.sourceforge.pmd.lang.rule.Rule} and {@link net.sourceforge.pmd.lang.rule.RuleSet} + * related classes. + */ +package net.sourceforge.pmd.lang.rule; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java index f808d375a5..268684c2b8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java @@ -10,9 +10,9 @@ import java.util.concurrent.ConcurrentMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.Attribute; -import net.sourceforge.pmd.rule.Rule; /** * Records usages of deprecated attributes in XPath rules. This needs diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java index a8c3d51264..9c71f35369 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java @@ -9,7 +9,7 @@ import java.util.Objects; import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.rule.RuleSetWriter; +import net.sourceforge.pmd.lang.rule.RuleSetWriter; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertySource.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertySource.java index 896dd7fcc7..6ae3caf0e2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertySource.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertySource.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.properties; import java.util.List; import java.util.Map; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java index 4ff5571e3f..facf98cac1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java @@ -13,8 +13,8 @@ import org.apache.commons.lang3.StringUtils; import net.sourceforge.pmd.PMDVersion; import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.properties.PropertyDescriptor; -import net.sourceforge.pmd.rule.Rule; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java index e38119f9f1..e877f99ad8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java @@ -18,9 +18,9 @@ import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Report.ConfigurationError; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.document.FileId; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; -import net.sourceforge.pmd.rule.Rule; /** * Renderer to basic HTML format. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/rule/package-info.java b/pmd-core/src/main/java/net/sourceforge/pmd/rule/package-info.java deleted file mode 100644 index 29f5848708..0000000000 --- a/pmd-core/src/main/java/net/sourceforge/pmd/rule/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -/** - * Contains {@link net.sourceforge.pmd.rule.Rule} and {@link net.sourceforge.pmd.rule.RuleSet} - * related classes. - */ -package net.sourceforge.pmd.rule; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/ResourceLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ResourceLoader.java index 4ce16d32ef..4762dad162 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/ResourceLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ResourceLoader.java @@ -18,7 +18,7 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; /** * @deprecated Is internal API diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java index aa90355377..6bcf914536 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java @@ -26,10 +26,10 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; +import net.sourceforge.pmd.lang.rule.RulePriority; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; import net.sourceforge.pmd.reporting.FileAnalysisListener; -import net.sourceforge.pmd.rule.RulePriority; class AbstractRuleTest { 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 4dabeccf99..b3a669ecae 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java @@ -30,10 +30,10 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.SimpleTestTextFile; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.lang.rule.MockRule; +import net.sourceforge.pmd.lang.rule.RuleSet; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.reporting.ReportStats; -import net.sourceforge.pmd.rule.MockRule; -import net.sourceforge.pmd.rule.RuleSet; import net.sourceforge.pmd.util.log.MessageReporter; /** diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java index 8ab1020315..9bb0730f4b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java @@ -33,9 +33,9 @@ import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.cache.FileAnalysisCache; import net.sourceforge.pmd.cache.NoopAnalysisCache; import net.sourceforge.pmd.internal.util.ClasspathClassLoader; +import net.sourceforge.pmd.lang.rule.RulePriority; import net.sourceforge.pmd.renderers.CSVRenderer; import net.sourceforge.pmd.renderers.Renderer; -import net.sourceforge.pmd.rule.RulePriority; class PmdConfigurationTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/PmdCoreTestUtils.java b/pmd-core/src/test/java/net/sourceforge/pmd/PmdCoreTestUtils.java index b6e8d747d1..865b3631bf 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/PmdCoreTestUtils.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/PmdCoreTestUtils.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd; import net.sourceforge.pmd.lang.Dummy2LanguageModule; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageVersion; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; /** * Helper methods. diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/ReportTest.java index 5b3bf0228e..fb88e6034a 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/ReportTest.java @@ -22,11 +22,11 @@ import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.rule.MockRule; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.renderers.XMLRenderer; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; -import net.sourceforge.pmd.rule.Rule; class ReportTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java b/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java index 0c9a3ac4f9..9ba3e4fcb3 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java @@ -10,9 +10,9 @@ import net.sourceforge.pmd.lang.LanguageProcessorRegistry; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.document.TestMessageReporter; -import net.sourceforge.pmd.rule.Rule; -import net.sourceforge.pmd.rule.RuleSet; -import net.sourceforge.pmd.rule.internal.RuleSets; +import net.sourceforge.pmd.lang.rule.Rule; +import net.sourceforge.pmd.lang.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.internal.RuleSets; public final class ReportTestUtil { private ReportTestUtil() { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationComparatorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationComparatorTest.java index 77940a7fc8..dee9169082 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationComparatorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationComparatorTest.java @@ -21,7 +21,7 @@ import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.MockRule; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; class RuleViolationComparatorTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationTest.java index 98f0722a6c..82f2fca175 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationTest.java @@ -21,7 +21,7 @@ import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.MockRule; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; class RuleViolationTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java index e29197bb56..1e13c79676 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java @@ -46,9 +46,9 @@ import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.document.TextFileContent; import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; +import net.sourceforge.pmd.lang.rule.Rule; +import net.sourceforge.pmd.lang.rule.internal.RuleSets; import net.sourceforge.pmd.reporting.FileAnalysisListener; -import net.sourceforge.pmd.rule.Rule; -import net.sourceforge.pmd.rule.internal.RuleSets; class FileAnalysisCacheTest { 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 a4be8f6a8a..f61fa3351a 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 @@ -25,9 +25,9 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.lang.rule.RuleSet; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; -import net.sourceforge.pmd.rule.RuleSet; import net.sourceforge.pmd.util.log.MessageReporter; abstract class AbstractPMDProcessorTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java index 073ee36199..0a3f628f34 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; import net.sourceforge.pmd.PmdAnalysis; -import net.sourceforge.pmd.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSet; class MonoThreadProcessorTest extends AbstractPMDProcessorTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java index 8feda5a284..62120608e3 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java @@ -17,7 +17,7 @@ import net.sourceforge.pmd.PmdAnalysis; import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; -import net.sourceforge.pmd.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSet; class MultiThreadProcessorTest extends AbstractPMDProcessorTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java index bea03e58ff..f100eea85b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java @@ -7,17 +7,17 @@ package net.sourceforge.pmd.lang.rule; import static net.sourceforge.pmd.properties.NumericConstraints.inRange; import net.sourceforge.pmd.RuleContext; +import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; -import net.sourceforge.pmd.rule.RulePriority; /** * This is a Rule implementation which can be used in scenarios where an actual * functional Rule is not needed. For example, during unit testing, or as an * editable surrogate used by IDE plugins. The Language of this Rule defaults to - * Java. + * Dummy. */ public class MockRule extends MockRuleWithNoProperties { @@ -28,11 +28,13 @@ public class MockRule extends MockRuleWithNoProperties { public MockRule() { super(); + setLanguage(DummyLanguageModule.getInstance()); definePropertyDescriptor(PROP); } public MockRule(String name, String description, String message, String ruleSetName, RulePriority priority) { super(name, description, message, ruleSetName, priority); + setLanguage(DummyLanguageModule.getInstance()); definePropertyDescriptor(PROP); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java index 891657072a..6ea3e7e95f 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java @@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.rule; import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; -import net.sourceforge.pmd.rule.RulePriority; /** diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleReferenceTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleReferenceTest.java similarity index 98% rename from pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleReferenceTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleReferenceTest.java index 742e6e54a3..703ff69e6d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleReferenceTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleReferenceTest.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import static net.sourceforge.pmd.PmdCoreTestUtils.dummyLanguage; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -15,11 +15,9 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.Dummy2LanguageModule; import net.sourceforge.pmd.lang.Language; -import net.sourceforge.pmd.lang.rule.MockRule; -import net.sourceforge.pmd.lang.rule.RuleReference; +import net.sourceforge.pmd.lang.rule.internal.RuleSetReference; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; -import net.sourceforge.pmd.rule.internal.RuleSetReference; class RuleReferenceTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryCompatibilityTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryCompatibilityTest.java similarity index 99% rename from pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryCompatibilityTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryCompatibilityTest.java index 6f46cad48b..fb0fc295fa 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryCompatibilityTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryCompatibilityTest.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryDuplicatedRuleLoggingTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryDuplicatedRuleLoggingTest.java similarity index 98% rename from pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryDuplicatedRuleLoggingTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryDuplicatedRuleLoggingTest.java index e305bfe8c9..277624acc7 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryDuplicatedRuleLoggingTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryDuplicatedRuleLoggingTest.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryMessagesTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryMessagesTest.java similarity index 98% rename from pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryMessagesTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryMessagesTest.java index 1091ced2de..5a47249906 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryMessagesTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryMessagesTest.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import static net.sourceforge.pmd.util.CollectionUtil.listOf; import static org.hamcrest.MatcherAssert.assertThat; @@ -11,7 +11,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.lang.rule.MockRule; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; import net.sourceforge.pmd.util.internal.xml.XmlErrorMessages; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryTest.java similarity index 97% rename from pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryTest.java index 63b8580dfa..12806d3336 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetFactoryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryTest.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import static net.sourceforge.pmd.PmdCoreTestUtils.dummyLanguage; import static net.sourceforge.pmd.util.CollectionUtil.listOf; @@ -25,8 +25,6 @@ import java.util.Set; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import net.sourceforge.pmd.lang.rule.MockRule; -import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; @@ -34,8 +32,8 @@ import net.sourceforge.pmd.util.internal.xml.SchemaConstants; import com.github.stefanbirkner.systemlambda.SystemLambda; class RuleSetFactoryTest extends RulesetFactoryTestBase { - private static final String TEST_RULESET_1 = "net/sourceforge/pmd/rule/TestRuleset1.xml"; - private static final String REFERENCE_RULESET = "net/sourceforge/pmd/rule/reference-ruleset.xml"; + private static final String TEST_RULESET_1 = "net/sourceforge/pmd/lang/rule/TestRuleset1.xml"; + private static final String REFERENCE_RULESET = "net/sourceforge/pmd/lang/rule/reference-ruleset.xml"; @Test void testRuleSetFileName() { @@ -782,7 +780,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { void testExternalReferences() { RuleSet rs = loadRuleSet( rulesetXml( - ruleRef("net/sourceforge/pmd/rule/external-reference-ruleset.xml/MockRule") + ruleRef("net/sourceforge/pmd/lang/rule/external-reference-ruleset.xml/MockRule") ) ); assertEquals(1, rs.size()); @@ -859,7 +857,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { @Test void testWrongRuleNameReferenced() { assertCannotParse(rulesetXml( - ruleRef("net/sourceforge/pmd/rule/TestRuleset1.xml/ThisRuleDoesNotExist") + ruleRef("net/sourceforge/pmd/lang/rule/TestRuleset1.xml/ThisRuleDoesNotExist") )); } @@ -897,7 +895,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:schemaLocation=\"http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd\">\n" + " Custom ruleset for tests\n" - + " \n" + + " \n" + " \n" + " \n" + "\n"); assertEquals(4, ruleset.getRules().size()); @@ -998,7 +996,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { + " testdesc\n" + " \n" + + " ref=\"net/sourceforge/pmd/lang/rule/TestRuleset1.xml/MockRule1\" message=\"TestMessageOverride\"> \n" + "\n" + " \n" + ""; @@ -1008,14 +1006,14 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { + "\n" + " testdesc\n" + " \n" + + " ref=\"net/sourceforge/pmd/lang/rule/TestRuleset1.xml/FooMockRule1\"> \n" + " \n" + ""; private static final String REF_OVERRIDE_ORIGINAL_NAME_ONE_ELEM = "\n" + "\n" + " testdesc\n" - + " \n" + + " \n" + "\n" + ""; @@ -1023,7 +1021,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { + "\n" + " testdesc\n" + " \n" @@ -1043,7 +1041,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { + "\n" + " testdesc\n" + " \n" @@ -1089,7 +1087,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { + "\n" + + "ref=\"net/sourceforge/pmd/lang/rule/TestRuleset1.xml/MockRule1\"/>\n" + " \n" + ""; @@ -1099,7 +1097,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { + "\n" + + "ref=\"net/sourceforge/pmd/lang/rule/TestRuleset2.xml/TestRule\"/>\n" + " 2 \n" + "\n" + " 1 \n" @@ -1159,7 +1157,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { // Note: Update this RuleSet name to a different RuleSet with deprecated // Rules when the Rules are finally removed. - private static final String DEPRECATED_RULE_RULESET_NAME = "net/sourceforge/pmd/rule/TestRuleset1.xml"; + private static final String DEPRECATED_RULE_RULESET_NAME = "net/sourceforge/pmd/lang/rule/TestRuleset1.xml"; // Note: Update this Rule name to a different deprecated Rule when the one // listed here is finally removed. diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetTest.java similarity index 98% rename from pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetTest.java index 6971de6912..6ae48c1964 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetTest.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import static net.sourceforge.pmd.PmdCoreTestUtils.dummyLanguage; import static net.sourceforge.pmd.PmdCoreTestUtils.dummyLanguage2; @@ -50,10 +50,8 @@ import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.document.TextFile; -import net.sourceforge.pmd.lang.rule.RuleReference; -import net.sourceforge.pmd.lang.rule.RuleTargetSelector; -import net.sourceforge.pmd.rule.RuleSet.RuleSetBuilder; -import net.sourceforge.pmd.rule.internal.RuleSets; +import net.sourceforge.pmd.lang.rule.RuleSet.RuleSetBuilder; +import net.sourceforge.pmd.lang.rule.internal.RuleSets; class RuleSetTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetWriterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetWriterTest.java similarity index 94% rename from pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetWriterTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetWriterTest.java index 87d314cf7a..916cf559b4 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RuleSetWriterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetWriterTest.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import static net.sourceforge.pmd.util.CollectionUtil.mapOf; import static org.hamcrest.MatcherAssert.assertThat; @@ -18,10 +18,8 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.lang.rule.RuleReference; -import net.sourceforge.pmd.lang.rule.XPathRule; -import net.sourceforge.pmd.rule.RuleSet.RuleSetBuilder; -import net.sourceforge.pmd.rule.internal.RuleSetReference; +import net.sourceforge.pmd.lang.rule.RuleSet.RuleSetBuilder; +import net.sourceforge.pmd.lang.rule.internal.RuleSetReference; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; /** @@ -60,7 +58,7 @@ class RuleSetWriterTest extends RulesetFactoryTestBase { */ @Test void testWrite() throws Exception { - RuleSet braces = new RuleSetLoader().loadFromResource("net/sourceforge/pmd/rule/TestRuleset1.xml"); + RuleSet braces = new RuleSetLoader().loadFromResource("net/sourceforge/pmd/lang/rule/TestRuleset1.xml"); RuleSet ruleSet = new RuleSetBuilder(new Random().nextLong()) .withName("ruleset") .withDescription("ruleset description") diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RulesetFactoryTestBase.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RulesetFactoryTestBase.java similarity index 99% rename from pmd-core/src/test/java/net/sourceforge/pmd/rule/RulesetFactoryTestBase.java rename to pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RulesetFactoryTestBase.java index 39c078b1a8..c00fb426de 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/rule/RulesetFactoryTestBase.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RulesetFactoryTestBase.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import static net.sourceforge.pmd.util.CollectionUtil.buildMap; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java index dd0059fdab..5bc0803271 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java @@ -21,7 +21,6 @@ import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; import net.sourceforge.pmd.lang.ast.DummyNodeWithDeprecatedAttribute; import net.sourceforge.pmd.lang.document.TextRegion; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; -import net.sourceforge.pmd.rule.Rule; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/rule/internal/RuleSetReferenceIdTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReferenceIdTest.java similarity index 99% rename from pmd-core/src/test/java/net/sourceforge/pmd/rule/internal/RuleSetReferenceIdTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReferenceIdTest.java index e55828e8b8..501470c38c 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/rule/internal/RuleSetReferenceIdTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReferenceIdTest.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule.internal; +package net.sourceforge.pmd.lang.rule.internal; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.findAll; 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 dbfde85c78..4ce3c2e1f1 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 @@ -39,8 +39,8 @@ import net.sourceforge.pmd.lang.ast.RootNode; 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.rule.Rule; -import net.sourceforge.pmd.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.Rule; +import net.sourceforge.pmd.lang.rule.RuleSet; import net.sourceforge.pmd.util.ContextedAssertionError; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java index 204a1b6bd8..a0ce4f10fd 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java @@ -13,8 +13,8 @@ import java.util.ArrayList; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.rule.Rule; -import net.sourceforge.pmd.rule.RulesetFactoryTestBase; +import net.sourceforge.pmd.lang.rule.Rule; +import net.sourceforge.pmd.lang.rule.RulesetFactoryTestBase; import net.sourceforge.pmd.util.internal.xml.XmlErrorMessages; /** diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java index cb98fafa56..1b754e5305 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java @@ -35,10 +35,10 @@ import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; +import net.sourceforge.pmd.lang.rule.Rule; +import net.sourceforge.pmd.lang.rule.RulePriority; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; -import net.sourceforge.pmd.rule.Rule; -import net.sourceforge.pmd.rule.RulePriority; abstract class AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java index 13c8c3d9c2..29380c4fff 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java @@ -12,8 +12,8 @@ import java.util.function.Consumer; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.reporting.FileAnalysisListener; -import net.sourceforge.pmd.rule.Rule; import com.github.stefanbirkner.systemlambda.SystemLambda; import com.google.gson.Gson; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java index 894c24fb58..df0c8d7e51 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java @@ -26,7 +26,7 @@ import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.util.CollectionUtil; class YAHTMLRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java index 3da7d7b0da..694716b5b4 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java @@ -27,8 +27,8 @@ import net.sourceforge.pmd.cache.NoopAnalysisCache; import net.sourceforge.pmd.lang.ast.FileAnalysisException; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.document.FileId; -import net.sourceforge.pmd.rule.Rule; -import net.sourceforge.pmd.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.Rule; +import net.sourceforge.pmd.lang.rule.RuleSet; class GlobalAnalysisListenerTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/rule/MockRule.java b/pmd-core/src/test/java/net/sourceforge/pmd/rule/MockRule.java deleted file mode 100644 index 93395bc1dc..0000000000 --- a/pmd-core/src/test/java/net/sourceforge/pmd/rule/MockRule.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -package net.sourceforge.pmd.rule; - -import net.sourceforge.pmd.lang.DummyLanguageModule; - -public class MockRule extends net.sourceforge.pmd.lang.rule.MockRule { - public MockRule() { - super(); - setLanguage(DummyLanguageModule.getInstance()); - } - - public MockRule(String name, String description, String message, String ruleSetName, RulePriority priority) { - super(name, description, message, ruleSetName, priority); - setLanguage(DummyLanguageModule.getInstance()); - } - - public MockRule(String name, String description, String message, String ruleSetName) { - super(name, description, message, ruleSetName); - setLanguage(DummyLanguageModule.getInstance()); - } -} diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset1.xml b/pmd-core/src/test/resources/net/sourceforge/pmd/lang/rule/TestRuleset1.xml similarity index 88% rename from pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset1.xml rename to pmd-core/src/test/resources/net/sourceforge/pmd/lang/rule/TestRuleset1.xml index feb2f9396d..b5090aaa8a 100644 --- a/pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset1.xml +++ b/pmd-core/src/test/resources/net/sourceforge/pmd/lang/rule/TestRuleset1.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd"> - Ruleset used by test net.sourceforge.pmd.rule.RuleSetWriter and RuleSetFactoryTest + Ruleset used by test net.sourceforge.pmd.lang.rule.RuleSetWriter and RuleSetFactoryTest - + - + diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset2.xml b/pmd-core/src/test/resources/net/sourceforge/pmd/lang/rule/TestRuleset2.xml similarity index 100% rename from pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset2.xml rename to pmd-core/src/test/resources/net/sourceforge/pmd/lang/rule/TestRuleset2.xml diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset3.xml b/pmd-core/src/test/resources/net/sourceforge/pmd/lang/rule/TestRuleset3.xml similarity index 100% rename from pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset3.xml rename to pmd-core/src/test/resources/net/sourceforge/pmd/lang/rule/TestRuleset3.xml diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset4.xml b/pmd-core/src/test/resources/net/sourceforge/pmd/lang/rule/TestRuleset4.xml similarity index 100% rename from pmd-core/src/test/resources/net/sourceforge/pmd/rule/TestRuleset4.xml rename to pmd-core/src/test/resources/net/sourceforge/pmd/lang/rule/TestRuleset4.xml diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/rule/external-reference-ruleset.xml b/pmd-core/src/test/resources/net/sourceforge/pmd/lang/rule/external-reference-ruleset.xml similarity index 89% rename from pmd-core/src/test/resources/net/sourceforge/pmd/rule/external-reference-ruleset.xml rename to pmd-core/src/test/resources/net/sourceforge/pmd/lang/rule/external-reference-ruleset.xml index d9a32bbb12..c5161219e7 100644 --- a/pmd-core/src/test/resources/net/sourceforge/pmd/rule/external-reference-ruleset.xml +++ b/pmd-core/src/test/resources/net/sourceforge/pmd/lang/rule/external-reference-ruleset.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd"> - Ruleset used by test net.sourceforge.pmd.rule.RuleSetFactoryTest + Ruleset used by test net.sourceforge.pmd.lang.rule.RuleSetFactoryTest - This ruleset checks my code for bad stuff. Used by net.sourceforge.pmd.rule.RuleSetFactoryTest. + This ruleset checks my code for bad stuff. Used by net.sourceforge.pmd.lang.rule.RuleSetFactoryTest. - + - + 2 - + - + - + - + 5 - + 2 diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java index 3eb570bc1b..256e605904 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java @@ -18,8 +18,8 @@ import java.util.List; import java.util.regex.Pattern; import net.sourceforge.pmd.internal.util.IOUtil; -import net.sourceforge.pmd.rule.RuleSet; -import net.sourceforge.pmd.rule.RuleSetLoader; +import net.sourceforge.pmd.lang.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; public final class GenerateRuleDocsCmd { diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java index 80af73520c..f7015294e8 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java @@ -35,13 +35,13 @@ import org.slf4j.LoggerFactory; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.lang.rule.RuleReference; +import net.sourceforge.pmd.lang.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSetLoadException; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.properties.PropertyDescriptor; -import net.sourceforge.pmd.rule.Rule; -import net.sourceforge.pmd.rule.RuleSet; -import net.sourceforge.pmd.rule.RuleSetLoadException; -import net.sourceforge.pmd.rule.RuleSetLoader; public class RuleDocGenerator { private static final Logger LOG = LoggerFactory.getLogger(RuleDocGenerator.class); diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java index a575efd90a..156946cfbc 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java @@ -11,9 +11,9 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.SystemUtils; import net.sourceforge.pmd.internal.util.IOUtil; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.lang.rule.RuleReference; -import net.sourceforge.pmd.rule.Rule; -import net.sourceforge.pmd.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSet; public final class RuleSetUtils { diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/SidebarGenerator.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/SidebarGenerator.java index d514aac017..cc573607b0 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/SidebarGenerator.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/SidebarGenerator.java @@ -26,7 +26,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; import org.yaml.snakeyaml.representer.Representer; import net.sourceforge.pmd.lang.Language; -import net.sourceforge.pmd.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSet; public class SidebarGenerator { private static final String SIDEBAR_YML = "docs/_data/sidebars/pmd_sidebar.yml"; diff --git a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java index 726b63120c..b593280141 100644 --- a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java +++ b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java @@ -21,8 +21,8 @@ import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.docs.MockedFileWriter.FileEntry; import net.sourceforge.pmd.internal.util.IOUtil; -import net.sourceforge.pmd.rule.RuleSet; -import net.sourceforge.pmd.rule.RuleSetLoader; +import net.sourceforge.pmd.lang.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; class RuleDocGeneratorTest { diff --git a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java index 6bfa114a1a..8d54ab6a00 100644 --- a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java +++ b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java @@ -15,7 +15,7 @@ import java.util.List; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.internal.util.IOUtil; -import net.sourceforge.pmd.rule.RuleSetLoader; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; class RuleSetResolverTest { diff --git a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java index cdbce4d764..68ce308d5b 100644 --- a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java +++ b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java @@ -29,7 +29,7 @@ import org.yaml.snakeyaml.representer.Representer; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; -import net.sourceforge.pmd.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSet; class SidebarGeneratorTest { private MockedFileWriter writer = new MockedFileWriter(); diff --git a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlJavaRuleTest.java b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlJavaRuleTest.java index 5a02e639f3..33c802b857 100644 --- a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlJavaRuleTest.java +++ b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlJavaRuleTest.java @@ -16,8 +16,8 @@ import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.html.ast.ASTHtmlElement; import net.sourceforge.pmd.lang.html.ast.HtmlParsingHelper; import net.sourceforge.pmd.lang.html.rule.AbstractHtmlRule; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.lang.rule.xpath.Attribute; -import net.sourceforge.pmd.rule.Rule; class HtmlJavaRuleTest { // from https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.js_props_getter diff --git a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/RuleSetFactoryTest.java b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/RuleSetFactoryTest.java index 4e479ff041..f3255130e1 100644 --- a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/RuleSetFactoryTest.java +++ b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.html; -import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest; class RuleSetFactoryTest extends AbstractRuleSetFactoryTest { // no additional tests yet diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/AnnotationSuppressionUtil.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/AnnotationSuppressionUtil.java index bc8615dd38..187fa37a02 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/AnnotationSuppressionUtil.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/AnnotationSuppressionUtil.java @@ -31,7 +31,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; import net.sourceforge.pmd.lang.java.ast.Annotatable; import net.sourceforge.pmd.lang.java.rule.errorprone.ImplicitSwitchFallThroughRule; import net.sourceforge.pmd.lang.java.types.TypeTestUtil; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; /** * Helper methods to suppress violations based on annotations. diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/ExcludeLinesTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/ExcludeLinesTest.java index effe537a49..621ce36d0f 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/ExcludeLinesTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/ExcludeLinesTest.java @@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.java.BaseParserTest; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; class ExcludeLinesTest extends BaseParserTest { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/ReportTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/ReportTest.java index e4c74ece70..b55f2fd1bb 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/ReportTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/ReportTest.java @@ -14,7 +14,7 @@ import java.util.regex.Pattern; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.java.JavaParsingHelper; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; class ReportTest { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/PMD5RulesetTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/PMD5RulesetTest.java index 25714b6e53..9675d88641 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/PMD5RulesetTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/PMD5RulesetTest.java @@ -9,8 +9,8 @@ import static org.junit.jupiter.api.Assertions.assertNull; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.rule.RuleSet; -import net.sourceforge.pmd.rule.RuleSetLoader; +import net.sourceforge.pmd.lang.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; class PMD5RulesetTest { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/QuickstartRulesetTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/QuickstartRulesetTest.java index eb5b22ef17..d616ef489e 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/QuickstartRulesetTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/QuickstartRulesetTest.java @@ -9,9 +9,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; -import net.sourceforge.pmd.rule.RuleSet; -import net.sourceforge.pmd.rule.RuleSetLoader; +import net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.lang.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/RuleSetFactoryTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/RuleSetFactoryTest.java index f11518cf1d..eac601291e 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/RuleSetFactoryTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.java; -import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest; /** * Test java's rulesets diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java index 8d19b6a867..41f4798455 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java @@ -19,6 +19,7 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.JavaParsingHelper; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.JavaNode; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathHandler; @@ -26,7 +27,6 @@ import net.sourceforge.pmd.lang.rule.xpath.internal.DeprecatedAttrLogger; import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; -import net.sourceforge.pmd.rule.Rule; /** * @author daniels diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredTest.java index e2fa5092ea..4c026b25c3 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredTest.java @@ -12,8 +12,8 @@ import java.util.List; import org.junit.jupiter.api.Test; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.properties.PropertyDescriptor; -import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.testframework.PmdRuleTst; class CommentRequiredTest extends PmdRuleTst { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java index 3010f64656..2645a7a2f2 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java @@ -19,11 +19,11 @@ import net.sourceforge.pmd.lang.ast.FileAnalysisException; import net.sourceforge.pmd.lang.ast.test.TestUtilsKt; import net.sourceforge.pmd.lang.java.BaseParserTest; import net.sourceforge.pmd.lang.java.JavaLanguageModule; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; -import net.sourceforge.pmd.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFunctionsTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFunctionsTest.java index 4f5f019e25..eb78a19c75 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFunctionsTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFunctionsTest.java @@ -10,8 +10,8 @@ import static org.hamcrest.MatcherAssert.assertThat; import org.junit.jupiter.api.Test; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase; -import net.sourceforge.pmd.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/HasAnnotationXPathTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/HasAnnotationXPathTest.java index 4d41253b87..642ba78047 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/HasAnnotationXPathTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/HasAnnotationXPathTest.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.java.rule.xpath.internal; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MatchesSignatureXPathTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MatchesSignatureXPathTest.java index a7e180a6d9..584d80fbbd 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MatchesSignatureXPathTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MatchesSignatureXPathTest.java @@ -10,9 +10,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.LanguageProcessor; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase; -import net.sourceforge.pmd.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/NodeIsFunctionTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/NodeIsFunctionTest.java index 70fb0e1e2e..99af2c8b52 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/NodeIsFunctionTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/NodeIsFunctionTest.java @@ -10,8 +10,8 @@ import static org.hamcrest.MatcherAssert.assertThat; import org.junit.jupiter.api.Test; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase; -import net.sourceforge.pmd.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/TypeIsFunctionTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/TypeIsFunctionTest.java index e626b56a4f..5f2d90b5b0 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/TypeIsFunctionTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/TypeIsFunctionTest.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.java.rule.xpath.internal; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/XPathMetricFunctionTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/XPathMetricFunctionTest.java index 1c1c3b5ca5..ef559f1669 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/XPathMetricFunctionTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/XPathMetricFunctionTest.java @@ -9,7 +9,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-javascript/src/test/java/net/sourceforge/pmd/ReportTest.java b/pmd-javascript/src/test/java/net/sourceforge/pmd/ReportTest.java index 2d7cd6f5bf..ac664f3725 100644 --- a/pmd-javascript/src/test/java/net/sourceforge/pmd/ReportTest.java +++ b/pmd-javascript/src/test/java/net/sourceforge/pmd/ReportTest.java @@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.ecmascript.ast.ASTFunctionNode; import net.sourceforge.pmd.lang.ecmascript.ast.EcmascriptParserTestBase; import net.sourceforge.pmd.lang.ecmascript.rule.AbstractEcmascriptRule; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; class ReportTest extends EcmascriptParserTestBase { diff --git a/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/RuleSetFactoryTest.java b/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/RuleSetFactoryTest.java index 46a9adae40..32b1211d9d 100644 --- a/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/RuleSetFactoryTest.java +++ b/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.ecmascript; -import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest; /** * Test javascript's rulesets diff --git a/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/RuleSetFactoryTest.java b/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/RuleSetFactoryTest.java index df499f7f42..531bde227b 100644 --- a/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/RuleSetFactoryTest.java +++ b/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.jsp; -import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest; /** * Test jsp's rulesets diff --git a/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/ast/XPathJspRuleTest.java b/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/ast/XPathJspRuleTest.java index 3202ba6231..c560a291d5 100644 --- a/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/ast/XPathJspRuleTest.java +++ b/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/ast/XPathJspRuleTest.java @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.RuleViolation; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; class XPathJspRuleTest extends AbstractJspNodesTst { diff --git a/pmd-kotlin/src/test/java/net/sourceforge/pmd/lang/kotlin/RuleSetFactoryTest.java b/pmd-kotlin/src/test/java/net/sourceforge/pmd/lang/kotlin/RuleSetFactoryTest.java index 3faa6b6ab2..190b8401ef 100644 --- a/pmd-kotlin/src/test/java/net/sourceforge/pmd/lang/kotlin/RuleSetFactoryTest.java +++ b/pmd-kotlin/src/test/java/net/sourceforge/pmd/lang/kotlin/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.kotlin; -import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest; class RuleSetFactoryTest extends AbstractRuleSetFactoryTest { // no additional tests yet diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt index 4b00719190..5b285b7f66 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt @@ -16,8 +16,8 @@ import net.sourceforge.pmd.lang.document.TextDocument import net.sourceforge.pmd.lang.rule.XPathRule import net.sourceforge.pmd.lang.rule.xpath.XPathVersion import net.sourceforge.pmd.reporting.GlobalAnalysisListener -import net.sourceforge.pmd.rule.Rule -import net.sourceforge.pmd.rule.RuleSet +import net.sourceforge.pmd.lang.rule.Rule +import net.sourceforge.pmd.lang.rule.RuleSet import java.io.InputStream import java.nio.charset.StandardCharsets import java.nio.file.Files diff --git a/pmd-modelica/src/test/java/net/sourceforge/pmd/lang/modelica/RuleSetFactoryTest.java b/pmd-modelica/src/test/java/net/sourceforge/pmd/lang/modelica/RuleSetFactoryTest.java index 6932fa08a1..53fc1834d1 100644 --- a/pmd-modelica/src/test/java/net/sourceforge/pmd/lang/modelica/RuleSetFactoryTest.java +++ b/pmd-modelica/src/test/java/net/sourceforge/pmd/lang/modelica/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.modelica; -import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest; class RuleSetFactoryTest extends AbstractRuleSetFactoryTest { // no additional tests yet diff --git a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/RuleSetFactoryTest.java b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/RuleSetFactoryTest.java index 59518c00bd..fbf61181a6 100644 --- a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/RuleSetFactoryTest.java +++ b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.plsql; -import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest; /** * Test plsql's rulesets diff --git a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateToCharTest.java b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateToCharTest.java index e795cdacab..044a86be62 100644 --- a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateToCharTest.java +++ b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateToCharTest.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.plsql.rule.errorprone; import java.util.Collections; import java.util.List; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.testframework.PmdRuleTst; class ToDateToCharTest extends PmdRuleTst { diff --git a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateWithoutDateFormatTest.java b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateWithoutDateFormatTest.java index 1f2fc9e7b4..a70adbc735 100644 --- a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateWithoutDateFormatTest.java +++ b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToDateWithoutDateFormatTest.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.plsql.rule.errorprone; import java.util.Collections; import java.util.List; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.testframework.PmdRuleTst; class ToDateWithoutDateFormatTest extends PmdRuleTst { diff --git a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToTimestampWithoutDateFormatTest.java b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToTimestampWithoutDateFormatTest.java index ad347a7756..730292e731 100644 --- a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToTimestampWithoutDateFormatTest.java +++ b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/rule/errorprone/ToTimestampWithoutDateFormatTest.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.plsql.rule.errorprone; import java.util.Collections; import java.util.List; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.testframework.PmdRuleTst; class ToTimestampWithoutDateFormatTest extends PmdRuleTst { diff --git a/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/RulesetFactoryTest.java b/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/RulesetFactoryTest.java index 93ac55200c..a7965850f3 100644 --- a/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/RulesetFactoryTest.java +++ b/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/RulesetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.scala; -import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest; /** * Test scala rulesets diff --git a/pmd-swift/src/test/java/net/sourceforge/pmd/lang/swift/RuleSetFactoryTest.java b/pmd-swift/src/test/java/net/sourceforge/pmd/lang/swift/RuleSetFactoryTest.java index bd9fb82f51..320fbf91a5 100644 --- a/pmd-swift/src/test/java/net/sourceforge/pmd/lang/swift/RuleSetFactoryTest.java +++ b/pmd-swift/src/test/java/net/sourceforge/pmd/lang/swift/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.swift; -import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest; class RuleSetFactoryTest extends AbstractRuleSetFactoryTest { // no additional unit tests diff --git a/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/BaseTestParserImpl.java b/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/BaseTestParserImpl.java index ec32dd3723..19a4387710 100644 --- a/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/BaseTestParserImpl.java +++ b/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/BaseTestParserImpl.java @@ -23,9 +23,9 @@ import org.w3c.dom.Node; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertySource; -import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.test.schema.TestSchemaParser.PmdXmlReporter; import com.github.oowekyala.ooxml.DomUtils; diff --git a/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/RuleTestDescriptor.java b/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/RuleTestDescriptor.java index ee73bdfc5f..3e4eb348f1 100644 --- a/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/RuleTestDescriptor.java +++ b/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/RuleTestDescriptor.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.Properties; import net.sourceforge.pmd.lang.LanguageVersion; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; /** * @author Clément Fournier diff --git a/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/TestSchemaParser.java b/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/TestSchemaParser.java index 78b1556f02..a9a21d6fdb 100644 --- a/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/TestSchemaParser.java +++ b/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/TestSchemaParser.java @@ -14,7 +14,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.xml.sax.InputSource; import net.sourceforge.pmd.annotation.Experimental; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; import com.github.oowekyala.ooxml.messages.NiceXmlMessageSpec; import com.github.oowekyala.ooxml.messages.OoxmlFacade; diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractLanguageVersionTest.java b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractLanguageVersionTest.java index c3eed72f00..9121161096 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractLanguageVersionTest.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractLanguageVersionTest.java @@ -19,8 +19,8 @@ import net.sourceforge.pmd.ant.SourceLanguage; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersion; -import net.sourceforge.pmd.rule.RuleSet; -import net.sourceforge.pmd.rule.RuleSetLoader; +import net.sourceforge.pmd.lang.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; /** * Base test class for {@link LanguageVersion} implementations.
diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/rule/AbstractRuleSetFactoryTest.java b/pmd-test/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRuleSetFactoryTest.java similarity index 99% rename from pmd-test/src/main/java/net/sourceforge/pmd/rule/AbstractRuleSetFactoryTest.java rename to pmd-test/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRuleSetFactoryTest.java index 067e1cd78a..2a7cf0a68c 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/rule/AbstractRuleSetFactoryTest.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRuleSetFactoryTest.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.rule; +package net.sourceforge.pmd.lang.rule; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.emptyString; @@ -45,8 +45,6 @@ import org.xml.sax.helpers.DefaultHandler; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; -import net.sourceforge.pmd.lang.rule.RuleReference; -import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.util.log.internal.MessageReporterBase; diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/PmdRuleTst.java b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/PmdRuleTst.java index a614049af2..b9bd7f5555 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/PmdRuleTst.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/PmdRuleTst.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.testframework; import java.util.Collections; import java.util.List; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; public class PmdRuleTst extends RuleTst { diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java index 08d48ff1e7..93064738d9 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java @@ -31,13 +31,13 @@ import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.TextFile; +import net.sourceforge.pmd.lang.rule.Rule; +import net.sourceforge.pmd.lang.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSetLoadException; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.renderers.TextRenderer; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; -import net.sourceforge.pmd.rule.Rule; -import net.sourceforge.pmd.rule.RuleSet; -import net.sourceforge.pmd.rule.RuleSetLoadException; -import net.sourceforge.pmd.rule.RuleSetLoader; import net.sourceforge.pmd.test.schema.RuleTestCollection; import net.sourceforge.pmd.test.schema.RuleTestDescriptor; import net.sourceforge.pmd.test.schema.TestSchemaParser; diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/SimpleAggregatorTst.java b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/SimpleAggregatorTst.java index ec145ec27a..1d067dfb74 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/SimpleAggregatorTst.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/SimpleAggregatorTst.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.testframework; import java.util.ArrayList; import java.util.List; -import net.sourceforge.pmd.rule.Rule; +import net.sourceforge.pmd.lang.rule.Rule; /** * Simple setup for a rule unit test, diff --git a/pmd-test/src/test/java/net/sourceforge/pmd/testframework/RuleTstTest.java b/pmd-test/src/test/java/net/sourceforge/pmd/testframework/RuleTstTest.java index d0e6c31f6d..91df5f7400 100644 --- a/pmd-test/src/test/java/net/sourceforge/pmd/testframework/RuleTstTest.java +++ b/pmd-test/src/test/java/net/sourceforge/pmd/testframework/RuleTstTest.java @@ -23,8 +23,8 @@ import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.lang.rule.RuleTargetSelector; -import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.test.schema.RuleTestDescriptor; class RuleTstTest { diff --git a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/RuleSetFactoryTest.java b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/RuleSetFactoryTest.java index ff5782044f..4023f74ed7 100644 --- a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/RuleSetFactoryTest.java +++ b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/RuleSetFactoryTest.java @@ -5,7 +5,7 @@ package net.sourceforge.pmd.lang.vf; import net.sourceforge.pmd.lang.apex.ApexLanguageModule; -import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest; class RuleSetFactoryTest extends AbstractRuleSetFactoryTest { RuleSetFactoryTest() { diff --git a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/rule/security/VfUnescapeElTest.java b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/rule/security/VfUnescapeElTest.java index b9cec819c2..400b0dd7aa 100644 --- a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/rule/security/VfUnescapeElTest.java +++ b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/rule/security/VfUnescapeElTest.java @@ -14,9 +14,9 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.lang.vf.VFTestUtils; import net.sourceforge.pmd.lang.vf.ast.VfParsingHelper; -import net.sourceforge.pmd.rule.Rule; import net.sourceforge.pmd.testframework.PmdRuleTst; class VfUnescapeElTest extends PmdRuleTst { diff --git a/pmd-vm/src/test/java/net/sourceforge/pmd/lang/vm/RuleSetFactoryTest.java b/pmd-vm/src/test/java/net/sourceforge/pmd/lang/vm/RuleSetFactoryTest.java index 987532babc..63278e21d7 100644 --- a/pmd-vm/src/test/java/net/sourceforge/pmd/lang/vm/RuleSetFactoryTest.java +++ b/pmd-vm/src/test/java/net/sourceforge/pmd/lang/vm/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.vm; -import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest; /** * Test velocity's rulesets. diff --git a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/RuleSetFactoryTest.java b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/RuleSetFactoryTest.java index 9b9934c738..4d4ce31948 100644 --- a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/RuleSetFactoryTest.java +++ b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/RuleSetFactoryTest.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.xml; -import net.sourceforge.pmd.rule.AbstractRuleSetFactoryTest; +import net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest; /** * Test xml's and xslt's rulesets diff --git a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRuleTest.java b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRuleTest.java index c7925512b4..571900ccdd 100644 --- a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRuleTest.java +++ b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRuleTest.java @@ -10,8 +10,8 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.lang.document.FileId; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.lang.xml.XmlParsingHelper; -import net.sourceforge.pmd.rule.Rule; class XmlXPathRuleTest { From f13cd58c7f8ee1574261a086ac1b941806b23ba7 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 18 Jan 2024 20:27:34 +0100 Subject: [PATCH 07/23] [core] Move classes into n.s.pmd.reporting - Report - RuleContext - RuleViolation - ViolationSuppressor - ParametricRuleViolation Fixes #3903 --- docs/pages/release_notes.md | 12 ++++++++++++ docs/pages/release_notes_pmd7.md | 4 ++-- .../java/net/sourceforge/pmd/ant/Formatter.java | 2 +- .../pmd/lang/apex/ApexLanguageHandler.java | 2 +- .../pmd/lang/apex/ApexViolationSuppressors.java | 8 ++++---- .../pmd/lang/apex/rule/AbstractApexRule.java | 2 +- .../rule/design/StdCyclomaticComplexityRule.java | 2 +- .../apex/rule/security/ApexCRUDViolationRule.java | 2 +- .../rule/security/ApexSharingViolationsRule.java | 2 +- .../pmd/lang/apex/SuppressWarningsTest.java | 4 ++-- .../pmd/lang/apex/rule/AbstractApexRuleTest.java | 2 +- .../pmd/lang/apex/rule/ApexXPathRuleTest.java | 2 +- .../lang/apex/rule/design/UnusedMethodTest.java | 4 ++-- .../ApexSharingViolationsNestedClassTest.java | 4 ++-- .../pmd/cli/internal/ProgressBarListener.java | 4 ++-- .../java/net/sourceforge/pmd/cli/PmdCliTest.java | 2 +- .../main/java/net/sourceforge/pmd/PmdAnalysis.java | 3 ++- .../src/main/java/net/sourceforge/pmd/Rule.java | 1 + .../pmd/cache/AbstractAnalysisCache.java | 4 ++-- .../net/sourceforge/pmd/cache/AnalysisCache.java | 2 +- .../net/sourceforge/pmd/cache/AnalysisResult.java | 2 +- .../sourceforge/pmd/cache/CachedRuleViolation.java | 2 +- .../sourceforge/pmd/cache/FileAnalysisCache.java | 2 +- .../sourceforge/pmd/cache/NoopAnalysisCache.java | 2 +- .../pmd/lang/LanguageVersionHandler.java | 2 +- .../net/sourceforge/pmd/lang/document/FileId.java | 2 +- .../pmd/lang/document/FileLocation.java | 2 +- .../net/sourceforge/pmd/lang/impl/PmdRunnable.java | 4 ++-- .../pmd/lang/rule/AbstractDelegateRule.java | 2 +- .../sourceforge/pmd/lang/rule/AbstractRule.java | 2 +- .../pmd/lang/rule/AbstractVisitorRule.java | 2 +- .../net/sourceforge/pmd/lang/rule/XPathRule.java | 2 +- .../pmd/lang/rule/internal/RuleApplicator.java | 4 ++-- .../renderers/AbstractAccumulatingRenderer.java | 6 +++--- .../renderers/AbstractIncrementingRenderer.java | 4 ++-- .../net/sourceforge/pmd/renderers/CSVRenderer.java | 2 +- .../pmd/renderers/CodeClimateRenderer.java | 2 +- .../sourceforge/pmd/renderers/EmacsRenderer.java | 2 +- .../sourceforge/pmd/renderers/EmptyRenderer.java | 2 +- .../sourceforge/pmd/renderers/HTMLRenderer.java | 6 +++--- .../sourceforge/pmd/renderers/IDEAJRenderer.java | 2 +- .../sourceforge/pmd/renderers/JsonRenderer.java | 6 +++--- .../net/sourceforge/pmd/renderers/Renderer.java | 14 +++++++------- .../sourceforge/pmd/renderers/SarifRenderer.java | 4 ++-- .../pmd/renderers/SummaryHTMLRenderer.java | 4 ++-- .../pmd/renderers/TextColorRenderer.java | 8 ++++---- .../sourceforge/pmd/renderers/TextPadRenderer.java | 2 +- .../sourceforge/pmd/renderers/TextRenderer.java | 4 ++-- .../sourceforge/pmd/renderers/VBHTMLRenderer.java | 4 ++-- .../net/sourceforge/pmd/renderers/XMLRenderer.java | 4 ++-- .../sourceforge/pmd/renderers/YAHTMLRenderer.java | 4 ++-- .../renderers/internal/sarif/SarifLogBuilder.java | 4 ++-- .../pmd/reporting/FileAnalysisListener.java | 6 ++---- .../pmd/reporting/GlobalAnalysisListener.java | 7 +++---- .../pmd/reporting/NoopFileListener.java | 2 -- .../ParametricRuleViolation.java | 6 +----- .../sourceforge/pmd/{ => reporting}/Report.java | 14 ++++++-------- .../pmd/reporting/ReportStatsListener.java | 3 +-- .../net/sourceforge/pmd/reporting/Reportable.java | 1 - .../pmd/{ => reporting}/RuleContext.java | 10 +++------- .../pmd/{ => reporting}/RuleViolation.java | 5 ++--- .../pmd/reporting/ViolationDecorator.java | 1 - .../pmd/{ => reporting}/ViolationSuppressor.java | 7 +++---- .../sourceforge/pmd/reporting/package-info.java | 4 ---- .../java/net/sourceforge/pmd/AbstractRuleTest.java | 6 ++++-- .../src/test/java/net/sourceforge/pmd/FooRule.java | 1 + .../java/net/sourceforge/pmd/PmdAnalysisTest.java | 2 ++ .../test/java/net/sourceforge/pmd/RuleSetTest.java | 7 +++++-- .../pmd/cache/FileAnalysisCacheTest.java | 4 ++-- .../sourceforge/pmd/lang/DummyLanguageModule.java | 2 +- .../pmd/lang/impl/AbstractPMDProcessorTest.java | 6 +++--- .../pmd/lang/impl/MultiThreadProcessorTest.java | 2 +- .../net/sourceforge/pmd/lang/rule/MockRule.java | 2 +- .../pmd/lang/rule/MockRuleWithNoProperties.java | 2 +- .../sourceforge/pmd/lang/rule/XPathRuleTest.java | 4 ++-- .../sourceforge/pmd/processor/PmdRunnableTest.java | 6 +++--- .../pmd/renderers/AbstractRendererTest.java | 10 +++++----- .../sourceforge/pmd/renderers/CSVRendererTest.java | 4 ++-- .../pmd/renderers/CodeClimateRendererTest.java | 2 +- .../pmd/renderers/HTMLRendererTest.java | 4 ++-- .../pmd/renderers/JsonRendererTest.java | 8 ++++---- .../pmd/renderers/PapariTextRendererTest.java | 4 ++-- .../pmd/renderers/SarifRendererTest.java | 2 +- .../pmd/renderers/SummaryHTMLRendererTest.java | 6 +++--- .../pmd/renderers/TextRendererTest.java | 4 ++-- .../pmd/renderers/VBHTMLRendererTest.java | 4 ++-- .../sourceforge/pmd/renderers/XMLRendererTest.java | 10 +++++----- .../pmd/renderers/XSLTRendererTest.java | 6 +++--- .../pmd/renderers/YAHTMLRendererTest.java | 8 ++++---- .../pmd/reporting/GlobalAnalysisListenerTest.java | 1 - .../pmd/{ => reporting}/ReportTest.java | 6 ++---- .../pmd/{ => reporting}/ReportTestUtil.java | 5 ++++- .../pmd/{ => reporting}/RuleContextTest.java | 5 +++-- .../RuleViolationComparatorTest.java | 6 +++--- .../pmd/{ => reporting}/RuleViolationTest.java | 7 ++++--- .../pmd/util/FooRuleWithLanguageSetInJava.java | 2 +- .../pmd/lang/html/rule/AbstractHtmlRule.java | 2 +- .../UnnecessaryTypeAttributeRule.java | 2 +- .../UseAltAttributeForImagesRule.java | 2 +- .../pmd/lang/html/HtmlJavaRuleTest.java | 6 +++--- .../pmd/lang/html/HtmlXPathRuleTest.java | 4 ++-- .../java/internal/AnnotationSuppressionUtil.java | 8 ++++---- .../lang/java/internal/JavaLanguageProcessor.java | 2 +- .../lang/java/internal/JavaViolationDecorator.java | 2 +- .../pmd/lang/java/rule/AbstractJavaRule.java | 2 +- .../bestpractices/AccessorClassGenerationRule.java | 2 +- .../AccessorMethodGenerationRule.java | 2 +- .../bestpractices/ArrayIsStoredDirectlyRule.java | 2 +- .../AvoidReassigningLoopVariablesRule.java | 2 +- .../bestpractices/AvoidUsingHardCodedIPRule.java | 2 +- .../rule/bestpractices/GuardLogStatementRule.java | 2 +- .../LiteralsFirstInComparisonsRule.java | 2 +- .../rule/bestpractices/UnusedAssignmentRule.java | 2 +- .../CommentDefaultAccessModifierRule.java | 2 +- .../codestyle/LocalVariableCouldBeFinalRule.java | 2 +- .../codestyle/MethodArgumentCouldBeFinalRule.java | 2 +- .../java/rule/codestyle/UnnecessaryBoxingRule.java | 2 +- .../pmd/lang/java/rule/design/DataClassRule.java | 2 +- .../lang/java/rule/design/LawOfDemeterRule.java | 2 +- .../lang/java/rule/design/NPathComplexityRule.java | 2 +- .../pmd/lang/java/rule/design/NcssCountRule.java | 2 +- .../rule/design/SimplifyBooleanReturnsRule.java | 2 +- .../rule/documentation/CommentContentRule.java | 2 +- .../rule/documentation/CommentRequiredRule.java | 2 +- .../java/rule/documentation/CommentSizeRule.java | 2 +- .../rule/errorprone/AssignmentInOperandRule.java | 2 +- .../errorprone/AvoidDuplicateLiteralsRule.java | 2 +- .../java/rule/errorprone/BrokenNullCheckRule.java | 2 +- .../java/rule/errorprone/CloseResourceRule.java | 2 +- .../ConstructorCallsOverridableMethodRule.java | 2 +- .../rule/errorprone/NonSerializableClassRule.java | 2 +- .../lang/java/rule/internal/TypeResTestRule.java | 2 +- .../multithreading/NonThreadSafeSingletonRule.java | 2 +- .../InefficientStringBufferingRule.java | 2 +- .../java/net/sourceforge/pmd/ExcludeLinesTest.java | 1 + .../test/java/net/sourceforge/pmd/ReportTest.java | 1 + .../pmd/lang/java/SuppressWarningsTest.java | 2 +- .../java/internal/JavaViolationDecoratorTest.java | 8 ++++---- .../pmd/lang/java/rule/DummyJavaRule.java | 2 +- .../pmd/lang/java/rule/XPathRuleTest.java | 4 ++-- .../rule/xpath/internal/BaseXPathFunctionTest.java | 2 +- .../ecmascript/rule/AbstractEcmascriptRule.java | 2 +- .../test/java/net/sourceforge/pmd/ReportTest.java | 1 + .../pmd/lang/ecmascript/DummyJsRule.java | 2 +- .../lang/ecmascript/ast/EcmascriptParserTest.java | 2 +- .../pmd/lang/jsp/rule/AbstractJspRule.java | 2 +- .../rule/codestyle/DuplicateJspImportsRule.java | 2 +- .../pmd/lang/jsp/ast/XPathJspRuleTest.java | 4 ++-- .../pmd/lang/kotlin/AbstractKotlinRule.java | 2 +- .../OverrideBothEqualsAndHashcodeRule.java | 2 +- .../pmd/test/AbstractMetricTestRule.java | 2 +- .../pmd/lang/ast/test/BaseParsingHelper.kt | 1 + .../net/sourceforge/pmd/lang/ast/test/TestUtils.kt | 4 ++-- .../lang/modelica/rule/AbstractModelicaRule.java | 2 +- .../pmd/lang/plsql/rule/AbstractPLSQLRule.java | 2 +- .../pmd/lang/plsql/PLSQLXPathRuleTest.java | 2 +- .../sourceforge/pmd/lang/scala/rule/ScalaRule.java | 2 +- .../pmd/lang/scala/rule/ScalaRuleTest.java | 4 ++-- .../pmd/lang/scala/rule/XPathRuleTest.java | 4 ++-- .../pmd/lang/swift/rule/AbstractSwiftRule.java | 2 +- .../bestpractices/UnavailableFunctionRule.java | 2 +- .../pmd/test/schema/TestSchemaParserTest.java | 2 +- .../net/sourceforge/pmd/testframework/RuleTst.java | 4 ++-- .../sourceforge/pmd/testframework/RuleTstTest.java | 2 +- .../pmd/lang/vf/rule/AbstractVfRule.java | 2 +- .../lang/vf/rule/security/VfUnescapeElTest.java | 4 ++-- .../pmd/lang/vm/rule/AbstractVmRule.java | 2 +- .../pmd/lang/xml/rule/DomXPathRule.java | 2 +- .../pmd/lang/xml/rule/XmlXPathRuleTest.java | 2 +- 169 files changed, 287 insertions(+), 283 deletions(-) rename pmd-core/src/main/java/net/sourceforge/pmd/{lang/rule => reporting}/ParametricRuleViolation.java (93%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => reporting}/Report.java (97%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => reporting}/RuleContext.java (96%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => reporting}/RuleViolation.java (98%) rename pmd-core/src/main/java/net/sourceforge/pmd/{ => reporting}/ViolationSuppressor.java (97%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => reporting}/ReportTest.java (96%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => reporting}/ReportTestUtil.java (90%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => reporting}/RuleContextTest.java (90%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => reporting}/RuleViolationComparatorTest.java (95%) rename pmd-core/src/test/java/net/sourceforge/pmd/{ => reporting}/RuleViolationTest.java (95%) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index cbf09dab12..dffb324832 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -105,6 +105,7 @@ in the Migration Guide. * [#4723](https://github.com/pmd/pmd/issues/4723): \[cli] Launch fails for "bash pmd" * core * [#1027](https://github.com/pmd/pmd/issues/1027): \[core] Apply the new PropertyDescriptor<Pattern> type where applicable + * [#3903](https://github.com/pmd/pmd/issues/3903): \[core] Consolidate `n.s.pmd.reporting` package * [#4674](https://github.com/pmd/pmd/issues/4674): \[core] WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass * [#4694](https://github.com/pmd/pmd/pull/4694): \[core] Fix line/col numbers in TokenMgrError * [#4717](https://github.com/pmd/pmd/issues/4717): \[core] XSLTRenderer doesn't close report file @@ -152,6 +153,16 @@ in the Migration Guide. #### API Changes +**Moved classes/consolidated packages** + +* pmd-core + * Many types have been moved from the base package `net.sourceforge.pmd` into subpackage {% jdoc_package core::reporting %} + * {%jdoc core::reporting.Report %} + * {%jdoc core::reporting.RuleContext %} + * {%jdoc core::reporting.RuleViolation %} + * {%jdoc core::reporting.ViolationSuppressor %} + * {%jdoc core::reporting.ParametricRuleViolation %} (moved from `net.sourcceforge.pmd.lang.rule`) + **Removed classes and methods** The following previously deprecated classes have been removed: @@ -565,6 +576,7 @@ See also [Detailed Release Notes for PMD 7]({{ baseurl }}pmd_release_notes_pmd7. * [#3815](https://github.com/pmd/pmd/issues/3815): \[core] Update Saxon HE to 10.7 * [#3893](https://github.com/pmd/pmd/pull/3893): \[core] Text documents * [#3902](https://github.com/pmd/pmd/issues/3902): \[core] Violation decorators + * [#3903](https://github.com/pmd/pmd/issues/3903): \[core] Consolidate `n.s.pmd.reporting` package * [#3918](https://github.com/pmd/pmd/issues/3918): \[core] Make LanguageRegistry non static * [#3919](https://github.com/pmd/pmd/issues/3919): \[core] Merge CPD and PMD language * [#3922](https://github.com/pmd/pmd/pull/3922): \[core] Better error reporting for the ruleset parser diff --git a/docs/pages/release_notes_pmd7.md b/docs/pages/release_notes_pmd7.md index f02b8a1ff8..cf71d941ff 100644 --- a/docs/pages/release_notes_pmd7.md +++ b/docs/pages/release_notes_pmd7.md @@ -1201,7 +1201,7 @@ You can identify them with the `@InternalApi` annotation. You'll also get a depr should be used. - Several members of {% jdoc test::cli.BaseCPDCLITest %} have been deprecated with replacements. - The methods {% jdoc !!core::ant.Formatter#start(java.lang.String) %}, - {% jdoc !!core::ant.Formatter#end(net.sourceforge.pmd.Report) %}, {% jdoc !!core::ant.Formatter#getRenderer() %}, + {% jdoc !!core::ant.Formatter#end(net.sourceforge.pmd.reporting.Report) %}, {% jdoc !!core::ant.Formatter#getRenderer() %}, and {% jdoc !!core::ant.Formatter#isNoOutputSupplied() %} have been internalized. #### 6.45.0 @@ -1211,7 +1211,7 @@ You can identify them with the `@InternalApi` annotation. You'll also get a depr * Report has two new methods which allow limited mutations of a given report: * {% jdoc !!core::Report#filterViolations(net.sourceforge.pmd.util.Predicate) %} creates a new report with some violations removed with a given predicate based filter. - * {% jdoc !!core::Report#union(net.sourceforge.pmd.Report) %} can combine two reports into a single new Report. + * {% jdoc !!core::Report#union(net.sourceforge.pmd.reporting.Report) %} can combine two reports into a single new Report. * {% jdoc !!core::util.Predicate %} will be replaced in PMD7 with the standard Predicate interface from java8. * The module `pmd-html` is entirely experimental right now. Anything in the package `net.sourceforge.pmd.lang.html` should be used cautiously. diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java index 199cc2b16b..48296af944 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java @@ -26,7 +26,6 @@ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.Parameter; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.document.TextFile; @@ -36,6 +35,7 @@ import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.FileNameRenderer; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; import net.sourceforge.pmd.reporting.ListenerInitializer; +import net.sourceforge.pmd.reporting.Report; @InternalApi public class Formatter { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageHandler.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageHandler.java index e1e10d6f00..92348f5f43 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageHandler.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageHandler.java @@ -9,7 +9,6 @@ import static net.sourceforge.pmd.util.CollectionUtil.setOf; import java.util.List; import java.util.Set; -import net.sourceforge.pmd.ViolationSuppressor; import net.sourceforge.pmd.lang.LanguageVersionHandler; import net.sourceforge.pmd.lang.apex.ast.ApexParser; import net.sourceforge.pmd.lang.apex.internal.ApexDesignerBindings; @@ -17,6 +16,7 @@ import net.sourceforge.pmd.lang.apex.metrics.ApexMetrics; import net.sourceforge.pmd.lang.ast.Parser; import net.sourceforge.pmd.lang.metrics.LanguageMetricsProvider; import net.sourceforge.pmd.lang.metrics.Metric; +import net.sourceforge.pmd.reporting.ViolationSuppressor; import net.sourceforge.pmd.util.designerbindings.DesignerBindings; class ApexLanguageHandler implements LanguageVersionHandler { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexViolationSuppressors.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexViolationSuppressors.java index ef792b2cfb..505a9c3440 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexViolationSuppressors.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexViolationSuppressors.java @@ -13,11 +13,7 @@ import java.util.TreeSet; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Report.SuppressedViolation; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleViolation; -import net.sourceforge.pmd.ViolationSuppressor; import net.sourceforge.pmd.lang.apex.ast.ASTAnnotation; import net.sourceforge.pmd.lang.apex.ast.ASTAnnotationParameter; import net.sourceforge.pmd.lang.apex.ast.ASTField; @@ -30,6 +26,10 @@ import net.sourceforge.pmd.lang.apex.ast.ASTUserEnum; import net.sourceforge.pmd.lang.apex.ast.ASTVariableDeclarationStatements; import net.sourceforge.pmd.lang.apex.ast.ApexNode; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.Report.SuppressedViolation; +import net.sourceforge.pmd.reporting.RuleViolation; +import net.sourceforge.pmd.reporting.ViolationSuppressor; final class ApexViolationSuppressors { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRule.java index c00f59cff9..bdaa957d8e 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRule.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.lang.apex.rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.reporting.RuleContext; public abstract class AbstractApexRule extends AbstractRule implements ApexParserVisitor { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/StdCyclomaticComplexityRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/StdCyclomaticComplexityRule.java index 00d876ba19..5e500b8849 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/StdCyclomaticComplexityRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/StdCyclomaticComplexityRule.java @@ -10,7 +10,6 @@ import static net.sourceforge.pmd.properties.PropertyFactory.booleanProperty; import java.util.ArrayDeque; import java.util.Deque; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.apex.ast.ASTBooleanExpression; import net.sourceforge.pmd.lang.apex.ast.ASTDoLoopStatement; import net.sourceforge.pmd.lang.apex.ast.ASTForEachStatement; @@ -27,6 +26,7 @@ import net.sourceforge.pmd.lang.apex.ast.ASTWhileLoopStatement; import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleContext; /** diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java index a4bc0a4e64..48a363aee8 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java @@ -23,7 +23,6 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.apex.ast.ASTAssignmentExpression; import net.sourceforge.pmd.lang.apex.ast.ASTBlockStatement; import net.sourceforge.pmd.lang.apex.ast.ASTDmlDeleteStatement; @@ -57,6 +56,7 @@ import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule; import net.sourceforge.pmd.lang.apex.rule.internal.Helper; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.reporting.RuleContext; import com.google.common.base.Objects; import com.google.common.collect.HashMultimap; diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java index 5bd6ea827d..759e53a10e 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java @@ -8,7 +8,6 @@ import java.util.Map; import java.util.Optional; import java.util.WeakHashMap; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.apex.ast.ASTDmlDeleteStatement; import net.sourceforge.pmd.lang.apex.ast.ASTDmlInsertStatement; import net.sourceforge.pmd.lang.apex.ast.ASTDmlMergeStatement; @@ -23,6 +22,7 @@ import net.sourceforge.pmd.lang.apex.ast.ASTUserClass; import net.sourceforge.pmd.lang.apex.ast.ApexNode; import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule; import net.sourceforge.pmd.lang.apex.rule.internal.Helper; +import net.sourceforge.pmd.reporting.RuleContext; /** * Finds Apex class that do not define sharing diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/SuppressWarningsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/SuppressWarningsTest.java index e57c420398..9fff805c89 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/SuppressWarningsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/SuppressWarningsTest.java @@ -12,11 +12,11 @@ import java.util.List; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.ViolationSuppressor; import net.sourceforge.pmd.lang.apex.ast.ASTUserClass; import net.sourceforge.pmd.lang.apex.ast.ApexParserTestBase; import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.ViolationSuppressor; class SuppressWarningsTest extends ApexParserTestBase { diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java index cf2f2c3d6b..56652be2e7 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java @@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.apex.rule; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.lang.apex.ast.ASTAnonymousClass; import net.sourceforge.pmd.lang.apex.ast.ASTUserClass; import net.sourceforge.pmd.lang.apex.ast.ASTUserEnum; @@ -14,6 +13,7 @@ import net.sourceforge.pmd.lang.apex.ast.ASTUserInterface; import net.sourceforge.pmd.lang.apex.ast.ASTUserTrigger; import net.sourceforge.pmd.lang.apex.ast.ApexParserTestBase; import net.sourceforge.pmd.lang.ast.test.TestUtilsKt; +import net.sourceforge.pmd.reporting.Report; class AbstractApexRuleTest extends ApexParserTestBase { diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java index 09346eb0f7..6878bc1284 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java @@ -8,10 +8,10 @@ import static net.sourceforge.pmd.lang.ast.test.TestUtilsKt.assertSize; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.lang.apex.ast.ApexParserTestBase; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.rule.XPathRule; +import net.sourceforge.pmd.reporting.Report; /** * @author daniels diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java index cda9afc56b..67544fc380 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java @@ -15,16 +15,16 @@ 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.Rule; 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; import net.sourceforge.pmd.lang.apex.ApexLanguageModule; import net.sourceforge.pmd.lang.apex.ApexLanguageProperties; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; import com.nawforce.pkgforce.path.PathFactory; import com.nawforce.pkgforce.path.PathLike; diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsNestedClassTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsNestedClassTest.java index dd2ae6531b..05c95696c6 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsNestedClassTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsNestedClassTest.java @@ -14,9 +14,9 @@ import java.util.stream.Collectors; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.apex.ast.ApexParserTestBase; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; /** *

Sharing settings are not inherited by inner classes. Sharing settings need to be declared on the class that diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/ProgressBarListener.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/ProgressBarListener.java index 84c43acfca..39debca2d5 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/ProgressBarListener.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/ProgressBarListener.java @@ -6,12 +6,12 @@ package net.sourceforge.pmd.cli.internal; import java.util.concurrent.atomic.AtomicInteger; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; import net.sourceforge.pmd.reporting.ListenerInitializer; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; import me.tongfei.progressbar.PmdProgressBarFriend; import me.tongfei.progressbar.ProgressBar; diff --git a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java index be585879ee..744dcaf033 100644 --- a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java +++ b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java @@ -40,11 +40,11 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.MockRule; +import net.sourceforge.pmd.reporting.RuleContext; import com.github.stefanbirkner.systemlambda.SystemLambda; 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 6a1b013776..8f28d07a38 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java @@ -21,7 +21,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.event.Level; -import net.sourceforge.pmd.Report.GlobalReportBuilderListener; import net.sourceforge.pmd.benchmark.TimeTracker; import net.sourceforge.pmd.benchmark.TimedOperation; import net.sourceforge.pmd.benchmark.TimedOperationCategory; @@ -47,6 +46,8 @@ import net.sourceforge.pmd.reporting.ConfigurableFileNameRenderer; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; import net.sourceforge.pmd.reporting.ListenerInitializer; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.Report.GlobalReportBuilderListener; import net.sourceforge.pmd.reporting.ReportStats; import net.sourceforge.pmd.reporting.ReportStatsListener; import net.sourceforge.pmd.util.AssertionUtil; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java b/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java index e6ceb8753e..0c4f37e636 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java @@ -16,6 +16,7 @@ import net.sourceforge.pmd.lang.rule.RuleTargetSelector; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; import net.sourceforge.pmd.properties.PropertySource; +import net.sourceforge.pmd.reporting.RuleContext; /** * This is the basic Rule interface for PMD rules. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java index 7a8b7a9498..e21e134325 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java @@ -26,9 +26,7 @@ import org.slf4j.Logger; 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; import net.sourceforge.pmd.benchmark.TimedOperation; @@ -39,6 +37,8 @@ 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.reporting.Report.ProcessingError; +import net.sourceforge.pmd.reporting.RuleViolation; /** * Abstract implementation of the analysis cache. Handles all operations, except for persistence. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java index 2b7e0e1b5a..a843b31530 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java @@ -9,12 +9,12 @@ 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.reporting.RuleViolation; /** * An analysis cache for incremental analysis. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisResult.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisResult.java index 6c87b8e052..956246b80c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisResult.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisResult.java @@ -7,8 +7,8 @@ package net.sourceforge.pmd.cache; import java.util.ArrayList; import java.util.List; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.annotation.InternalApi; +import net.sourceforge.pmd.reporting.RuleViolation; /** * The result of a single file analysis. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleViolation.java index f53d56492e..2f5f7aa1d6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleViolation.java @@ -15,11 +15,11 @@ import java.util.Map.Entry; import org.checkerframework.checker.nullness.qual.NonNull; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextRange2d; +import net.sourceforge.pmd.reporting.RuleViolation; import net.sourceforge.pmd.util.StringUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java index b1fcc12ed0..e70f7b1b17 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/FileAnalysisCache.java @@ -20,13 +20,13 @@ 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; 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.reporting.RuleViolation; /** * An analysis cache backed by a regular file. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java index ea8896501d..737510d83b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java @@ -9,11 +9,11 @@ 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.reporting.RuleViolation; /** * A NOOP analysis cache. Easier / safer than null-checking. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionHandler.java index 3e6d3063a5..f1650cc9a1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionHandler.java @@ -7,12 +7,12 @@ package net.sourceforge.pmd.lang; import java.util.Collections; import java.util.List; -import net.sourceforge.pmd.ViolationSuppressor; import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.lang.ast.Parser; import net.sourceforge.pmd.lang.metrics.LanguageMetricsProvider; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathHandler; import net.sourceforge.pmd.reporting.ViolationDecorator; +import net.sourceforge.pmd.reporting.ViolationSuppressor; import net.sourceforge.pmd.util.designerbindings.DesignerBindings; import net.sourceforge.pmd.util.designerbindings.DesignerBindings.DefaultDesignerBindings; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileId.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileId.java index 452ee2ae2e..98da0536da 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileId.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileId.java @@ -11,8 +11,8 @@ import java.nio.file.Paths; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.renderers.Renderer; +import net.sourceforge.pmd.reporting.RuleViolation; /** * An identifier for a {@link TextFile}. This is not a path, but provides diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java index e42fe4e212..e9a6d89ab2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java @@ -9,10 +9,10 @@ import java.util.Objects; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.ast.GenericToken; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.reporting.Reportable; +import net.sourceforge.pmd.reporting.RuleViolation; import net.sourceforge.pmd.util.AssertionUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java index 8059d94e2b..ff4e71db84 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java @@ -9,9 +9,7 @@ import static net.sourceforge.pmd.util.CollectionUtil.listOf; 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; import net.sourceforge.pmd.benchmark.TimedOperationCategory; @@ -29,6 +27,8 @@ 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.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; /** * A processing task for a single file. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java index a780a65178..a0baeed421 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java @@ -8,7 +8,6 @@ import java.util.List; import java.util.Map; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageProcessor; @@ -16,6 +15,7 @@ import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertySource; +import net.sourceforge.pmd.reporting.RuleContext; /** * Base class for Rule implementations which delegate to another Rule instance. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java index fd0573ed7b..dc6cffc779 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java @@ -16,7 +16,6 @@ import java.util.Set; import org.checkerframework.checker.nullness.qual.NonNull; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageVersion; @@ -24,6 +23,7 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.properties.AbstractPropertySource; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.reporting.RuleContext; /** * Basic abstract implementation of all parser-independent methods of the Rule diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractVisitorRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractVisitorRule.java index 9ef6e4a472..f633fe66f5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractVisitorRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractVisitorRule.java @@ -4,9 +4,9 @@ package net.sourceforge.pmd.lang.rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.AstVisitor; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.reporting.RuleContext; public abstract class AbstractVisitorRule extends AbstractRule { @Override diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java index e5cc2ea252..28bca3fe7b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java @@ -17,7 +17,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.annotation.DeprecatedUntil700; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.ast.Node; @@ -27,6 +26,7 @@ import net.sourceforge.pmd.lang.rule.xpath.internal.DeprecatedAttrLogger; import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleContext; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java index 6da5e290d8..e468008cf2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java @@ -11,9 +11,7 @@ import org.apache.commons.lang3.exception.ExceptionContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.benchmark.TimeTracker; import net.sourceforge.pmd.benchmark.TimedOperation; @@ -23,6 +21,8 @@ import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.reporting.FileAnalysisListener; +import net.sourceforge.pmd.reporting.Report.ProcessingError; +import net.sourceforge.pmd.reporting.RuleContext; import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.StringUtil; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractAccumulatingRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractAccumulatingRenderer.java index 0bf666d9b9..5f90c44b78 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractAccumulatingRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractAccumulatingRenderer.java @@ -7,9 +7,6 @@ package net.sourceforge.pmd.renderers; import java.io.IOException; import java.util.Objects; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Report.GlobalReportBuilderListener; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.benchmark.TimeTracker; import net.sourceforge.pmd.benchmark.TimedOperation; @@ -17,6 +14,9 @@ import net.sourceforge.pmd.benchmark.TimedOperationCategory; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.GlobalReportBuilderListener; /** * Abstract base class for {@link Renderer} implementations which only produce diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractIncrementingRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractIncrementingRenderer.java index 05cdc963bb..f1dab29a52 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractIncrementingRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractIncrementingRenderer.java @@ -9,9 +9,9 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.document.TextFile; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; /** * Abstract base class for {@link Renderer} implementations which can produce diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CSVRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CSVRenderer.java index dfbd93bcb3..85e869eced 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CSVRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CSVRenderer.java @@ -14,11 +14,11 @@ import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; import net.sourceforge.pmd.properties.PropertySource; import net.sourceforge.pmd.renderers.ColumnDescriptor.Accessor; +import net.sourceforge.pmd.reporting.RuleViolation; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java index e2f4334206..737feb6a07 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java @@ -13,8 +13,8 @@ import org.apache.commons.lang3.StringUtils; import net.sourceforge.pmd.PMDVersion; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.reporting.RuleViolation; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmacsRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmacsRenderer.java index 943c34a0ff..2f1a144f0a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmacsRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmacsRenderer.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.renderers; import java.io.IOException; import java.util.Iterator; -import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.reporting.RuleViolation; /** * Renderer to GNU Emacs parsable format. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmptyRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmptyRenderer.java index 0496e6226c..6161d86604 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmptyRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmptyRenderer.java @@ -6,8 +6,8 @@ package net.sourceforge.pmd.renderers; import java.io.IOException; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.lang.document.TextFile; +import net.sourceforge.pmd.reporting.Report; /** * An empty renderer, for when you really don't want a report. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java index 24e44a4c62..09aeda4144 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java @@ -14,13 +14,13 @@ import java.util.Optional; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Report.ConfigurationError; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.RuleViolation; /** * Renderer to basic HTML format. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/IDEAJRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/IDEAJRenderer.java index a67103179c..9dd2b7501e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/IDEAJRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/IDEAJRenderer.java @@ -11,9 +11,9 @@ import java.util.Iterator; import java.util.Set; import java.util.StringTokenizer; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleViolation; /** * Renderer for IntelliJ IDEA integration. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/JsonRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/JsonRenderer.java index d793cb7fe7..11ff613259 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/JsonRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/JsonRenderer.java @@ -15,9 +15,9 @@ import java.util.Map; import org.apache.commons.lang3.StringUtils; import net.sourceforge.pmd.PMDVersion; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleViolation; -import net.sourceforge.pmd.ViolationSuppressor; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; +import net.sourceforge.pmd.reporting.ViolationSuppressor; import com.google.gson.stream.JsonWriter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/Renderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/Renderer.java index 443eef1b1d..0a19b46c9a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/Renderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/Renderer.java @@ -7,13 +7,6 @@ package net.sourceforge.pmd.renderers; import java.io.IOException; import java.io.Writer; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Report.GlobalReportBuilderListener; -import net.sourceforge.pmd.Report.ProcessingError; -import net.sourceforge.pmd.Report.ReportBuilderListener; -import net.sourceforge.pmd.Report.SuppressedViolation; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.benchmark.TimeTracker; import net.sourceforge.pmd.benchmark.TimedOperation; @@ -25,6 +18,13 @@ import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.FileNameRenderer; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; import net.sourceforge.pmd.reporting.ListenerInitializer; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.GlobalReportBuilderListener; +import net.sourceforge.pmd.reporting.Report.ProcessingError; +import net.sourceforge.pmd.reporting.Report.ReportBuilderListener; +import net.sourceforge.pmd.reporting.Report.SuppressedViolation; +import net.sourceforge.pmd.reporting.RuleViolation; /** * This is an interface for rendering a Report. When a Renderer is being diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java index 39cb54baf6..047b6e2ac3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java @@ -8,11 +8,11 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Iterator; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.renderers.internal.sarif.SarifLog; import net.sourceforge.pmd.renderers.internal.sarif.SarifLogBuilder; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java index 20272afb30..b552af92d0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java @@ -11,8 +11,8 @@ import java.util.Map.Entry; import org.apache.commons.lang3.mutable.MutableInt; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; /** * Renderer to a summarized HTML format. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextColorRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextColorRenderer.java index cb78a79871..d277b62b03 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextColorRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextColorRenderer.java @@ -16,12 +16,12 @@ import java.util.Map; import org.apache.commons.lang3.StringUtils; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Report.ProcessingError; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.ProcessingError; +import net.sourceforge.pmd.reporting.RuleViolation; /** *

diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextPadRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextPadRenderer.java index 0b68d66206..77ced0a1c4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextPadRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextPadRenderer.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.renderers; import java.io.IOException; import java.util.Iterator; -import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.reporting.RuleViolation; /** *

diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextRenderer.java index 04702540fc..4e727c125c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextRenderer.java @@ -7,8 +7,8 @@ package net.sourceforge.pmd.renderers; import java.io.IOException; import java.util.Iterator; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; /** * Renderer to simple text format. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/VBHTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/VBHTMLRenderer.java index ae7a5f7927..2d751aedb4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/VBHTMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/VBHTMLRenderer.java @@ -7,8 +7,8 @@ package net.sourceforge.pmd.renderers; import java.io.IOException; import java.util.Iterator; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; /** * Renderer to another HTML format. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java index ef3ac7f0de..7699d26c6c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java @@ -25,11 +25,11 @@ import javax.xml.stream.XMLStreamWriter; import org.apache.commons.lang3.StringUtils; import net.sourceforge.pmd.PMDVersion; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; import net.sourceforge.pmd.util.StringUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/YAHTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/YAHTMLRenderer.java index db7dcd08ff..9001f5a05c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/YAHTMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/YAHTMLRenderer.java @@ -16,10 +16,10 @@ import java.util.TreeMap; import org.apache.commons.lang3.StringUtils; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; import net.sourceforge.pmd.util.StringUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java index d76c021b03..286d247f31 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java @@ -11,8 +11,6 @@ import java.util.HashSet; import java.util.List; import net.sourceforge.pmd.PMDVersion; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.ArtifactLocation; import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.AssociatedRule; import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Component; @@ -30,6 +28,8 @@ import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Run; import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.Tool; import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.ToolConfigurationNotification; import net.sourceforge.pmd.renderers.internal.sarif.SarifLog.ToolExecutionNotification; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; public class SarifLogBuilder { private final List rules = new ArrayList<>(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java index 7ecc79018e..30e0778b41 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java @@ -8,11 +8,9 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Report.ProcessingError; -import net.sourceforge.pmd.Report.SuppressedViolation; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.internal.util.IOUtil; +import net.sourceforge.pmd.reporting.Report.ProcessingError; +import net.sourceforge.pmd.reporting.Report.SuppressedViolation; import net.sourceforge.pmd.util.AssertionUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java index 23330b416e..740d56e9a8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java @@ -11,15 +11,14 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; import net.sourceforge.pmd.PmdAnalysis; -import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Report.GlobalReportBuilderListener; -import net.sourceforge.pmd.Report.ProcessingError; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.ast.FileAnalysisException; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.renderers.Renderer; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.GlobalReportBuilderListener; +import net.sourceforge.pmd.reporting.Report.ProcessingError; import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.BaseResultProducingCloseable; import net.sourceforge.pmd.util.CollectionUtil; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopFileListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopFileListener.java index 737bbb8c57..223fb948f5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopFileListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopFileListener.java @@ -4,8 +4,6 @@ package net.sourceforge.pmd.reporting; -import net.sourceforge.pmd.RuleViolation; - final class NoopFileListener implements FileAnalysisListener { static final NoopFileListener INSTANCE = new NoopFileListener(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ParametricRuleViolation.java similarity index 93% rename from pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java rename to pmd-core/src/main/java/net/sourceforge/pmd/reporting/ParametricRuleViolation.java index 6697ff7728..60e7a42603 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ParametricRuleViolation.java @@ -2,16 +2,14 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.lang.rule; +package net.sourceforge.pmd.reporting; import java.util.Collections; import java.util.Map; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.document.FileLocation; -import net.sourceforge.pmd.reporting.Reportable; import net.sourceforge.pmd.util.AssertionUtil; /** @@ -20,8 +18,6 @@ import net.sourceforge.pmd.util.AssertionUtil; @Deprecated @InternalApi public class ParametricRuleViolation implements RuleViolation { - // todo move to package reporting - protected final Rule rule; protected final String description; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/Report.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/Report.java similarity index 97% rename from pmd-core/src/main/java/net/sourceforge/pmd/Report.java rename to pmd-core/src/main/java/net/sourceforge/pmd/reporting/Report.java index d579ec05d7..eb07725be2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/Report.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/Report.java @@ -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.reporting; import static java.util.Collections.synchronizedList; @@ -15,18 +15,18 @@ import java.util.List; import java.util.function.Consumer; import java.util.function.Predicate; +import net.sourceforge.pmd.PmdAnalysis; +import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.annotation.DeprecatedUntil700; import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.renderers.AbstractAccumulatingRenderer; -import net.sourceforge.pmd.reporting.FileAnalysisListener; -import net.sourceforge.pmd.reporting.GlobalAnalysisListener; import net.sourceforge.pmd.util.BaseResultProducingCloseable; /** - * A {@link Report} collects all informations during a PMD execution. This + * A {@link Report} collects all information during a PMD execution. This * includes violations, suppressed violations, metrics, error during processing * and configuration errors. * @@ -44,8 +44,6 @@ import net.sourceforge.pmd.util.BaseResultProducingCloseable; *

*/ public final class Report { - // todo move to package reporting - private final List violations = synchronizedList(new ArrayList<>()); private final List suppressedRuleViolations = synchronizedList(new ArrayList<>()); private final List errors = synchronizedList(new ArrayList<>()); @@ -79,7 +77,7 @@ public final class Report { } /** - * Gets the wrongly configured rule + * Gets the wrongly configured rule. * * @return the wrongly configured rule */ @@ -362,7 +360,7 @@ public final class Report { } @Override - protected Report getResultImpl() { + public Report getResultImpl() { return report; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ReportStatsListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ReportStatsListener.java index 27b8e96cb8..49d18837d3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ReportStatsListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ReportStatsListener.java @@ -6,9 +6,8 @@ package net.sourceforge.pmd.reporting; import java.util.concurrent.atomic.AtomicInteger; -import net.sourceforge.pmd.Report.ProcessingError; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.document.TextFile; +import net.sourceforge.pmd.reporting.Report.ProcessingError; import net.sourceforge.pmd.util.BaseResultProducingCloseable; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/Reportable.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/Reportable.java index 9b6eb5042e..574a8323ef 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/Reportable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/Reportable.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.reporting; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.annotation.DeprecatedUntil700; import net.sourceforge.pmd.lang.ast.GenericToken; import net.sourceforge.pmd.lang.ast.Node; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleContext.java similarity index 96% rename from pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java rename to pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleContext.java index 905d38474f..53ecd4ed2d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleContext.java @@ -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.reporting; import static net.sourceforge.pmd.util.CollectionUtil.listOf; @@ -15,17 +15,15 @@ import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.Report.SuppressedViolation; +import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.LanguageVersionHandler; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.AbstractRule; -import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.properties.PropertyDescriptor; -import net.sourceforge.pmd.reporting.FileAnalysisListener; -import net.sourceforge.pmd.reporting.ViolationDecorator; +import net.sourceforge.pmd.reporting.Report.SuppressedViolation; /** * The API for rules to report violations or errors during analysis. @@ -38,8 +36,6 @@ import net.sourceforge.pmd.reporting.ViolationDecorator; * not unique throughout the analysis, a separate one is used per file and rule. */ public final class RuleContext { - // todo move to package reporting - // Rule contexts do not need to be thread-safe, within PmdRunnable // they are stack-local diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleViolation.java similarity index 98% rename from pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java rename to pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleViolation.java index 3b0f1518a7..819cdb3ac7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleViolation.java @@ -2,11 +2,12 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd; +package net.sourceforge.pmd.reporting; import java.util.Comparator; import java.util.Map; +import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.annotation.DeprecatedUntil700; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.FileLocation; @@ -22,8 +23,6 @@ import net.sourceforge.pmd.lang.document.FileLocation; * @see Rule */ public interface RuleViolation { - // todo move to package reporting - /** * A comparator for rule violations. This compares all exposed attributes * of a violation, filename first. The remaining parameters are compared diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationDecorator.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationDecorator.java index d68ac3d9ab..ead8232db3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationDecorator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationDecorator.java @@ -9,7 +9,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.ast.Node; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/ViolationSuppressor.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationSuppressor.java similarity index 97% rename from pmd-core/src/main/java/net/sourceforge/pmd/ViolationSuppressor.java rename to pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationSuppressor.java index 4d6c0edb30..41f5213aa2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/ViolationSuppressor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationSuppressor.java @@ -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.reporting; import java.util.List; import java.util.Map; @@ -12,12 +12,13 @@ import java.util.regex.Pattern; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.Report.SuppressedViolation; +import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.ast.AstInfo; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; import net.sourceforge.pmd.lang.rule.xpath.internal.DeprecatedAttrLogger; import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery; +import net.sourceforge.pmd.reporting.Report.SuppressedViolation; /** * An object that suppresses rule violations. Suppressors are used by @@ -26,8 +27,6 @@ import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery; * no knowledge of language-specific suppressors. */ public interface ViolationSuppressor { - // todo move to package reporting - /** * Suppressor for the violationSuppressRegex property. */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/package-info.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/package-info.java index 2d9e959ca0..a1b362a05c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/package-info.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/package-info.java @@ -4,9 +4,5 @@ /** * Logic about reporting: violations, suppression etc. - * - *

TODO move {@link net.sourceforge.pmd.Report}, {@link net.sourceforge.pmd.RuleViolation}, - * {@link net.sourceforge.pmd.RuleContext}, {@link net.sourceforge.pmd.ViolationSuppressor} - * into this package */ package net.sourceforge.pmd.reporting; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java index bc82f3452c..3aa0a9df07 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java @@ -4,8 +4,8 @@ package net.sourceforge.pmd; -import static net.sourceforge.pmd.ReportTestUtil.getReportForRuleApply; import static net.sourceforge.pmd.properties.NumericConstraints.inRange; +import static net.sourceforge.pmd.reporting.ReportTestUtil.getReportForRuleApply; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; @@ -25,10 +25,12 @@ import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.rule.AbstractRule; -import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; import net.sourceforge.pmd.reporting.FileAnalysisListener; +import net.sourceforge.pmd.reporting.ParametricRuleViolation; +import net.sourceforge.pmd.reporting.RuleContext; +import net.sourceforge.pmd.reporting.RuleViolation; class AbstractRuleTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/FooRule.java b/pmd-core/src/test/java/net/sourceforge/pmd/FooRule.java index 540575da39..37c056913a 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/FooRule.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/FooRule.java @@ -12,6 +12,7 @@ import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.lang.rule.RuleTargetSelector; +import net.sourceforge.pmd.reporting.RuleContext; /** * Sample rule that detect any node with an image of "Foo". Used for testing. 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..ae6b321567 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java @@ -32,7 +32,9 @@ import net.sourceforge.pmd.lang.document.FileId; 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.Report; import net.sourceforge.pmd.reporting.ReportStats; +import net.sourceforge.pmd.reporting.RuleContext; import net.sourceforge.pmd.util.log.MessageReporter; /** diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java index ca94ab2f1f..8787d7b5f6 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd; import static net.sourceforge.pmd.PmdCoreTestUtils.dummyLanguage; import static net.sourceforge.pmd.PmdCoreTestUtils.dummyLanguage2; import static net.sourceforge.pmd.PmdCoreTestUtils.dummyVersion; -import static net.sourceforge.pmd.ReportTestUtil.getReportForRuleSetApply; +import static net.sourceforge.pmd.reporting.ReportTestUtil.getReportForRuleSetApply; import static net.sourceforge.pmd.util.CollectionUtil.listOf; import static net.sourceforge.pmd.util.CollectionUtil.setOf; import static org.hamcrest.CoreMatchers.containsString; @@ -40,7 +40,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.RuleSet.RuleSetBuilder; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; @@ -49,6 +48,10 @@ import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.RuleTargetSelector; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.Report.ProcessingError; +import net.sourceforge.pmd.reporting.RuleContext; +import net.sourceforge.pmd.reporting.RuleViolation; class RuleSetTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java index 171219ad1f..597020dad6 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java @@ -37,7 +37,6 @@ import org.mockito.Mockito; import net.sourceforge.pmd.PmdCoreTestUtils; import net.sourceforge.pmd.RuleSets; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.document.FileId; @@ -46,8 +45,9 @@ import net.sourceforge.pmd.lang.document.TextDocument; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.document.TextFileContent; import net.sourceforge.pmd.lang.document.TextRange2d; -import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.reporting.FileAnalysisListener; +import net.sourceforge.pmd.reporting.ParametricRuleViolation; +import net.sourceforge.pmd.reporting.RuleViolation; class FileAnalysisCacheTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageModule.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageModule.java index b0c76988ae..53b3b48660 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageModule.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageModule.java @@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang; import java.util.Objects; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.cpd.CpdCapableLanguage; import net.sourceforge.pmd.cpd.CpdLanguageProperties; import net.sourceforge.pmd.lang.ast.DummyNode; @@ -18,6 +17,7 @@ import net.sourceforge.pmd.lang.document.Chars; import net.sourceforge.pmd.lang.document.TextDocument; import net.sourceforge.pmd.lang.document.TextRegion; import net.sourceforge.pmd.lang.impl.SimpleLanguageModuleBase; +import net.sourceforge.pmd.reporting.RuleViolation; import net.sourceforge.pmd.reporting.ViolationDecorator; /** 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..416db02beb 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 @@ -15,10 +15,7 @@ import org.mockito.Mockito; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RuleSet; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.LanguageVersion; @@ -28,6 +25,9 @@ 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.reporting.Report; +import net.sourceforge.pmd.reporting.RuleContext; +import net.sourceforge.pmd.reporting.RuleViolation; import net.sourceforge.pmd.util.log.MessageReporter; abstract class AbstractPMDProcessorTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java index 12e381fac1..5489c0a90b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java @@ -14,10 +14,10 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; import net.sourceforge.pmd.PmdAnalysis; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.reporting.RuleContext; class MultiThreadProcessorTest extends AbstractPMDProcessorTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java index e3b760674d..e7fb4e797d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java @@ -6,11 +6,11 @@ package net.sourceforge.pmd.lang.rule; import static net.sourceforge.pmd.properties.NumericConstraints.inRange; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleContext; /** diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java index ec4f081756..1105de96fa 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java @@ -4,9 +4,9 @@ package net.sourceforge.pmd.lang.rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.reporting.RuleContext; /** diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java index ccbb20cdb2..b043089952 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java @@ -5,7 +5,7 @@ package net.sourceforge.pmd.lang.rule; import static net.sourceforge.pmd.PmdCoreTestUtils.setDummyLanguage; -import static net.sourceforge.pmd.ReportTestUtil.getReportForRuleApply; +import static net.sourceforge.pmd.reporting.ReportTestUtil.getReportForRuleApply; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasSize; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -15,12 +15,12 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import net.sourceforge.pmd.DummyParsingHelper; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.lang.ast.DummyNode; import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; import net.sourceforge.pmd.lang.ast.DummyNodeWithDeprecatedAttribute; import net.sourceforge.pmd.lang.document.TextRegion; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; +import net.sourceforge.pmd.reporting.Report; import com.github.stefanbirkner.systemlambda.SystemLambda; 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..1cf509b581 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 @@ -26,10 +26,7 @@ import org.slf4j.event.Level; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.internal.SystemProps; import net.sourceforge.pmd.lang.DummyLanguageModule; @@ -41,6 +38,9 @@ import net.sourceforge.pmd.lang.ast.RootNode; 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.reporting.Report; +import net.sourceforge.pmd.reporting.Report.ProcessingError; +import net.sourceforge.pmd.reporting.RuleContext; import net.sourceforge.pmd.util.ContextedAssertionError; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java index 411be7336a..77dc0c36d7 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java @@ -22,12 +22,8 @@ import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.DummyParsingHelper; import net.sourceforge.pmd.FooRule; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RulePriority; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.RuleWithProperties; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.DummyLanguageModule; @@ -36,9 +32,13 @@ import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.document.TextRange2d; -import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; +import net.sourceforge.pmd.reporting.ParametricRuleViolation; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.ProcessingError; +import net.sourceforge.pmd.reporting.RuleViolation; abstract class AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java index 102d033891..644a3de23e 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java @@ -4,8 +4,8 @@ package net.sourceforge.pmd.renderers; -import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Report.ProcessingError; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.ProcessingError; class CSVRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java index 0a0b87b385..501e222df9 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java @@ -9,9 +9,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.document.FileLocation; -import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; +import net.sourceforge.pmd.reporting.ParametricRuleViolation; class CodeClimateRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/HTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/HTMLRendererTest.java index 6d036898bf..adc1f2cc7d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/HTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/HTMLRendererTest.java @@ -11,8 +11,8 @@ import java.util.Optional; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Report.ProcessingError; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.ProcessingError; class HTMLRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/JsonRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/JsonRendererTest.java index f696c01c3c..dd5945d36b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/JsonRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/JsonRendererTest.java @@ -12,10 +12,10 @@ import java.io.IOException; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.FooRule; -import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Report.ProcessingError; -import net.sourceforge.pmd.Report.SuppressedViolation; -import net.sourceforge.pmd.ViolationSuppressor; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.ProcessingError; +import net.sourceforge.pmd.reporting.Report.SuppressedViolation; +import net.sourceforge.pmd.reporting.ViolationSuppressor; class JsonRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/PapariTextRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/PapariTextRendererTest.java index 626e01427c..9b84094ede 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/PapariTextRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/PapariTextRendererTest.java @@ -8,8 +8,8 @@ import java.io.FileNotFoundException; import java.io.Reader; import java.io.StringReader; -import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Report.ProcessingError; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.ProcessingError; class PapariTextRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java index a3b786f8a0..5537c6d055 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java @@ -11,9 +11,9 @@ import java.util.function.Consumer; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.reporting.FileAnalysisListener; +import net.sourceforge.pmd.reporting.Report; import com.github.stefanbirkner.systemlambda.SystemLambda; import com.google.gson.Gson; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java index 89a60d00ff..14a4495699 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java @@ -13,11 +13,11 @@ import java.util.function.Consumer; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.FooRule; -import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Report.ProcessingError; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; import net.sourceforge.pmd.reporting.FileAnalysisListener; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.ProcessingError; +import net.sourceforge.pmd.reporting.RuleContext; class SummaryHTMLRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextRendererTest.java index 5198be9559..72c1d88c8d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextRendererTest.java @@ -4,8 +4,8 @@ package net.sourceforge.pmd.renderers; -import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Report.ProcessingError; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.ProcessingError; class TextRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java index 0d473841ac..e3f6f5155b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java @@ -4,8 +4,8 @@ package net.sourceforge.pmd.renderers; -import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Report.ProcessingError; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.ProcessingError; class VBHTMLRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java index 482f3508dd..126c72c8f1 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java @@ -25,15 +25,15 @@ import org.xml.sax.InputSource; import net.sourceforge.pmd.FooRule; import net.sourceforge.pmd.PMDVersion; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Report.ProcessingError; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextRange2d; -import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; +import net.sourceforge.pmd.reporting.ParametricRuleViolation; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.ProcessingError; +import net.sourceforge.pmd.reporting.RuleViolation; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XSLTRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XSLTRendererTest.java index db22cb95ee..c1499d542b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XSLTRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XSLTRendererTest.java @@ -9,12 +9,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.FooRule; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextRange2d; -import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; +import net.sourceforge.pmd.reporting.ParametricRuleViolation; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; class XSLTRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java index 414983ad92..5c838f9099 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java @@ -20,13 +20,13 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.FooRule; -import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.document.FileLocation; -import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; +import net.sourceforge.pmd.reporting.ParametricRuleViolation; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.ProcessingError; +import net.sourceforge.pmd.reporting.RuleViolation; import net.sourceforge.pmd.util.CollectionUtil; class YAHTMLRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java index 71e6fedfc9..a201e8bca9 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/GlobalAnalysisListenerTest.java @@ -22,7 +22,6 @@ import net.sourceforge.pmd.FooRule; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.cache.AnalysisCache; import net.sourceforge.pmd.cache.NoopAnalysisCache; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/ReportTest.java similarity index 96% rename from pmd-core/src/test/java/net/sourceforge/pmd/ReportTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/reporting/ReportTest.java index b3a10c642d..80b706db49 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/ReportTest.java @@ -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.reporting; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; @@ -15,17 +15,15 @@ import java.util.function.Consumer; import org.checkerframework.checker.nullness.qual.NonNull; import org.junit.jupiter.api.Test; +import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.rule.MockRule; -import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.renderers.XMLRenderer; -import net.sourceforge.pmd.reporting.FileAnalysisListener; -import net.sourceforge.pmd.reporting.GlobalAnalysisListener; class ReportTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/ReportTestUtil.java similarity index 90% rename from pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java rename to pmd-core/src/test/java/net/sourceforge/pmd/reporting/ReportTestUtil.java index 752d4d580c..c1c4577efd 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTestUtil.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/ReportTestUtil.java @@ -2,10 +2,13 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd; +package net.sourceforge.pmd.reporting; import java.util.function.BiConsumer; +import net.sourceforge.pmd.Rule; +import net.sourceforge.pmd.RuleSet; +import net.sourceforge.pmd.RuleSets; import net.sourceforge.pmd.lang.LanguageProcessorRegistry; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleContextTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/RuleContextTest.java similarity index 90% rename from pmd-core/src/test/java/net/sourceforge/pmd/RuleContextTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/reporting/RuleContextTest.java index d0e1682f0c..8cd42b3757 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleContextTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/RuleContextTest.java @@ -2,13 +2,14 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd; +package net.sourceforge.pmd.reporting; -import static net.sourceforge.pmd.ReportTestUtil.getReport; +import static net.sourceforge.pmd.reporting.ReportTestUtil.getReport; import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; +import net.sourceforge.pmd.FooRule; import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; import net.sourceforge.pmd.lang.ast.impl.DummyTreeUtil; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationComparatorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/RuleViolationComparatorTest.java similarity index 95% rename from pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationComparatorTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/reporting/RuleViolationComparatorTest.java index 8e431d4a7f..04d5b28909 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationComparatorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/RuleViolationComparatorTest.java @@ -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.reporting; import static net.sourceforge.pmd.PmdCoreTestUtils.setDummyLanguage; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -16,11 +16,11 @@ import java.util.Random; import org.junit.jupiter.api.Test; +import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.MockRule; -import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; class RuleViolationComparatorTest { @@ -71,7 +71,7 @@ class RuleViolationComparatorTest { } private RuleViolation createJavaRuleViolation(Rule rule, String fileName, int beginLine, String description, - int beginColumn, int endLine, int endColumn) { + int beginColumn, int endLine, int endColumn) { FileLocation loc = FileLocation.range(FileId.fromPathLikeString(fileName), TextRange2d.range2d(beginLine, beginColumn, endLine, endColumn)); return new ParametricRuleViolation(rule, loc, description, Collections.emptyMap()); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/RuleViolationTest.java similarity index 95% rename from pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/reporting/RuleViolationTest.java index 278b888d7e..eaad3c6b6d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/RuleViolationTest.java @@ -2,9 +2,9 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd; +package net.sourceforge.pmd.reporting; -import static net.sourceforge.pmd.ReportTest.violation; +import static net.sourceforge.pmd.reporting.ReportTest.violation; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -14,13 +14,14 @@ import java.util.Comparator; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import net.sourceforge.pmd.DummyParsingHelper; +import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.ast.DummyNode; import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.MockRule; -import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; class RuleViolationTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/FooRuleWithLanguageSetInJava.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/FooRuleWithLanguageSetInJava.java index 38c748645f..ee2b107445 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/FooRuleWithLanguageSetInJava.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/FooRuleWithLanguageSetInJava.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.util; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.reporting.RuleContext; public class FooRuleWithLanguageSetInJava extends AbstractRule { diff --git a/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/rule/AbstractHtmlRule.java b/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/rule/AbstractHtmlRule.java index 3740d51245..02765e6119 100644 --- a/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/rule/AbstractHtmlRule.java +++ b/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/rule/AbstractHtmlRule.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.lang.html.rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.html.ast.HtmlVisitor; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.reporting.RuleContext; public abstract class AbstractHtmlRule extends AbstractRule implements HtmlVisitor { diff --git a/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/rule/bestpractices/UnnecessaryTypeAttributeRule.java b/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/rule/bestpractices/UnnecessaryTypeAttributeRule.java index b24cadff59..b2b692c19c 100644 --- a/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/rule/bestpractices/UnnecessaryTypeAttributeRule.java +++ b/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/rule/bestpractices/UnnecessaryTypeAttributeRule.java @@ -4,9 +4,9 @@ package net.sourceforge.pmd.lang.html.rule.bestpractices; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.html.ast.ASTHtmlElement; import net.sourceforge.pmd.lang.html.rule.AbstractHtmlRule; +import net.sourceforge.pmd.reporting.RuleContext; public class UnnecessaryTypeAttributeRule extends AbstractHtmlRule { diff --git a/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/rule/bestpractices/UseAltAttributeForImagesRule.java b/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/rule/bestpractices/UseAltAttributeForImagesRule.java index 3cab721591..a4219abcd4 100644 --- a/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/rule/bestpractices/UseAltAttributeForImagesRule.java +++ b/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/rule/bestpractices/UseAltAttributeForImagesRule.java @@ -8,10 +8,10 @@ import java.util.Arrays; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.html.ast.ASTHtmlElement; import net.sourceforge.pmd.lang.html.rule.AbstractHtmlRule; import net.sourceforge.pmd.lang.rule.RuleTargetSelector; +import net.sourceforge.pmd.reporting.RuleContext; public class UseAltAttributeForImagesRule extends AbstractHtmlRule { diff --git a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlJavaRuleTest.java b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlJavaRuleTest.java index 9132774ed7..59f0af598c 100644 --- a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlJavaRuleTest.java +++ b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlJavaRuleTest.java @@ -10,14 +10,14 @@ import java.util.List; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleContext; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.html.ast.ASTHtmlElement; import net.sourceforge.pmd.lang.html.ast.HtmlParsingHelper; import net.sourceforge.pmd.lang.html.rule.AbstractHtmlRule; import net.sourceforge.pmd.lang.rule.xpath.Attribute; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleContext; +import net.sourceforge.pmd.reporting.RuleViolation; class HtmlJavaRuleTest { // from https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.js_props_getter diff --git a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlXPathRuleTest.java b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlXPathRuleTest.java index 22cd8549af..9674718511 100644 --- a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlXPathRuleTest.java +++ b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlXPathRuleTest.java @@ -10,14 +10,14 @@ import java.util.List; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.html.ast.ASTHtmlComment; import net.sourceforge.pmd.lang.html.ast.ASTHtmlDocument; import net.sourceforge.pmd.lang.html.ast.ASTHtmlTextNode; import net.sourceforge.pmd.lang.html.ast.HtmlParsingHelper; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; class HtmlXPathRuleTest { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/AnnotationSuppressionUtil.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/AnnotationSuppressionUtil.java index 48dad01c73..8f29f61aa4 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/AnnotationSuppressionUtil.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/AnnotationSuppressionUtil.java @@ -14,11 +14,7 @@ import java.util.Set; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.Report.SuppressedViolation; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleViolation; -import net.sourceforge.pmd.ViolationSuppressor; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTAnnotation; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; @@ -32,6 +28,10 @@ import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; import net.sourceforge.pmd.lang.java.ast.Annotatable; import net.sourceforge.pmd.lang.java.rule.errorprone.ImplicitSwitchFallThroughRule; import net.sourceforge.pmd.lang.java.types.TypeTestUtil; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.Report.SuppressedViolation; +import net.sourceforge.pmd.reporting.RuleViolation; +import net.sourceforge.pmd.reporting.ViolationSuppressor; /** * Helper methods to suppress violations based on annotations. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaLanguageProcessor.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaLanguageProcessor.java index 020fe79ed0..9fdbfb1f94 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaLanguageProcessor.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaLanguageProcessor.java @@ -11,7 +11,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.ViolationSuppressor; import net.sourceforge.pmd.lang.LanguageVersionHandler; import net.sourceforge.pmd.lang.ast.Parser; import net.sourceforge.pmd.lang.impl.BatchLanguageProcessor; @@ -30,6 +29,7 @@ import net.sourceforge.pmd.lang.java.types.internal.infer.TypeInferenceLogger.Ve import net.sourceforge.pmd.lang.metrics.LanguageMetricsProvider; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathHandler; import net.sourceforge.pmd.reporting.ViolationDecorator; +import net.sourceforge.pmd.reporting.ViolationSuppressor; import net.sourceforge.pmd.util.designerbindings.DesignerBindings; /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecorator.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecorator.java index 05900cd459..d6a0ce9bd2 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecorator.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecorator.java @@ -11,7 +11,6 @@ import java.util.stream.Collectors; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTBodyDeclaration; @@ -24,6 +23,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclarator; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId; import net.sourceforge.pmd.lang.java.ast.JavaNode; +import net.sourceforge.pmd.reporting.RuleViolation; import net.sourceforge.pmd.reporting.ViolationDecorator; import net.sourceforge.pmd.util.IteratorUtil; diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRule.java index f230d40b2a..df5911239a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRule.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.lang.java.rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.JavaParserVisitor; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.reporting.RuleContext; /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AccessorClassGenerationRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AccessorClassGenerationRule.java index 2828b0d36a..ee2d2da4b7 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AccessorClassGenerationRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AccessorClassGenerationRule.java @@ -7,11 +7,11 @@ package net.sourceforge.pmd.lang.java.rule.bestpractices; import java.util.HashSet; import java.util.Set; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; import net.sourceforge.pmd.lang.java.ast.ASTExplicitConstructorInvocation; import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; +import net.sourceforge.pmd.reporting.RuleContext; /** * 1. Note all private constructors. 2. Note all instantiations from outside of diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AccessorMethodGenerationRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AccessorMethodGenerationRule.java index f73beab33a..f7e0283593 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AccessorMethodGenerationRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AccessorMethodGenerationRule.java @@ -9,7 +9,6 @@ import java.util.HashSet; import java.util.Objects; import java.util.Set; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTExpression; import net.sourceforge.pmd.lang.java.ast.ASTFieldAccess; import net.sourceforge.pmd.lang.java.ast.ASTMethodCall; @@ -22,6 +21,7 @@ import net.sourceforge.pmd.lang.java.symbols.JFieldSymbol; import net.sourceforge.pmd.lang.java.symbols.JMethodSymbol; import net.sourceforge.pmd.lang.java.symbols.JVariableSymbol; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.reporting.RuleContext; public class AccessorMethodGenerationRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/ArrayIsStoredDirectlyRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/ArrayIsStoredDirectlyRule.java index da45d86c47..ffd8d11790 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/ArrayIsStoredDirectlyRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/ArrayIsStoredDirectlyRule.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.java.rule.bestpractices; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.AccessType; @@ -18,6 +17,7 @@ import net.sourceforge.pmd.lang.java.ast.internal.JavaAstUtils; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleContext; /** * If a method or constructor receives an array as an argument, the array should diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidReassigningLoopVariablesRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidReassigningLoopVariablesRule.java index a5a052fd99..870f6a50e7 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidReassigningLoopVariablesRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidReassigningLoopVariablesRule.java @@ -9,7 +9,6 @@ import static net.sourceforge.pmd.properties.PropertyFactory.enumProperty; import java.util.Set; import java.util.stream.Collectors; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.NodeStream; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.AccessType; @@ -32,6 +31,7 @@ import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.ast.internal.JavaAstUtils; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.reporting.RuleContext; import net.sourceforge.pmd.util.StringUtil.CaseConvention; public class AvoidReassigningLoopVariablesRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidUsingHardCodedIPRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidUsingHardCodedIPRule.java index f9e8f8c443..3bafb20156 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidUsingHardCodedIPRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidUsingHardCodedIPRule.java @@ -14,11 +14,11 @@ import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTStringLiteral; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleContext; public class AvoidUsingHardCodedIPRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/GuardLogStatementRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/GuardLogStatementRule.java index b6d38ad82c..dd315c8188 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/GuardLogStatementRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/GuardLogStatementRule.java @@ -14,7 +14,6 @@ import java.util.Map; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTArgumentList; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr; import net.sourceforge.pmd.lang.java.ast.ASTExpression; @@ -32,6 +31,7 @@ import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.lang.java.symbols.JVariableSymbol; import net.sourceforge.pmd.lang.java.types.TypeTestUtil; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.reporting.RuleContext; /** * Check that log.debug, log.trace, log.error, etc... statements are guarded by diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/LiteralsFirstInComparisonsRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/LiteralsFirstInComparisonsRule.java index d97a1afdb9..32c912a88e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/LiteralsFirstInComparisonsRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/LiteralsFirstInComparisonsRule.java @@ -12,7 +12,6 @@ import java.util.Set; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr; import net.sourceforge.pmd.lang.java.ast.ASTExpression; import net.sourceforge.pmd.lang.java.ast.ASTMethodCall; @@ -21,6 +20,7 @@ import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.lang.java.symbols.JFieldSymbol; import net.sourceforge.pmd.lang.java.types.TypeTestUtil; +import net.sourceforge.pmd.reporting.RuleContext; public class LiteralsFirstInComparisonsRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedAssignmentRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedAssignmentRule.java index 044e7b9813..ff8680cd09 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedAssignmentRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedAssignmentRule.java @@ -12,7 +12,6 @@ import java.util.Set; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.ASTExpressionStatement; import net.sourceforge.pmd.lang.java.ast.ASTForeachStatement; @@ -27,6 +26,7 @@ import net.sourceforge.pmd.lang.java.rule.internal.DataflowPass.DataflowResult; import net.sourceforge.pmd.lang.java.rule.internal.JavaRuleUtil; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleContext; public class UnusedAssignmentRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/CommentDefaultAccessModifierRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/CommentDefaultAccessModifierRule.java index 23506062fe..33f1006d87 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/CommentDefaultAccessModifierRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/CommentDefaultAccessModifierRule.java @@ -7,7 +7,6 @@ package net.sourceforge.pmd.lang.java.rule.codestyle; import java.util.List; import java.util.regex.Pattern; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTAnnotationTypeDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; @@ -24,6 +23,7 @@ import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.lang.java.rule.internal.JavaPropertyUtil; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleContext; /** * Check for Methods, Fields and Nested Classes that have a default access diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LocalVariableCouldBeFinalRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LocalVariableCouldBeFinalRule.java index c3eb1da6c6..41db736b7a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LocalVariableCouldBeFinalRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/LocalVariableCouldBeFinalRule.java @@ -6,11 +6,11 @@ package net.sourceforge.pmd.lang.java.rule.codestyle; import static net.sourceforge.pmd.properties.PropertyFactory.booleanProperty; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTForeachStatement; import net.sourceforge.pmd.lang.java.ast.ASTLocalVariableDeclaration; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.reporting.RuleContext; public class LocalVariableCouldBeFinalRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/MethodArgumentCouldBeFinalRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/MethodArgumentCouldBeFinalRule.java index bd95e874e8..f0fa6d9a2b 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/MethodArgumentCouldBeFinalRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/MethodArgumentCouldBeFinalRule.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.java.rule.codestyle; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.NodeStream; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.AccessType; @@ -15,6 +14,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.reporting.RuleContext; public class MethodArgumentCouldBeFinalRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryBoxingRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryBoxingRule.java index 33f56b41b8..fd0e826f2d 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryBoxingRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryBoxingRule.java @@ -10,7 +10,6 @@ import java.util.Set; import org.apache.commons.lang3.StringUtils; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; import net.sourceforge.pmd.lang.java.ast.ASTExpression; import net.sourceforge.pmd.lang.java.ast.ASTList; @@ -23,6 +22,7 @@ import net.sourceforge.pmd.lang.java.types.OverloadSelectionResult; import net.sourceforge.pmd.lang.java.types.TypePrettyPrint; import net.sourceforge.pmd.lang.java.types.TypeTestUtil; import net.sourceforge.pmd.lang.java.types.ast.ExprContext; +import net.sourceforge.pmd.reporting.RuleContext; /** * diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/DataClassRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/DataClassRule.java index dfbe31b126..79cc433902 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/DataClassRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/DataClassRule.java @@ -9,11 +9,11 @@ import static net.sourceforge.pmd.lang.java.metrics.JavaMetrics.NUMBER_OF_PUBLIC import static net.sourceforge.pmd.lang.java.metrics.JavaMetrics.WEIGHED_METHOD_COUNT; import static net.sourceforge.pmd.lang.java.metrics.JavaMetrics.WEIGHT_OF_CLASS; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.lang.metrics.MetricsUtil; +import net.sourceforge.pmd.reporting.RuleContext; import net.sourceforge.pmd.util.StringUtil; /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/LawOfDemeterRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/LawOfDemeterRule.java index 5f8d4ccac1..554ea73e8b 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/LawOfDemeterRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/LawOfDemeterRule.java @@ -21,7 +21,6 @@ import java.util.stream.Stream; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTArgumentList; import net.sourceforge.pmd.lang.java.ast.ASTArrayAccess; @@ -56,6 +55,7 @@ import net.sourceforge.pmd.lang.java.types.TypeOps; import net.sourceforge.pmd.lang.java.types.TypeTestUtil; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleContext; /** * This rule can detect possible violations of the Law of Demeter. The Law of diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NPathComplexityRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NPathComplexityRule.java index 565c393e75..0ca5e63da3 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NPathComplexityRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NPathComplexityRule.java @@ -8,7 +8,6 @@ import static net.sourceforge.pmd.properties.NumericConstraints.positive; import java.math.BigInteger; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; import net.sourceforge.pmd.lang.java.ast.JavaNode; @@ -18,6 +17,7 @@ import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.lang.metrics.MetricsUtil; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleContext; /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssCountRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssCountRule.java index 23c0dbb2a9..5be93f5829 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssCountRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssCountRule.java @@ -10,7 +10,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; @@ -23,6 +22,7 @@ import net.sourceforge.pmd.lang.metrics.MetricOptions; import net.sourceforge.pmd.lang.metrics.MetricsUtil; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleContext; import net.sourceforge.pmd.util.AssertionUtil; diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/SimplifyBooleanReturnsRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/SimplifyBooleanReturnsRule.java index ae0a84cd17..300fa40cff 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/SimplifyBooleanReturnsRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/SimplifyBooleanReturnsRule.java @@ -22,7 +22,6 @@ import java.util.Set; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTBlock; import net.sourceforge.pmd.lang.java.ast.ASTCastExpression; import net.sourceforge.pmd.lang.java.ast.ASTExpression; @@ -36,6 +35,7 @@ import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.ast.internal.JavaAstUtils; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.lang.java.types.JPrimitiveType.PrimitiveTypeKind; +import net.sourceforge.pmd.reporting.RuleContext; public class SimplifyBooleanReturnsRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentContentRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentContentRule.java index 63feecfabc..ec354ee05d 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentContentRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentContentRule.java @@ -8,13 +8,13 @@ import static net.sourceforge.pmd.properties.PropertyFactory.regexProperty; import java.util.regex.Pattern; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.document.Chars; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.JavaComment; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.reporting.RuleContext; /** * A rule that checks for illegal words in the comment text. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredRule.java index bcaccdfa76..55e128bf44 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentRequiredRule.java @@ -12,7 +12,6 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTBodyDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration; @@ -28,6 +27,7 @@ import net.sourceforge.pmd.lang.java.rule.internal.JavaRuleUtil; import net.sourceforge.pmd.properties.PropertyBuilder.GenericPropertyBuilder; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleContext; import net.sourceforge.pmd.util.CollectionUtil; diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java index 0786bef786..857d68dc48 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/CommentSizeRule.java @@ -6,13 +6,13 @@ package net.sourceforge.pmd.lang.java.rule.documentation; import static net.sourceforge.pmd.properties.NumericConstraints.positive; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.document.Chars; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.JavaComment; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleContext; /** * A rule to manage those who just can't shut up... diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AssignmentInOperandRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AssignmentInOperandRule.java index c59a86ce1a..5cf8bde053 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AssignmentInOperandRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AssignmentInOperandRule.java @@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.java.rule.errorprone; import static net.sourceforge.pmd.properties.PropertyFactory.booleanProperty; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTAssignmentExpression; import net.sourceforge.pmd.lang.java.ast.ASTExpression; import net.sourceforge.pmd.lang.java.ast.ASTExpressionStatement; @@ -19,6 +18,7 @@ import net.sourceforge.pmd.lang.java.ast.internal.JavaAstUtils; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertySource; +import net.sourceforge.pmd.reporting.RuleContext; /** * diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AvoidDuplicateLiteralsRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AvoidDuplicateLiteralsRule.java index df4f69a9f6..3c76ba8eeb 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AvoidDuplicateLiteralsRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/AvoidDuplicateLiteralsRule.java @@ -18,12 +18,12 @@ import java.util.SortedSet; import java.util.TreeSet; import java.util.stream.Collectors; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTAnnotation; import net.sourceforge.pmd.lang.java.ast.ASTStringLiteral; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.reporting.RuleContext; public class AvoidDuplicateLiteralsRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/BrokenNullCheckRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/BrokenNullCheckRule.java index d11a28d370..48268f971d 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/BrokenNullCheckRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/BrokenNullCheckRule.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.java.rule.errorprone; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.NodeStream; import net.sourceforge.pmd.lang.java.ast.ASTExpression; import net.sourceforge.pmd.lang.java.ast.ASTInfixExpression; @@ -14,6 +13,7 @@ import net.sourceforge.pmd.lang.java.ast.QualifiableExpression; import net.sourceforge.pmd.lang.java.ast.internal.JavaAstUtils; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.lang.java.rule.internal.StablePathMatcher; +import net.sourceforge.pmd.reporting.RuleContext; public class BrokenNullCheckRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CloseResourceRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CloseResourceRule.java index 603077c771..5c7333456e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CloseResourceRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CloseResourceRule.java @@ -15,7 +15,6 @@ import java.util.Set; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTArgumentList; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr; @@ -54,6 +53,7 @@ import net.sourceforge.pmd.lang.java.symbols.JTypeDeclSymbol; import net.sourceforge.pmd.lang.java.types.InvocationMatcher; import net.sourceforge.pmd.lang.java.types.TypeTestUtil; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.reporting.RuleContext; /** * Makes sure you close your database connections. It does this by looking for diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/ConstructorCallsOverridableMethodRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/ConstructorCallsOverridableMethodRule.java index 4ef336e6dc..8f5c41369d 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/ConstructorCallsOverridableMethodRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/ConstructorCallsOverridableMethodRule.java @@ -18,7 +18,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.pcollections.PVector; import org.pcollections.TreePVector; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.NodeStream; import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTExpression; @@ -31,6 +30,7 @@ import net.sourceforge.pmd.lang.java.symbols.JExecutableSymbol; import net.sourceforge.pmd.lang.java.symbols.JMethodSymbol; import net.sourceforge.pmd.lang.java.types.JMethodSig; import net.sourceforge.pmd.lang.java.types.OverloadSelectionResult; +import net.sourceforge.pmd.reporting.RuleContext; /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/NonSerializableClassRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/NonSerializableClassRule.java index a1e791c385..16a33fa087 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/NonSerializableClassRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/NonSerializableClassRule.java @@ -16,7 +16,6 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTBodyDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; @@ -41,6 +40,7 @@ import net.sourceforge.pmd.lang.java.types.JTypeMirror; import net.sourceforge.pmd.lang.java.types.JTypeVar; import net.sourceforge.pmd.lang.java.types.TypeTestUtil; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.reporting.RuleContext; // Note: This rule has been formerly known as "BeanMembersShouldSerialize". public class NonSerializableClassRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/TypeResTestRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/TypeResTestRule.java index 00908a858b..886dade7b8 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/TypeResTestRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/TypeResTestRule.java @@ -7,13 +7,13 @@ package net.sourceforge.pmd.lang.java.rule.internal; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.ast.TypeNode; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; import net.sourceforge.pmd.lang.java.types.JTypeMirror; import net.sourceforge.pmd.lang.java.types.TypeSystem; +import net.sourceforge.pmd.reporting.RuleContext; import net.sourceforge.pmd.util.StringUtil; /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/multithreading/NonThreadSafeSingletonRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/multithreading/NonThreadSafeSingletonRule.java index 7bbee2ae2e..72da7b9d93 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/multithreading/NonThreadSafeSingletonRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/multithreading/NonThreadSafeSingletonRule.java @@ -10,7 +10,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr; import net.sourceforge.pmd.lang.java.ast.ASTAssignmentExpression; @@ -25,6 +24,7 @@ import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.lang.java.symbols.JFieldSymbol; import net.sourceforge.pmd.lang.java.symbols.JVariableSymbol; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.reporting.RuleContext; public class NonThreadSafeSingletonRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/InefficientStringBufferingRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/InefficientStringBufferingRule.java index dc62ef5fa7..39fa1bda5c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/InefficientStringBufferingRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/performance/InefficientStringBufferingRule.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.lang.java.rule.performance; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTArgumentList; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; @@ -14,6 +13,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTMethodCall; import net.sourceforge.pmd.lang.java.ast.internal.JavaAstUtils; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.lang.java.rule.internal.JavaRuleUtil; +import net.sourceforge.pmd.reporting.RuleContext; /** * How this rule works: find additive expressions: + check that the addition is diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/ExcludeLinesTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/ExcludeLinesTest.java index 8a48b275d9..c4745b2666 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/ExcludeLinesTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/ExcludeLinesTest.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.java.BaseParserTest; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; +import net.sourceforge.pmd.reporting.Report; class ExcludeLinesTest extends BaseParserTest { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/ReportTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/ReportTest.java index aa2c5ffa50..32e57976e9 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/ReportTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/ReportTest.java @@ -14,6 +14,7 @@ import java.util.regex.Pattern; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.java.JavaParsingHelper; +import net.sourceforge.pmd.reporting.Report; class ReportTest { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/SuppressWarningsTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/SuppressWarningsTest.java index 032072537f..0616127c41 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/SuppressWarningsTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/SuppressWarningsTest.java @@ -10,10 +10,10 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.FooRule; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; +import net.sourceforge.pmd.reporting.Report; class SuppressWarningsTest { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecoratorTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecoratorTest.java index 45b131aefa..b139ea6cda 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecoratorTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecoratorTest.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.lang.java.internal; -import static net.sourceforge.pmd.RuleViolation.CLASS_NAME; -import static net.sourceforge.pmd.RuleViolation.METHOD_NAME; -import static net.sourceforge.pmd.RuleViolation.PACKAGE_NAME; -import static net.sourceforge.pmd.RuleViolation.VARIABLE_NAME; +import static net.sourceforge.pmd.reporting.RuleViolation.CLASS_NAME; +import static net.sourceforge.pmd.reporting.RuleViolation.METHOD_NAME; +import static net.sourceforge.pmd.reporting.RuleViolation.PACKAGE_NAME; +import static net.sourceforge.pmd.reporting.RuleViolation.VARIABLE_NAME; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasEntry; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/DummyJavaRule.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/DummyJavaRule.java index d8a7bea8d6..664096ba0d 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/DummyJavaRule.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/DummyJavaRule.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.lang.java.rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId; import net.sourceforge.pmd.lang.java.ast.JavaNode; +import net.sourceforge.pmd.reporting.RuleContext; /** * @author Clément Fournier diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java index 1b8de97629..f021ae6f72 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java @@ -12,9 +12,7 @@ import java.util.List; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.JavaParsingHelper; @@ -27,6 +25,8 @@ import net.sourceforge.pmd.lang.rule.xpath.internal.DeprecatedAttrLogger; import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; /** * @author daniels diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java index 037cb92c30..727732bb9e 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java @@ -13,7 +13,6 @@ import java.util.function.Consumer; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.ast.FileAnalysisException; @@ -24,6 +23,7 @@ import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; +import net.sourceforge.pmd.reporting.Report; /** * @author Clément Fournier diff --git a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/AbstractEcmascriptRule.java b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/AbstractEcmascriptRule.java index c3f3eec489..df21241b9b 100644 --- a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/AbstractEcmascriptRule.java +++ b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/AbstractEcmascriptRule.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.lang.ecmascript.rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ecmascript.ast.EcmascriptParserVisitor; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.reporting.RuleContext; public abstract class AbstractEcmascriptRule extends AbstractRule diff --git a/pmd-javascript/src/test/java/net/sourceforge/pmd/ReportTest.java b/pmd-javascript/src/test/java/net/sourceforge/pmd/ReportTest.java index afcbe068d3..ec87a657e4 100644 --- a/pmd-javascript/src/test/java/net/sourceforge/pmd/ReportTest.java +++ b/pmd-javascript/src/test/java/net/sourceforge/pmd/ReportTest.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.ecmascript.ast.ASTFunctionNode; import net.sourceforge.pmd.lang.ecmascript.ast.EcmascriptParserTestBase; import net.sourceforge.pmd.lang.ecmascript.rule.AbstractEcmascriptRule; +import net.sourceforge.pmd.reporting.Report; class ReportTest extends EcmascriptParserTestBase { diff --git a/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/DummyJsRule.java b/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/DummyJsRule.java index 97ddeaa608..4a86a86808 100644 --- a/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/DummyJsRule.java +++ b/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/DummyJsRule.java @@ -4,9 +4,9 @@ package net.sourceforge.pmd.lang.ecmascript; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ecmascript.rule.AbstractEcmascriptRule; +import net.sourceforge.pmd.reporting.RuleContext; /** * @author Clément Fournier diff --git a/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptParserTest.java b/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptParserTest.java index ee120d4569..90e42d0043 100644 --- a/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptParserTest.java +++ b/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptParserTest.java @@ -16,9 +16,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; import org.mozilla.javascript.ast.AstRoot; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ecmascript.rule.AbstractEcmascriptRule; +import net.sourceforge.pmd.reporting.Report; class EcmascriptParserTest extends EcmascriptParserTestBase { diff --git a/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/AbstractJspRule.java b/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/AbstractJspRule.java index ffe3a7b4cc..fb208c797c 100644 --- a/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/AbstractJspRule.java +++ b/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/AbstractJspRule.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.lang.jsp.rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.jsp.ast.JspParserVisitor; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.reporting.RuleContext; public abstract class AbstractJspRule extends AbstractRule implements JspParserVisitor { diff --git a/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/codestyle/DuplicateJspImportsRule.java b/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/codestyle/DuplicateJspImportsRule.java index d5b4666da6..14c9f1a641 100644 --- a/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/codestyle/DuplicateJspImportsRule.java +++ b/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/rule/codestyle/DuplicateJspImportsRule.java @@ -8,9 +8,9 @@ import java.util.HashSet; import java.util.Set; import java.util.StringTokenizer; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.jsp.ast.ASTJspDirectiveAttribute; import net.sourceforge.pmd.lang.jsp.rule.AbstractJspRule; +import net.sourceforge.pmd.reporting.RuleContext; public class DuplicateJspImportsRule extends AbstractJspRule { diff --git a/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/ast/XPathJspRuleTest.java b/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/ast/XPathJspRuleTest.java index 0fed9e17ae..183f1b17ed 100644 --- a/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/ast/XPathJspRuleTest.java +++ b/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/ast/XPathJspRuleTest.java @@ -8,9 +8,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; class XPathJspRuleTest extends AbstractJspNodesTst { diff --git a/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/AbstractKotlinRule.java b/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/AbstractKotlinRule.java index 7c13206023..e824bee510 100644 --- a/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/AbstractKotlinRule.java +++ b/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/AbstractKotlinRule.java @@ -4,9 +4,9 @@ package net.sourceforge.pmd.lang.kotlin; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.kotlin.ast.KotlinVisitor; import net.sourceforge.pmd.lang.rule.AbstractVisitorRule; +import net.sourceforge.pmd.reporting.RuleContext; public abstract class AbstractKotlinRule extends AbstractVisitorRule { diff --git a/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/rule/errorprone/OverrideBothEqualsAndHashcodeRule.java b/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/rule/errorprone/OverrideBothEqualsAndHashcodeRule.java index 224ea1b7b0..80795dde56 100644 --- a/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/rule/errorprone/OverrideBothEqualsAndHashcodeRule.java +++ b/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/rule/errorprone/OverrideBothEqualsAndHashcodeRule.java @@ -9,7 +9,6 @@ import java.util.List; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.kotlin.AbstractKotlinRule; import net.sourceforge.pmd.lang.kotlin.ast.KotlinParser.KtClassDeclaration; import net.sourceforge.pmd.lang.kotlin.ast.KotlinParser.KtClassMemberDeclaration; @@ -20,6 +19,7 @@ import net.sourceforge.pmd.lang.kotlin.ast.KotlinTerminalNode; import net.sourceforge.pmd.lang.kotlin.ast.KotlinVisitor; import net.sourceforge.pmd.lang.kotlin.ast.KotlinVisitorBase; import net.sourceforge.pmd.lang.rule.RuleTargetSelector; +import net.sourceforge.pmd.reporting.RuleContext; public class OverrideBothEqualsAndHashcodeRule extends AbstractKotlinRule { diff --git a/pmd-lang-test/src/main/java/net/sourceforge/pmd/test/AbstractMetricTestRule.java b/pmd-lang-test/src/main/java/net/sourceforge/pmd/test/AbstractMetricTestRule.java index 4c18a4eb8b..35f65663fe 100644 --- a/pmd-lang-test/src/main/java/net/sourceforge/pmd/test/AbstractMetricTestRule.java +++ b/pmd-lang-test/src/main/java/net/sourceforge/pmd/test/AbstractMetricTestRule.java @@ -9,7 +9,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.metrics.Metric; import net.sourceforge.pmd.lang.metrics.MetricOption; @@ -17,6 +16,7 @@ import net.sourceforge.pmd.lang.metrics.MetricOptions; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleContext; /** diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt index 46c3d9b272..431f99d991 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt @@ -16,6 +16,7 @@ import net.sourceforge.pmd.lang.document.TextDocument import net.sourceforge.pmd.lang.rule.XPathRule import net.sourceforge.pmd.lang.rule.xpath.XPathVersion import net.sourceforge.pmd.reporting.GlobalAnalysisListener +import net.sourceforge.pmd.reporting.Report import java.io.InputStream import java.nio.charset.StandardCharsets import java.nio.file.Files diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/TestUtils.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/TestUtils.kt index 5819192522..e037138889 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/TestUtils.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/TestUtils.kt @@ -8,8 +8,8 @@ import io.kotest.assertions.withClue import io.kotest.matchers.Matcher import io.kotest.matchers.equalityMatcher import io.kotest.matchers.should -import net.sourceforge.pmd.Report -import net.sourceforge.pmd.RuleViolation +import net.sourceforge.pmd.reporting.Report +import net.sourceforge.pmd.reporting.RuleViolation import net.sourceforge.pmd.lang.ast.Node import net.sourceforge.pmd.lang.document.Chars import kotlin.reflect.KCallable diff --git a/pmd-modelica/src/main/java/net/sourceforge/pmd/lang/modelica/rule/AbstractModelicaRule.java b/pmd-modelica/src/main/java/net/sourceforge/pmd/lang/modelica/rule/AbstractModelicaRule.java index 900cf1eea7..bb635578bd 100644 --- a/pmd-modelica/src/main/java/net/sourceforge/pmd/lang/modelica/rule/AbstractModelicaRule.java +++ b/pmd-modelica/src/main/java/net/sourceforge/pmd/lang/modelica/rule/AbstractModelicaRule.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.lang.modelica.rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.modelica.ast.ModelicaParserVisitor; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.reporting.RuleContext; /** * Base class for rules for Modelica language. diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/AbstractPLSQLRule.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/AbstractPLSQLRule.java index afa94e1f6c..18d03d691a 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/AbstractPLSQLRule.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/AbstractPLSQLRule.java @@ -5,7 +5,6 @@ package net.sourceforge.pmd.lang.plsql.rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.plsql.ast.ASTInput; import net.sourceforge.pmd.lang.plsql.ast.ASTPackageBody; @@ -16,6 +15,7 @@ import net.sourceforge.pmd.lang.plsql.ast.ASTTypeSpecification; import net.sourceforge.pmd.lang.plsql.ast.ExecutableCode; import net.sourceforge.pmd.lang.plsql.ast.PLSQLParserVisitor; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.reporting.RuleContext; public abstract class AbstractPLSQLRule extends AbstractRule implements PLSQLParserVisitor { diff --git a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/PLSQLXPathRuleTest.java b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/PLSQLXPathRuleTest.java index 09f9013008..5919fa8e55 100644 --- a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/PLSQLXPathRuleTest.java +++ b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/PLSQLXPathRuleTest.java @@ -8,9 +8,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; +import net.sourceforge.pmd.reporting.Report; /** * Tests to use XPath rules with PLSQL. diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/rule/ScalaRule.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/rule/ScalaRule.java index a385df3465..65de1b6a6a 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/rule/ScalaRule.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/rule/ScalaRule.java @@ -4,11 +4,11 @@ package net.sourceforge.pmd.lang.scala.rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.lang.scala.ast.ScalaNode; import net.sourceforge.pmd.lang.scala.ast.ScalaParserVisitor; +import net.sourceforge.pmd.reporting.RuleContext; /** * The default base implementation of a PMD Rule for Scala. Uses the Visitor diff --git a/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/ScalaRuleTest.java b/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/ScalaRuleTest.java index 144593dfef..e1dc81444e 100644 --- a/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/ScalaRuleTest.java +++ b/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/ScalaRuleTest.java @@ -10,13 +10,13 @@ import java.util.concurrent.atomic.AtomicInteger; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.scala.ast.ASTSource; import net.sourceforge.pmd.lang.scala.ast.ASTTermApply; import net.sourceforge.pmd.lang.scala.ast.ASTTermName; import net.sourceforge.pmd.lang.scala.ast.BaseScalaTest; import net.sourceforge.pmd.lang.scala.ast.ScalaNode; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleContext; class ScalaRuleTest extends BaseScalaTest { diff --git a/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/XPathRuleTest.java b/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/XPathRuleTest.java index 303040dc59..88a675de95 100644 --- a/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/XPathRuleTest.java +++ b/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/XPathRuleTest.java @@ -8,10 +8,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.scala.ast.BaseScalaTest; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; class XPathRuleTest extends BaseScalaTest { diff --git a/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/rule/AbstractSwiftRule.java b/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/rule/AbstractSwiftRule.java index 9c5a43c722..ae1cc195b0 100644 --- a/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/rule/AbstractSwiftRule.java +++ b/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/rule/AbstractSwiftRule.java @@ -4,9 +4,9 @@ package net.sourceforge.pmd.lang.swift.rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.rule.AbstractVisitorRule; import net.sourceforge.pmd.lang.swift.ast.SwiftVisitor; +import net.sourceforge.pmd.reporting.RuleContext; public abstract class AbstractSwiftRule extends AbstractVisitorRule { diff --git a/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/rule/bestpractices/UnavailableFunctionRule.java b/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/rule/bestpractices/UnavailableFunctionRule.java index 9c4a5a1df3..59d2d857c5 100644 --- a/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/rule/bestpractices/UnavailableFunctionRule.java +++ b/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/rule/bestpractices/UnavailableFunctionRule.java @@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.swift.rule.bestpractices; import java.util.List; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.swift.ast.SwiftParser.SwAttribute; import net.sourceforge.pmd.lang.swift.ast.SwiftParser.SwAttributes; import net.sourceforge.pmd.lang.swift.ast.SwiftParser.SwCodeBlock; @@ -16,6 +15,7 @@ import net.sourceforge.pmd.lang.swift.ast.SwiftParser.SwStatement; import net.sourceforge.pmd.lang.swift.ast.SwiftVisitor; import net.sourceforge.pmd.lang.swift.ast.SwiftVisitorBase; import net.sourceforge.pmd.lang.swift.rule.AbstractSwiftRule; +import net.sourceforge.pmd.reporting.RuleContext; public class UnavailableFunctionRule extends AbstractSwiftRule { diff --git a/pmd-test-schema/src/test/java/net/sourceforge/pmd/test/schema/TestSchemaParserTest.java b/pmd-test-schema/src/test/java/net/sourceforge/pmd/test/schema/TestSchemaParserTest.java index 50dde9dc41..73878474ae 100644 --- a/pmd-test-schema/src/test/java/net/sourceforge/pmd/test/schema/TestSchemaParserTest.java +++ b/pmd-test-schema/src/test/java/net/sourceforge/pmd/test/schema/TestSchemaParserTest.java @@ -15,10 +15,10 @@ import java.io.StringReader; import org.junit.jupiter.api.Test; import org.xml.sax.InputSource; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.PlainTextLanguage; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.reporting.RuleContext; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java index 546d77c7f2..907582a441 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTst.java @@ -26,18 +26,18 @@ import org.xml.sax.InputSource; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.RuleSetLoadException; import net.sourceforge.pmd.RuleSetLoader; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.renderers.TextRenderer; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; import net.sourceforge.pmd.test.schema.RuleTestCollection; import net.sourceforge.pmd.test.schema.RuleTestDescriptor; import net.sourceforge.pmd.test.schema.TestSchemaParser; diff --git a/pmd-test/src/test/java/net/sourceforge/pmd/testframework/RuleTstTest.java b/pmd-test/src/test/java/net/sourceforge/pmd/testframework/RuleTstTest.java index 7d19147c12..5f169df1a2 100644 --- a/pmd-test/src/test/java/net/sourceforge/pmd/testframework/RuleTstTest.java +++ b/pmd-test/src/test/java/net/sourceforge/pmd/testframework/RuleTstTest.java @@ -17,7 +17,6 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.LanguageVersion; @@ -25,6 +24,7 @@ import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.lang.rule.RuleTargetSelector; +import net.sourceforge.pmd.reporting.RuleContext; import net.sourceforge.pmd.test.schema.RuleTestDescriptor; class RuleTstTest { diff --git a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/rule/AbstractVfRule.java b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/rule/AbstractVfRule.java index 4fb6e82f79..f7d64546d8 100644 --- a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/rule/AbstractVfRule.java +++ b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/rule/AbstractVfRule.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.lang.vf.rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor; +import net.sourceforge.pmd.reporting.RuleContext; public abstract class AbstractVfRule extends AbstractRule implements VfParserVisitor { diff --git a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/rule/security/VfUnescapeElTest.java b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/rule/security/VfUnescapeElTest.java index b1032c5d26..880ea0641f 100644 --- a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/rule/security/VfUnescapeElTest.java +++ b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/rule/security/VfUnescapeElTest.java @@ -12,11 +12,11 @@ import java.util.List; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.vf.VFTestUtils; import net.sourceforge.pmd.lang.vf.ast.VfParsingHelper; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.RuleViolation; import net.sourceforge.pmd.testframework.PmdRuleTst; class VfUnescapeElTest extends PmdRuleTst { diff --git a/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/AbstractVmRule.java b/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/AbstractVmRule.java index b309c8edf1..2cc6bfd5ea 100644 --- a/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/AbstractVmRule.java +++ b/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/rule/AbstractVmRule.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.lang.vm.rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.lang.vm.ast.VmParserVisitor; +import net.sourceforge.pmd.reporting.RuleContext; public abstract class AbstractVmRule extends AbstractRule implements VmParserVisitor { diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/DomXPathRule.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/DomXPathRule.java index ce2df9d9de..c25cd0a192 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/DomXPathRule.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/DomXPathRule.java @@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.xml.rule; import java.util.Objects; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; @@ -14,6 +13,7 @@ import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.xml.ast.internal.XmlParserImpl.RootXmlNode; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleContext; /** * XPath rule that executes an expression on the DOM directly, and not diff --git a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRuleTest.java b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRuleTest.java index 36bdb5fb49..fbddf2f3de 100644 --- a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRuleTest.java +++ b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRuleTest.java @@ -8,10 +8,10 @@ import static net.sourceforge.pmd.lang.ast.test.TestUtilsKt.assertSize; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.xml.XmlParsingHelper; +import net.sourceforge.pmd.reporting.Report; class XmlXPathRuleTest { From f6440c6dab6a3e64d4eca5cd1117c15d411b628d Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 19 Jan 2024 11:49:08 +0100 Subject: [PATCH 08/23] [compat6] Making compat6 layer for m-pmd-p work again --- pmd-compat6/pom.xml | 14 + .../src/it/pmd-for-java/invoker.properties | 2 +- .../java/net/sourceforge/pmd/PmdAnalysis.java | 622 ++++++++++++++++++ .../main/java/net/sourceforge/pmd/Report.java | 21 +- .../sourceforge/pmd/renderers/Renderer.java | 288 ++++++++ .../net/sourceforge/pmd/reporting/Report.java | 36 + .../pmd/reporting/RuleViolation.java | 8 + 7 files changed, 980 insertions(+), 11 deletions(-) create mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/PmdAnalysis.java create mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/renderers/Renderer.java create mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/Report.java create mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/RuleViolation.java diff --git a/pmd-compat6/pom.xml b/pmd-compat6/pom.xml index 9f682a8768..10d2fc34c3 100644 --- a/pmd-compat6/pom.xml +++ b/pmd-compat6/pom.xml @@ -43,6 +43,20 @@ + + org.jboss.bridger + bridger + 1.6.Final + + + weave + process-classes + + transform + + + + org.apache.maven.plugins maven-invoker-plugin diff --git a/pmd-compat6/src/it/pmd-for-java/invoker.properties b/pmd-compat6/src/it/pmd-for-java/invoker.properties index bfaaa1661c..d03166a079 100644 --- a/pmd-compat6/src/it/pmd-for-java/invoker.properties +++ b/pmd-compat6/src/it/pmd-for-java/invoker.properties @@ -1,4 +1,4 @@ -invoker.goals.1 = verify +invoker.goals.1 = verify -e invoker.goals.2 = pmd:check -Dformat=csv invoker.goals.3 = pmd:check -Dformat=txt invoker.buildResult = failure diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/PmdAnalysis.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/PmdAnalysis.java new file mode 100644 index 0000000000..cf82fb9e0c --- /dev/null +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/PmdAnalysis.java @@ -0,0 +1,622 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +// This class has been taken from 7.0.0-SNAPSHOT +// Changes: performAnalysisAndCollectReport, changes due to Report moved package + +package net.sourceforge.pmd; + +import static net.sourceforge.pmd.util.CollectionUtil.listOf; + +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.event.Level; + +import net.sourceforge.pmd.benchmark.TimeTracker; +import net.sourceforge.pmd.benchmark.TimedOperation; +import net.sourceforge.pmd.benchmark.TimedOperationCategory; +import net.sourceforge.pmd.cache.AnalysisCacheListener; +import net.sourceforge.pmd.cache.NoopAnalysisCache; +import net.sourceforge.pmd.internal.LogMessages; +import net.sourceforge.pmd.internal.util.ClasspathClassLoader; +import net.sourceforge.pmd.internal.util.FileCollectionUtil; +import net.sourceforge.pmd.internal.util.IOUtil; +import net.sourceforge.pmd.lang.JvmLanguagePropertyBundle; +import net.sourceforge.pmd.lang.Language; +import net.sourceforge.pmd.lang.LanguageProcessor.AnalysisTask; +import net.sourceforge.pmd.lang.LanguageProcessorRegistry; +import net.sourceforge.pmd.lang.LanguageProcessorRegistry.LanguageTerminationException; +import net.sourceforge.pmd.lang.LanguagePropertyBundle; +import net.sourceforge.pmd.lang.LanguageRegistry; +import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.lang.LanguageVersionDiscoverer; +import net.sourceforge.pmd.lang.document.FileCollector; +import net.sourceforge.pmd.lang.document.TextFile; +import net.sourceforge.pmd.renderers.Renderer; +import net.sourceforge.pmd.reporting.ConfigurableFileNameRenderer; +import net.sourceforge.pmd.reporting.FileAnalysisListener; +import net.sourceforge.pmd.reporting.GlobalAnalysisListener; +import net.sourceforge.pmd.reporting.ListenerInitializer; +import net.sourceforge.pmd.reporting.Report; +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; + +/** + * Main programmatic API of PMD. This is not a CLI entry point, see module + * {@code pmd-cli} for that. + * + *

Usage overview

+ * + *

Create and configure a {@link PMDConfiguration}, + * then use {@link #create(PMDConfiguration)} to obtain an instance. + * You can perform additional configuration on the instance, e.g. adding + * files to process, or additional rulesets and renderers. Then, call + * {@link #performAnalysis()} or one of the related terminal methods. + * + *

Simple example

+ * + *
{@code
+ *   PMDConfiguration config = new PMDConfiguration();
+ *   config.setDefaultLanguageVersion(LanguageRegistry.findLanguageByTerseName("java").getVersion("11"));
+ *   config.addInputPath(Path.of("src/main/java"));
+ *   config.prependClasspath("target/classes");
+ *   config.setMinimumPriority(RulePriority.HIGH);
+ *   config.addRuleSet("rulesets/java/quickstart.xml");
+ *   config.setReportFormat("xml");
+ *   config.setReportFile("target/pmd-report.xml");
+ *
+ *   try (PmdAnalysis pmd = PmdAnalysis.create(config)) {
+ *     // note: don't use `config` once a PmdAnalysis has been created.
+ *     // optional: add more rulesets
+ *     pmd.addRuleSet(pmd.newRuleSetLoader().loadFromResource("custom-ruleset.xml"));
+ *     // optional: add more files
+ *     pmd.files().addFile(Paths.get("src", "main", "more-java", "ExtraSource.java"));
+ *     // optional: add more renderers
+ *     pmd.addRenderer(renderer);
+ *
+ *     pmd.performAnalysis();
+ *   }
+ * }
+ * + *

Rendering reports

+ * + *

If you just want to render a report to a file like with the CLI, you + * should use a {@link Renderer}. You can add a custom one with {@link PmdAnalysis#addRenderer(Renderer)}. + * You can add one of the builtin renderers from its ID using {@link PMDConfiguration#setReportFormat(String)}. + * + *

Reports and events

+ * + *

If you want strongly typed access to violations and other analysis events, + * you can implement and register a {@link GlobalAnalysisListener} with {@link #addListener(GlobalAnalysisListener)}. + * The listener needs to provide a new {@link FileAnalysisListener} for each file, + * which will receive events from the analysis. The listener's lifecycle + * happens only once the analysis is started ({@link #performAnalysis()}). + * + *

If you want access to all events once the analysis ends instead of processing + * events as they go, you can obtain a {@link Report} instance from {@link #performAnalysisAndCollectReport()}, + * or use {@link Report.GlobalReportBuilderListener} manually. Keep in + * mind collecting a report is less memory-efficient than using a listener. + * + *

If you want to process events in batches, one per file, you can + * use {@link Report.ReportBuilderListener}. to implement {@link GlobalAnalysisListener#startFileAnalysis(TextFile)}. + * + *

Listeners can be used alongside renderers. + * + *

Specifying the Java classpath

+ * + *

Java rules work better if you specify the path to the compiled classes + * of the analysed sources. See {@link PMDConfiguration#prependAuxClasspath(String)}. + * + *

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)}. + * By default, it forwards messages to SLF4J. + * + */ +public final class PmdAnalysis implements AutoCloseable { + + private static final Logger LOG = LoggerFactory.getLogger(PmdAnalysis.class); + + private final FileCollector collector; + private final List renderers = new ArrayList<>(); + private final List listeners = new ArrayList<>(); + private final List ruleSets = new ArrayList<>(); + private final PMDConfiguration configuration; + private final MessageReporter reporter; + + private final Map langProperties = new HashMap<>(); + private boolean closed; + private final ConfigurableFileNameRenderer fileNameRenderer = new ConfigurableFileNameRenderer(); + + /** + * Constructs a new instance. The files paths (input files, filelist, + * exclude list, etc) given in the configuration are collected into + * the file collector ({@link #files()}), but more can be added + * programmatically using the file collector. + */ + private PmdAnalysis(PMDConfiguration config) { + this.configuration = config; + this.reporter = config.getReporter(); + this.collector = FileCollector.newCollector( + config.getLanguageVersionDiscoverer(), + reporter + ); + + } + + /** + * Constructs a new instance from a configuration. + * + *

    + *
  • The files paths (input files, filelist, + * exclude list, etc) are explored and the files to analyse are + * collected into the file collector ({@link #files()}). + * More can be added programmatically using the file collector. + *
  • The rulesets given in the configuration are loaded ({@link PMDConfiguration#getRuleSets()}) + *
  • A renderer corresponding to the parameters of the configuration + * is created and added (but not started). + *
+ */ + public static PmdAnalysis create(PMDConfiguration config) { + PmdAnalysis pmd = new PmdAnalysis(config); + + // note: do not filter files by language + // they could be ignored later. The problem is if you call + // addRuleSet later, then you could be enabling new languages + // So the files should not be pruned in advance + FileCollectionUtil.collectFiles(config, pmd.files()); + + if (config.getReportFormat() != null) { + Renderer renderer = config.createRenderer(true); + pmd.addRenderer(renderer); + } + + if (!config.getRuleSetPaths().isEmpty()) { + final RuleSetLoader ruleSetLoader = pmd.newRuleSetLoader(); + final List ruleSets = ruleSetLoader.loadRuleSetsWithoutException(config.getRuleSetPaths()); + pmd.addRuleSets(ruleSets); + } + + for (Language language : config.getLanguageRegistry()) { + LanguagePropertyBundle props = config.getLanguageProperties(language); + assert props.getLanguage().equals(language); + pmd.langProperties.put(language, props); + + LanguageVersion forcedVersion = config.getForceLanguageVersion(); + if (forcedVersion != null && forcedVersion.getLanguage().equals(language)) { + props.setLanguageVersion(forcedVersion.getVersion()); + } + + // TODO replace those with actual language properties when the + // CLI syntax is implemented. + props.setProperty(LanguagePropertyBundle.SUPPRESS_MARKER, config.getSuppressMarker()); + if (props instanceof JvmLanguagePropertyBundle) { + ((JvmLanguagePropertyBundle) props).setClassLoader(config.getClassLoader()); + } + } + + for (Path path : config.getRelativizeRoots()) { + pmd.fileNameRenderer.relativizeWith(path); + } + + return pmd; + } + + // test only + List rulesets() { + return ruleSets; + } + + // test only + List renderers() { + return renderers; + } + + + /** + * Returns the file collector for the analysed sources. + */ + public FileCollector files() { + return collector; // todo user can close collector programmatically + } + + /** + * Returns a new ruleset loader, which can be used to create new + * rulesets (add them then with {@link #addRuleSet(RuleSet)}). + * + *
{@code
+     * try (PmdAnalysis pmd = create(config)) {
+     *     pmd.addRuleSet(pmd.newRuleSetLoader().loadFromResource("custom-ruleset.xml"));
+     * }
+     * }
+ */ + public RuleSetLoader newRuleSetLoader() { + return RuleSetLoader.fromPmdConfig(configuration); + } + + /** + * Add a new renderer. The given renderer must not already be started, + * it will be started by {@link #performAnalysis()}. + * + * @throws NullPointerException If the parameter is null + */ + public void addRenderer(Renderer renderer) { + AssertionUtil.requireParamNotNull("renderer", renderer); + this.renderers.add(renderer); + } + + /** + * Add several renderers at once. + * + * @throws NullPointerException If the parameter is null, or any of its items is null. + */ + public void addRenderers(Collection renderers) { + renderers.forEach(this::addRenderer); + } + + /** + * Add a new listener. As per the contract of {@link GlobalAnalysisListener}, + * this object must be ready for interaction. However, nothing will + * be done with the listener until {@link #performAnalysis()} is called. + * The listener will be closed by {@link #performAnalysis()}, or + * {@link #close()}, whichever happens first. + * + * @throws NullPointerException If the parameter is null + */ + public void addListener(GlobalAnalysisListener listener) { + AssertionUtil.requireParamNotNull("listener", listener); + this.listeners.add(listener); + } + + /** + * Add several listeners at once. + * + * @throws NullPointerException If the parameter is null, or any of its items is null. + * @see #addListener(GlobalAnalysisListener) + */ + public void addListeners(Collection listeners) { + listeners.forEach(this::addListener); + } + + /** + * Add a new ruleset. + * + * @throws NullPointerException If the parameter is null + */ + public void addRuleSet(RuleSet ruleSet) { + AssertionUtil.requireParamNotNull("rule set", ruleSet); + this.ruleSets.add(ruleSet); + } + + /** + * Add several rulesets at once. + * + * @throws NullPointerException If the parameter is null, or any of its items is null. + */ + public void addRuleSets(Collection ruleSets) { + ruleSets.forEach(this::addRuleSet); + } + + /** + * Returns an unmodifiable view of the ruleset list. That will be + * processed. + */ + public List getRulesets() { + return Collections.unmodifiableList(ruleSets); + } + + + /** + * Returns a mutable bundle of language properties that are associated + * to the given language (always the same for a given language). + * + * @param language A language, which must be registered + */ + public LanguagePropertyBundle getLanguageProperties(Language language) { + configuration.checkLanguageIsRegistered(language); + return langProperties.computeIfAbsent(language, Language::newPropertyBundle); + } + + + public ConfigurableFileNameRenderer fileNameRenderer() { + return fileNameRenderer; + } + + /** + * Run PMD with the current state of this instance. This will start + * and finish the registered renderers, and close all + * {@linkplain #addListener(GlobalAnalysisListener) registered listeners}. + * All files collected in the {@linkplain #files() file collector} are + * 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}. + */ + public void performAnalysis() { + performAnalysisImpl(Collections.emptyList()); + } + + /** + * Run PMD with the current state of this instance. This will start + * 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}. + */ + public Report performAnalysisAndCollectReport() { + try (Report.GlobalReportBuilderListener reportBuilder = new Report.GlobalReportBuilderListener()) { + performAnalysisImpl(listOf(reportBuilder)); // closes the report builder + return reportBuilder.getResultImpl(); + } + } + + void performAnalysisImpl(List extraListeners) { + try (FileCollector files = collector) { + files.filterLanguages(getApplicableLanguages(false)); + performAnalysisImpl(extraListeners, files.getCollectedFiles()); + } + } + + void performAnalysisImpl(List extraListeners, List textFiles) { + RuleSets rulesets = new RuleSets(this.ruleSets); + + GlobalAnalysisListener listener; + try { + @SuppressWarnings("PMD.CloseResource") + AnalysisCacheListener cacheListener = new AnalysisCacheListener(configuration.getAnalysisCache(), + rulesets, + configuration.getClassLoader(), + textFiles); + listener = GlobalAnalysisListener.tee(listOf(createComposedRendererListener(renderers), + GlobalAnalysisListener.tee(listeners), + GlobalAnalysisListener.tee(extraListeners), + cacheListener)); + + // Initialize listeners + try (ListenerInitializer initializer = listener.initializer()) { + initializer.setNumberOfFilesToAnalyze(textFiles.size()); + initializer.setFileNameRenderer(fileNameRenderer()); + } + } catch (Exception e) { + reporter.errorEx("Exception while initializing analysis listeners", e); + throw new RuntimeException("Exception while initializing analysis listeners", e); + } + + try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.FILE_PROCESSING)) { + for (final Rule rule : removeBrokenRules(rulesets)) { + // todo Just like we throw for invalid properties, "broken rules" + // shouldn't be a "config error". This is the only instance of + // config errors... + // see https://github.com/pmd/pmd/issues/3901 + listener.onConfigError(new Report.ConfigurationError(rule, rule.dysfunctionReason())); + } + + encourageToUseIncrementalAnalysis(configuration); + + try (LanguageProcessorRegistry lpRegistry = LanguageProcessorRegistry.create( + // only start the applicable languages (and dependencies) + new LanguageRegistry(getApplicableLanguages(true)), + langProperties, + reporter + )) { + // Note the analysis task is shared: all processors see + // the same file list, which may contain files for other + // languages. + AnalysisTask analysisTask = new AnalysisTask( + rulesets, + textFiles, + listener, + configuration.getThreads(), + configuration.getAnalysisCache(), + reporter, + lpRegistry + ); + + List analyses = new ArrayList<>(); + try { + for (Language lang : lpRegistry.getLanguages()) { + analyses.add(lpRegistry.getProcessor(lang).launchAnalysis(analysisTask)); + } + } finally { + Exception e = IOUtil.closeAll(analyses); + if (e != null) { + reporter.errorEx("Error while joining analysis", e); + } + } + + } catch (LanguageTerminationException e) { + reporter.errorEx("Error while closing language processors", e); + } + } finally { + try { + listener.close(); + } catch (Exception e) { + reporter.errorEx("Exception while closing analysis listeners", e); + // todo better exception + throw new RuntimeException("Exception while closing analysis listeners", e); + } + } + } + + + private GlobalAnalysisListener createComposedRendererListener(List renderers) throws Exception { + if (renderers.isEmpty()) { + return GlobalAnalysisListener.noop(); + } + + List rendererListeners = new ArrayList<>(renderers.size()); + for (Renderer renderer : renderers) { + try { + @SuppressWarnings("PMD.CloseResource") + GlobalAnalysisListener listener = + Objects.requireNonNull(renderer.newListener(), "Renderer should provide non-null listener"); + rendererListeners.add(listener); + } catch (Exception ioe) { + // close listeners so far, throw their close exception or the ioe + IOUtil.ensureClosed(rendererListeners, ioe); + throw AssertionUtil.shouldNotReachHere("ensureClosed should have thrown"); + } + } + return GlobalAnalysisListener.tee(rendererListeners); + } + + private Set getApplicableLanguages(boolean quiet) { + Set languages = new HashSet<>(); + LanguageVersionDiscoverer discoverer = configuration.getLanguageVersionDiscoverer(); + + for (RuleSet ruleSet : ruleSets) { + for (Rule rule : ruleSet.getRules()) { + Language ruleLanguage = rule.getLanguage(); + Objects.requireNonNull(ruleLanguage, "Rule has no language " + rule); + if (!languages.contains(ruleLanguage)) { + LanguageVersion version = discoverer.getDefaultLanguageVersion(ruleLanguage); + if (RuleSet.applies(rule, version)) { + configuration.checkLanguageIsRegistered(ruleLanguage); + languages.add(ruleLanguage); + if (!quiet) { + LOG.trace("Using {} version ''{}''", version.getLanguage().getName(), version.getTerseName()); + } + } + } + } + } + + // collect all dependencies, they shouldn't be filtered out + LanguageRegistry reg = configuration.getLanguageRegistry(); + boolean changed; + do { + changed = false; + for (Language lang : new HashSet<>(languages)) { + for (String depId : lang.getDependencies()) { + Language depLang = reg.getLanguageById(depId); + if (depLang == null) { + // todo maybe report all then throw + throw new IllegalStateException( + "Language " + lang.getId() + " has unsatisfied dependencies: " + + depId + " is not found in " + reg + ); + } + changed |= languages.add(depLang); + } + } + } while (changed); + return languages; + } + + /** + * Remove and return the misconfigured rules from the rulesets and log them + * for good measure. + */ + private Set removeBrokenRules(final RuleSets ruleSets) { + final Set brokenRules = new HashSet<>(); + ruleSets.removeDysfunctionalRules(brokenRules); + + for (final Rule rule : brokenRules) { + reporter.warn("Removed misconfigured rule: {0} cause: {1}", + rule.getName(), rule.dysfunctionReason()); + } + + return brokenRules; + } + + + public MessageReporter getReporter() { + return reporter; + } + + @Override + public void close() { + if (closed) { + return; + } + closed = true; + collector.close(); + + // close listeners if analysis is not run. + IOUtil.closeAll(listeners); + + /* + * Make sure it's our own classloader before attempting to close it.... + * Maven + Jacoco provide us with a cloaseable classloader that if closed + * will throw a ClassNotFoundException. + */ + if (configuration.getClassLoader() instanceof ClasspathClassLoader) { + IOUtil.tryCloseClassLoader(configuration.getClassLoader()); + } + } + + public ReportStats runAndReturnStats() { + if (getRulesets().isEmpty()) { + return ReportStats.empty(); + } + + @SuppressWarnings("PMD.CloseResource") + ReportStatsListener listener = new ReportStatsListener(); + + addListener(listener); + + try { + performAnalysis(); + } catch (Exception e) { + getReporter().errorEx("Exception during processing", e); + ReportStats stats = listener.getResult(); + printErrorDetected(1 + stats.getNumErrors()); + return stats; // should have been closed + } + ReportStats stats = listener.getResult(); + + if (stats.getNumErrors() > 0) { + printErrorDetected(stats.getNumErrors()); + } + + return stats; + } + + static void printErrorDetected(MessageReporter 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)); + } + + void printErrorDetected(int errors) { + printErrorDetected(getReporter(), errors); + } + + private static void encourageToUseIncrementalAnalysis(final PMDConfiguration configuration) { + final MessageReporter reporter = configuration.getReporter(); + + if (!configuration.isIgnoreIncrementalAnalysis() + && configuration.getAnalysisCache() instanceof NoopAnalysisCache + && reporter.isLoggable(Level.WARN)) { + final String version = + PMDVersion.isUnknown() || PMDVersion.isSnapshot() ? "latest" : "pmd-doc-" + PMDVersion.VERSION; + reporter.warn("This analysis could be faster, please consider using Incremental Analysis: " + + "https://docs.pmd-code.org/{0}/pmd_userdocs_incremental_analysis.html", version); + } + } + + // ---- compatibility + + // new method to be compatible with PMD 6 - Report has changed package + public net.sourceforge.pmd.Report performAnalysisAndCollectReport$$bridge() { // SUPPRESS CHECKSTYLE ignore + return performAnalysisAndCollectReport(); + } +} diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/Report.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/Report.java index 35b312b7b5..a5eff60bf1 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/Report.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/Report.java @@ -26,10 +26,11 @@ import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.renderers.AbstractAccumulatingRenderer; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; +import net.sourceforge.pmd.reporting.ViolationSuppressor; import net.sourceforge.pmd.util.BaseResultProducingCloseable; /** - * A {@link Report} collects all informations during a PMD execution. This + * A {@link Report} collects all information during a PMD execution. This * includes violations, suppressed violations, metrics, error during processing * and configuration errors. * @@ -46,7 +47,7 @@ import net.sourceforge.pmd.util.BaseResultProducingCloseable; * These methods create a new {@link Report} rather than modifying their receiver. *

*/ -public final class Report { +public class Report { // todo move to package reporting private final List violations = synchronizedList(new ArrayList<>()); @@ -312,7 +313,7 @@ public final class Report { * A {@link FileAnalysisListener} that accumulates events into a * {@link Report}. */ - public static final class ReportBuilderListener extends BaseResultProducingCloseable implements FileAnalysisListener { + public static /*final*/ class ReportBuilderListener extends BaseResultProducingCloseable implements FileAnalysisListener { private final Report report; @@ -330,17 +331,17 @@ public final class Report { } @Override - public void onRuleViolation(RuleViolation violation) { + public void onRuleViolation(net.sourceforge.pmd.reporting.RuleViolation violation) { report.addRuleViolation(violation); } @Override - public void onSuppressedRuleViolation(SuppressedViolation violation) { + public void onSuppressedRuleViolation(net.sourceforge.pmd.reporting.Report.SuppressedViolation violation) { report.addSuppressedViolation(violation); } @Override - public void onError(ProcessingError error) { + public void onError(net.sourceforge.pmd.reporting.Report.ProcessingError error) { report.addError(error); } @@ -354,9 +355,9 @@ public final class Report { * A {@link GlobalAnalysisListener} that accumulates the events of * all files into a {@link Report}. */ - public static final class GlobalReportBuilderListener extends BaseResultProducingCloseable implements GlobalAnalysisListener { + public static /*final*/ class GlobalReportBuilderListener extends BaseResultProducingCloseable implements GlobalAnalysisListener { - private final Report report = new Report(); + private final net.sourceforge.pmd.reporting.Report report = new net.sourceforge.pmd.reporting.Report(); @Override public FileAnalysisListener startFileAnalysis(TextFile file) { @@ -365,12 +366,12 @@ public final class Report { } @Override - public void onConfigError(ConfigurationError error) { + public void onConfigError(net.sourceforge.pmd.reporting.Report.ConfigurationError error) { report.addConfigError(error); } @Override - protected Report getResultImpl() { + protected net.sourceforge.pmd.reporting.Report getResultImpl() { return report; } } diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/renderers/Renderer.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/renderers/Renderer.java new file mode 100644 index 0000000000..3013dbc7d1 --- /dev/null +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/renderers/Renderer.java @@ -0,0 +1,288 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +// This class has been taken from 7.0.0-SNAPSHOT +// Changes: renderFileReport + +package net.sourceforge.pmd.renderers; + +import java.io.IOException; +import java.io.Writer; + +import net.sourceforge.pmd.annotation.Experimental; +import net.sourceforge.pmd.benchmark.TimeTracker; +import net.sourceforge.pmd.benchmark.TimedOperation; +import net.sourceforge.pmd.benchmark.TimedOperationCategory; +import net.sourceforge.pmd.lang.document.TextFile; +import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.properties.PropertySource; +import net.sourceforge.pmd.reporting.FileAnalysisListener; +import net.sourceforge.pmd.reporting.FileNameRenderer; +import net.sourceforge.pmd.reporting.GlobalAnalysisListener; +import net.sourceforge.pmd.reporting.ListenerInitializer; +import net.sourceforge.pmd.reporting.Report; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.GlobalReportBuilderListener; +import net.sourceforge.pmd.reporting.Report.ProcessingError; +import net.sourceforge.pmd.reporting.Report.ReportBuilderListener; +import net.sourceforge.pmd.reporting.Report.SuppressedViolation; +import net.sourceforge.pmd.reporting.RuleViolation; + +/** + * This is an interface for rendering a Report. When a Renderer is being + * invoked, the sequence of method calls is something like the following: + *
    + *
  1. Renderer construction/initialization
  2. + *
  3. {@link Renderer#setShowSuppressedViolations(boolean)}
  4. + *
  5. {@link Renderer#setWriter(Writer)}
  6. + *
  7. {@link Renderer#start()}
  8. + *
  9. {@link Renderer#startFileAnalysis(TextFile)} for each source file + * processed
  10. + *
  11. {@link Renderer#renderFileReport(Report)} for each Report instance
  12. + *
  13. {@link Renderer#end()}
  14. + *
+ *

+ * An implementation of the Renderer interface is expected to have a default + * constructor. Properties should be defined using the + * {@link #definePropertyDescriptor(PropertyDescriptor)} + * method. After the instance is created, the property values are set. This + * means, you won't have access to property values in your constructor. + */ +// TODO Are implementations expected to be thread-safe? +public interface Renderer extends PropertySource { + + /** + * Get the name of the Renderer. + * + * @return The name of the Renderer. + */ + @Override + String getName(); + + /** + * Set the name of the Renderer. + * + * @param name + * The name of the Renderer. + */ + void setName(String name); + + /** + * Get the description of the Renderer. + * + * @return The description of the Renderer. + */ + String getDescription(); + + /** + * Return the default filename extension to use. + * + * @return String + */ + String defaultFileExtension(); + + /** + * Set the description of the Renderer. + * + * @param description + * The description of the Renderer. + */ + void setDescription(String description); + + /** + * Get the indicator for whether to show suppressed violations. + * + * @return true if suppressed violations should show, + * false otherwise. + */ + boolean isShowSuppressedViolations(); + + /** + * Set the indicator for whether to show suppressed violations. + * + * @param showSuppressedViolations + * Whether to show suppressed violations. + */ + void setShowSuppressedViolations(boolean showSuppressedViolations); + + /** + * Get the Writer for the Renderer. + * + * @return The Writer. + */ + Writer getWriter(); + + /** + * Set the {@link FileNameRenderer} used to render file paths to the report. + * Note that this renderer does not have to use the parameter to output paths. + * Some report formats require a specific format for paths (eg a URI), and are + * allowed to circumvent the provided strategy. + * + * @param fileNameRenderer a non-null file name renderer + */ + void setFileNameRenderer(FileNameRenderer fileNameRenderer); + + /** + * Set the Writer for the Renderer. + * + * @param writer The Writer. + */ + void setWriter(Writer writer); + + /** + * This method is called before any source files are processed. The Renderer + * will have been fully initialized by the time this method is called, so + * the Writer and other state will be available. + * + * @throws IOException + */ + void start() throws IOException; + + /** + * This method is called each time a source file is processed. It is called + * after {@link Renderer#start()}, but before + * {@link Renderer#renderFileReport(Report)} and {@link Renderer#end()}. + * + * This method may be invoked by different threads which are processing + * files independently. Therefore, any non-trivial implementation of this + * method needs to be thread-safe. + * + * @param dataSource + * The source file. + */ + void startFileAnalysis(TextFile dataSource); + + /** + * Render the given file Report. There may be multiple Report instances + * which need to be rendered if produced by different threads. It is called + * after {@link Renderer#start()} and + * {@link Renderer#startFileAnalysis(TextFile)}, but before + * {@link Renderer#end()}. + * + * @param report + * A file Report. + * @throws IOException + * + * @see Report + */ + void renderFileReport(Report report) throws IOException; + + /** + * This method is at the very end of the Rendering process, after + * {@link Renderer#renderFileReport(Report)}. + */ + void end() throws IOException; + + void flush() throws IOException; + + /** + * Sets the filename where the report should be written to. If no filename is provided, + * the renderer should write to stdout. + * + *

Implementations must initialize the writer of the renderer. + * + *

See {@link AbstractRenderer#setReportFile(String)} for the default impl. + * + * @param reportFilename the filename (optional). + */ + @Experimental + void setReportFile(String reportFilename); + + + + /** + * Returns a new analysis listener, that handles violations by rendering + * them in an implementation-defined way. + */ + // TODO the default implementation matches the current behavior, + // ie violations are batched by file and forwarded to the renderer + // when the file is done. Many renderers could directly handle + // violations as they come though. + default GlobalAnalysisListener newListener() throws IOException { + try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.REPORTING)) { + this.start(); + } + + return new GlobalAnalysisListener() { + + // guard for the close routine + final Object reportMergeLock = new Object(); + + final GlobalReportBuilderListener configErrorReport = new GlobalReportBuilderListener(); + + @Override + public void onConfigError(ConfigurationError error) { + configErrorReport.onConfigError(error); + } + + @Override + public ListenerInitializer initializer() { + return new ListenerInitializer() { + @Override + public void setFileNameRenderer(FileNameRenderer fileNameRenderer) { + Renderer.this.setFileNameRenderer(fileNameRenderer); + } + }; + } + + @Override + public FileAnalysisListener startFileAnalysis(TextFile file) { + Renderer renderer = Renderer.this; + + renderer.startFileAnalysis(file); // this routine is thread-safe by contract + return new FileAnalysisListener() { + final ReportBuilderListener reportBuilder = new ReportBuilderListener(); + + @Override + public void onRuleViolation(RuleViolation violation) { + reportBuilder.onRuleViolation(violation); + } + + @Override + public void onSuppressedRuleViolation(SuppressedViolation violation) { + reportBuilder.onSuppressedRuleViolation(violation); + } + + @Override + public void onError(ProcessingError error) { + reportBuilder.onError(error); + } + + @Override + public void close() throws Exception { + reportBuilder.close(); + synchronized (reportMergeLock) { + // TODO renderFileReport should be thread-safe instead + try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.REPORTING)) { + renderer.renderFileReport(reportBuilder.getResult()); + } + } + } + + @Override + public String toString() { + return "FileRendererListener[" + Renderer.this + "]"; + } + }; + } + + @Override + public void close() throws Exception { + configErrorReport.close(); + Renderer.this.renderFileReport(configErrorReport.getResult()); + try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.REPORTING)) { + end(); + flush(); + } + } + }; + } + + // --- compat + default void renderFileReport(net.sourceforge.pmd.Report report) throws IOException { + Report newReport = new Report(); + newReport.merge(report); + renderFileReport(newReport); + } +} diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/Report.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/Report.java new file mode 100644 index 0000000000..5132f8ee29 --- /dev/null +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/Report.java @@ -0,0 +1,36 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.reporting; + +import net.sourceforge.pmd.Rule; +import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.lang.document.FileId; + +public class Report extends net.sourceforge.pmd.Report { + + public static class ConfigurationError extends net.sourceforge.pmd.Report.ConfigurationError { + public ConfigurationError(Rule theRule, String theIssue) { + super(theRule, theIssue); + } + } + + public static class ProcessingError extends net.sourceforge.pmd.Report.ProcessingError { + public ProcessingError(Throwable error, FileId file) { + super(error, file); + } + } + + public static class SuppressedViolation extends net.sourceforge.pmd.Report.SuppressedViolation { + public SuppressedViolation(RuleViolation rv, ViolationSuppressor suppressor, String userMessage) { + super(rv, suppressor, userMessage); + } + } + + public static final class GlobalReportBuilderListener extends net.sourceforge.pmd.Report.GlobalReportBuilderListener { + } + + public static final class ReportBuilderListener extends net.sourceforge.pmd.Report.ReportBuilderListener { + } +} diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/RuleViolation.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/RuleViolation.java new file mode 100644 index 0000000000..d501b9820e --- /dev/null +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/RuleViolation.java @@ -0,0 +1,8 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.reporting; + +public interface RuleViolation extends net.sourceforge.pmd.RuleViolation { +} From 7c29f16eace31b341091c4c92b6167e9d6b231ec Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 19 Jan 2024 12:52:51 +0100 Subject: [PATCH 09/23] [core] Move XPathRule into subpackage lang.rule.xpath (#4309) --- .../userdocs/extending/writing_rules_intro.md | 4 +- .../pmd/userdocs/extending/your_first_rule.md | 2 +- docs/pages/pmd/userdocs/migrating_to_pmd7.md | 6 +- docs/pages/release_notes.md | 7 +- .../resources/category/apex/bestpractices.xml | 4 +- .../resources/category/apex/codestyle.xml | 10 +- .../resources/category/apex/errorprone.xml | 14 +- .../resources/category/apex/performance.xml | 4 +- .../pmd/lang/apex/rule/ApexXPathRuleTest.java | 2 +- .../pmd/cli/RuleSetWithViolations.xml | 2 +- .../src/it/pmd-for-java/exception_ruleset.xml | 2 +- .../java/net/sourceforge/pmd/RuleSet.java | 2 +- .../pmd/lang/rule/{ => xpath}/XPathRule.java | 8 +- .../xpath/internal/DeprecatedAttrLogger.java | 2 +- .../xpath/internal/SaxonXPathRuleQuery.java | 2 +- .../sourceforge/pmd/RuleSetFactoryTest.java | 4 +- .../sourceforge/pmd/RuleSetWriterTest.java | 2 +- .../pmd/lang/rule/XPathRuleTest.java | 1 + .../renderers/CodeClimateRendererTest.java | 2 +- .../net/sourceforge/pmd/TestRuleset1.xml | 2 +- .../net/sourceforge/pmd/xml/j2ee.xml | 18 +-- .../test/resources/rulesets/dummy/basic.xml | 4 +- .../pmd/docs/RuleDocGenerator.java | 2 +- .../resources/rulesets/ruledoctest/sample.xml | 6 +- .../rulesets/ruledoctest/sample2.xml | 2 +- .../resources/category/html/bestpractices.xml | 2 +- .../pmd/lang/html/HtmlXPathRuleTest.java | 2 +- .../resources/category/java/bestpractices.xml | 42 +++--- .../resources/category/java/codestyle.xml | 60 ++++---- .../main/resources/category/java/design.xml | 32 ++--- .../resources/category/java/documentation.xml | 4 +- .../resources/category/java/errorprone.xml | 136 +++++++++--------- .../category/java/multithreading.xml | 14 +- .../resources/category/java/performance.xml | 20 +-- .../pmd/lang/java/rule/XPathRuleTest.java | 2 +- .../xpath/internal/BaseXPathFunctionTest.java | 2 +- .../pmd/ant/classpathtest/ruleset.xml | 2 +- .../category/ecmascript/bestpractices.xml | 8 +- .../category/ecmascript/codestyle.xml | 18 +-- .../category/ecmascript/errorprone.xml | 6 +- .../resources/category/jsp/bestpractices.xml | 8 +- .../main/resources/category/jsp/design.xml | 6 +- .../resources/category/jsp/errorprone.xml | 2 +- .../main/resources/category/jsp/security.xml | 2 +- .../category/kotlin/bestpractices.xml | 2 +- .../pmd/lang/ast/test/BaseParsingHelper.kt | 2 +- .../category/modelica/bestpractices.xml | 2 +- .../category/plsql/bestpractices.xml | 2 +- .../resources/category/plsql/codestyle.xml | 4 +- .../main/resources/category/plsql/design.xml | 2 +- .../resources/category/plsql/errorprone.xml | 6 +- .../pmd/lang/plsql/PLSQLXPathRuleTest.java | 2 +- .../pmd/lang/scala/rule/XPathRuleTest.java | 2 +- .../category/swift/bestpractices.xml | 2 +- .../resources/category/swift/errorprone.xml | 4 +- .../pmd/AbstractRuleSetFactoryTest.java | 2 +- .../main/resources/rulesets/dummy/basic.xml | 2 +- .../src/main/resources/category/vm/design.xml | 2 +- .../pmd/lang/xml/rule/DomXPathRule.java | 2 +- .../resources/category/pom/errorprone.xml | 4 +- .../resources/category/xml/bestpractices.xml | 2 +- .../resources/category/xml/errorprone.xml | 2 +- .../main/resources/category/xsl/codestyle.xml | 2 +- .../resources/category/xsl/performance.xml | 2 +- 64 files changed, 269 insertions(+), 263 deletions(-) rename pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/{ => xpath}/XPathRule.java (97%) diff --git a/docs/pages/pmd/userdocs/extending/writing_rules_intro.md b/docs/pages/pmd/userdocs/extending/writing_rules_intro.md index 2831e1eb0f..c110e02add 100644 --- a/docs/pages/pmd/userdocs/extending/writing_rules_intro.md +++ b/docs/pages/pmd/userdocs/extending/writing_rules_intro.md @@ -103,7 +103,7 @@ instead of mentioning the `ref` attribute, it mentions the `class` attribute, with the implementation class of your rule. * **For Java rules:** this is the concrete class extending AbstractRule (transitively) -* **For XPath rules:** this is `net.sourceforge.pmd.lang.rule.XPathRule`. +* **For XPath rules:** this is `net.sourceforge.pmd.lang.rule.xpath.XPathRule`. * **For XPath rules analyzing XML-based languages:** this is `net.sourceforge.pmd.lang.xml.rule.DomXPathRule`. See [XPath rules in XML](pmd_languages_xml.html#xpath-rules-in-xml) for more info. @@ -127,7 +127,7 @@ Example for XPath rule: + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"> Description diff --git a/docs/pages/pmd/userdocs/extending/your_first_rule.md b/docs/pages/pmd/userdocs/extending/your_first_rule.md index eeb2e064c8..18c715471a 100644 --- a/docs/pages/pmd/userdocs/extending/your_first_rule.md +++ b/docs/pages/pmd/userdocs/extending/your_first_rule.md @@ -127,7 +127,7 @@ copy-paste into your ruleset XML. The resulting element looks like so: + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"> TODO diff --git a/docs/pages/pmd/userdocs/migrating_to_pmd7.md b/docs/pages/pmd/userdocs/migrating_to_pmd7.md index a78f4224ad..ef04f34a48 100644 --- a/docs/pages/pmd/userdocs/migrating_to_pmd7.md +++ b/docs/pages/pmd/userdocs/migrating_to_pmd7.md @@ -94,8 +94,10 @@ won't support XPath 1.0 anymore. The difference between XPath 2.0 and XPath 3.1 can be expected to work in PMD 7 without any further changes. So the migration path is to simply migrate to XPath 2.0. After you have migrated your XPath rules to XPath 2.0, remove the "version" property, since that will be removed -with PMD 7. PMD 7 by default uses XPath 3.1. -See below [XPath](#xpath-migrating-from-10-to-20) for details. +with PMD 7. PMD 7 by default uses XPath 3.1. See below [XPath](#xpath-migrating-from-10-to-20) for details. + +Then change the `class` attribute of your rule to `net.sourceforge.pmd.lang.rule.xpath.XPathRule` - because the +class {%jdoc core::lang.rule.xpath.XPathRule %} has been moved into subpackage {% jdoc_package core::lang.rule.xpath %}. Additional infos: * The custom XPath function `typeOf` has been removed (deprecated since 6.4.0). diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index cbf09dab12..814730cb48 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -152,7 +152,12 @@ in the Migration Guide. #### API Changes -**Removed classes and methods** +**Moved classes/consolidated packages** + +* pmd-core + * {%jdoc core::lang.rule.xpath.XPathRule %} has been moved into subpackage {% jdoc_package core::lang.rule.xpath %}. + +* **Removed classes and methods** The following previously deprecated classes have been removed: diff --git a/pmd-apex/src/main/resources/category/apex/bestpractices.xml b/pmd-apex/src/main/resources/category/apex/bestpractices.xml index 178f94e82e..637a647543 100644 --- a/pmd-apex/src/main/resources/category/apex/bestpractices.xml +++ b/pmd-apex/src/main/resources/category/apex/bestpractices.xml @@ -106,7 +106,7 @@ private class TestRunAs { since="6.13.0" language="apex" message="Apex test methods should have @isTest annotation." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_bestpractices.html#apexunittestmethodshouldhaveistestannotation"> Apex test methods should have `@isTest` annotation instead of the `testMethod` keyword, @@ -231,7 +231,7 @@ trigger Accounts on Account (before insert, before update, before delete, after since="6.18.0" language="apex" message="Calls to System.debug should specify a logging level." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_bestpractices.html#debugsshoulduselogginglevel"> The first parameter of System.debug, when using the signature with two parameters, is a LoggingLevel enum. diff --git a/pmd-apex/src/main/resources/category/apex/codestyle.xml b/pmd-apex/src/main/resources/category/apex/codestyle.xml index c2028bfd3c..448d8e9a00 100644 --- a/pmd-apex/src/main/resources/category/apex/codestyle.xml +++ b/pmd-apex/src/main/resources/category/apex/codestyle.xml @@ -37,7 +37,7 @@ public class fooClass { } // This will be reported unless you change the regex language="apex" since="5.6.0" message="Avoid using 'if...else' statements without curly braces" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_codestyle.html#ifelsestmtsmustusebraces"> Avoid using if..else statements without using surrounding braces. If the code formatting @@ -74,7 +74,7 @@ else language="apex" since="5.6.0" message="Avoid using if statements without curly braces" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_codestyle.html#ifstmtsmustusebraces"> Avoid using if statements without using braces to surround the code block. If the code @@ -156,7 +156,7 @@ public class Foo { language="apex" since="5.6.0" message="Avoid using 'for' statements without curly braces" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_codestyle.html#forloopsmustusebraces"> Avoid using 'for' statements without using surrounding braces. If the code formatting or @@ -270,7 +270,7 @@ public class Foo { language="apex" since="6.7.0" message="Use one statement for each line, it enhances code readability." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_codestyle.html#onedeclarationperline"> Apex allows the use of several variables declaration of the same type on one line. However, it @@ -338,7 +338,7 @@ public class Foo { language="apex" since="5.6.0" message="Avoid using 'while' statements without curly braces" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_codestyle.html#whileloopsmustusebraces"> Avoid using 'while' statements without using braces to surround the code block. If the code diff --git a/pmd-apex/src/main/resources/category/apex/errorprone.xml b/pmd-apex/src/main/resources/category/apex/errorprone.xml index 76795e4987..e0e92eb6c6 100644 --- a/pmd-apex/src/main/resources/category/apex/errorprone.xml +++ b/pmd-apex/src/main/resources/category/apex/errorprone.xml @@ -54,7 +54,7 @@ public class Foo { language="apex" since="6.0.0" message="Avoid directly accessing Trigger.old and Trigger.new" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#avoiddirectaccesstriggermap"> Avoid directly accessing Trigger.old and Trigger.new as it can lead to a bug. Triggers should be bulkified and iterate through the map to handle the actions for each item separately. @@ -138,7 +138,7 @@ public without sharing class Foo { language="apex" since="6.0.0" message="Avoid empty catch blocks" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#emptycatchblock"> Empty Catch Block finds instances where an exception is caught, but nothing is done. @@ -177,7 +177,7 @@ public void doSomething() { language="apex" since="6.0.0" message="Avoid empty 'if' statements" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#emptyifstmt"> Empty If Statement finds instances where a condition is checked but nothing is done about it. @@ -210,7 +210,7 @@ public class Foo { language="apex" since="6.0.0" message="Avoid empty block statements." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#emptystatementblock"> Empty block statements serve no purpose and should be removed. @@ -247,7 +247,7 @@ public class Foo { language="apex" since="6.0.0" message="Avoid empty try or finally blocks" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#emptytryorfinallyblock"> Avoid empty try or finally blocks - what's the point? @@ -291,7 +291,7 @@ public class Foo { language="apex" since="6.0.0" message="Avoid empty 'while' statements" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#emptywhilestmt"> Empty While Statement finds all instances where a while statement does nothing. @@ -445,7 +445,7 @@ public class Foo { // perfect, both methods provided language="apex" since="6.22.0" message="Test methods must be in test classes" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#testmethodsmustbeintestclasses"> Test methods marked as a testMethod or annotated with @IsTest, diff --git a/pmd-apex/src/main/resources/category/apex/performance.xml b/pmd-apex/src/main/resources/category/apex/performance.xml index 8f4e17523b..2fd4ed9f04 100644 --- a/pmd-apex/src/main/resources/category/apex/performance.xml +++ b/pmd-apex/src/main/resources/category/apex/performance.xml @@ -13,7 +13,7 @@ Rules that flag suboptimal code. language="apex" since="6.36.0" message="Avoid debug statements since they impact on performance" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_performance.html#avoiddebugstatements"> Debug statements contribute to longer transactions and consume Apex CPU time even when debug logs are not being captured. @@ -141,7 +141,7 @@ public class Something { language="apex" since="6.40.0" message="DescribeSObjectResult could be being loaded eagerly with all child relationships." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_performance.html#eagerlyloadeddescribesobjectresult"> This rule finds `DescribeSObjectResult`s which could have been loaded eagerly via `SObjectType.getDescribe()`. diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java index 09346eb0f7..6301981422 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.lang.apex.ast.ApexParserTestBase; import net.sourceforge.pmd.lang.document.FileId; -import net.sourceforge.pmd.lang.rule.XPathRule; +import net.sourceforge.pmd.lang.rule.xpath.XPathRule; /** * @author daniels diff --git a/pmd-cli/src/test/resources/net/sourceforge/pmd/cli/RuleSetWithViolations.xml b/pmd-cli/src/test/resources/net/sourceforge/pmd/cli/RuleSetWithViolations.xml index de1fa0063e..8049a8b63b 100644 --- a/pmd-cli/src/test/resources/net/sourceforge/pmd/cli/RuleSetWithViolations.xml +++ b/pmd-cli/src/test/resources/net/sourceforge/pmd/cli/RuleSetWithViolations.xml @@ -7,7 +7,7 @@ Just for test 3 diff --git a/pmd-compat6/src/it/pmd-for-java/exception_ruleset.xml b/pmd-compat6/src/it/pmd-for-java/exception_ruleset.xml index 7f9604ffa3..bd7427e5a8 100644 --- a/pmd-compat6/src/it/pmd-for-java/exception_ruleset.xml +++ b/pmd-compat6/src/it/pmd-for-java/exception_ruleset.xml @@ -2,7 +2,7 @@ + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"> Use this rule to produce a processing error. 3 diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java index 8d7e370a4d..ed5daaeb52 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java @@ -27,7 +27,7 @@ import net.sourceforge.pmd.lang.LanguageVersion; 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.lang.rule.xpath.XPathRule; /** * This class represents a collection of rules along with some optional filter diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java similarity index 97% rename from pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java rename to pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java index e5cc2ea252..9910d67182 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.lang.rule; +package net.sourceforge.pmd.lang.rule.xpath; import java.util.Collections; import java.util.HashMap; @@ -21,8 +21,8 @@ import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.annotation.DeprecatedUntil700; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.ast.Node; -import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException; -import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; +import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.lang.rule.RuleTargetSelector; import net.sourceforge.pmd.lang.rule.xpath.internal.DeprecatedAttrLogger; import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery; import net.sourceforge.pmd.properties.PropertyDescriptor; @@ -36,8 +36,6 @@ public final class XPathRule extends AbstractRule { private static final Logger LOG = LoggerFactory.getLogger(XPathRule.class); - // TODO move to XPath subpackage - /** * @deprecated Use {@link #XPathRule(XPathVersion, String)} */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java index 5b0a6c3dc8..ede186be56 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java @@ -11,8 +11,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.Attribute; +import net.sourceforge.pmd.lang.rule.xpath.XPathRule; /** * Records usages of deprecated attributes in XPath rules. This needs diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java index 70ec7b7e59..4995b4ee95 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java @@ -17,9 +17,9 @@ import org.slf4j.LoggerFactory; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; -import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase; +import net.sourceforge.pmd.lang.rule.xpath.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathHandler; import net.sourceforge.pmd.properties.PropertyDescriptor; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java index 541f88b477..6ae097eb82 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java @@ -241,7 +241,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { "\n" + "\n" + " ruleset desc\n" + " " - + " " + + " " + " d\n" + " 2\n" + " " + ""); assertEquals(1, rs.getRules().size()); @@ -269,7 +269,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { "\n" + "\n" + " ruleset desc\n" + " " - + " " + + " " + " d\n" + " 2\n" + " " diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetWriterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetWriterTest.java index b762837b10..6bdc3ae828 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetWriterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetWriterTest.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.RuleSet.RuleSetBuilder; import net.sourceforge.pmd.lang.rule.RuleReference; -import net.sourceforge.pmd.lang.rule.XPathRule; +import net.sourceforge.pmd.lang.rule.xpath.XPathRule; import net.sourceforge.pmd.util.internal.xml.SchemaConstants; /** diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java index ccbb20cdb2..6ae7dc0db3 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java @@ -20,6 +20,7 @@ import net.sourceforge.pmd.lang.ast.DummyNode; import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; import net.sourceforge.pmd.lang.ast.DummyNodeWithDeprecatedAttribute; import net.sourceforge.pmd.lang.document.TextRegion; +import net.sourceforge.pmd.lang.rule.xpath.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java index 0a0b87b385..5bcf01dcbd 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; -import net.sourceforge.pmd.lang.rule.XPathRule; +import net.sourceforge.pmd.lang.rule.xpath.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; class CodeClimateRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/TestRuleset1.xml b/pmd-core/src/test/resources/net/sourceforge/pmd/TestRuleset1.xml index 8055258242..4bb2ee3a07 100644 --- a/pmd-core/src/test/resources/net/sourceforge/pmd/TestRuleset1.xml +++ b/pmd-core/src/test/resources/net/sourceforge/pmd/TestRuleset1.xml @@ -33,7 +33,7 @@ Just for test Just for test diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/xml/j2ee.xml b/pmd-core/src/test/resources/net/sourceforge/pmd/xml/j2ee.xml index 17443c62ab..af716d45fb 100644 --- a/pmd-core/src/test/resources/net/sourceforge/pmd/xml/j2ee.xml +++ b/pmd-core/src/test/resources/net/sourceforge/pmd/xml/j2ee.xml @@ -13,7 +13,7 @@ language="java" since="3.7" message="In J2EE, getClassLoader() might not work as expected. Use Thread.currentThread().getContextClassLoader() instead." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/rules/j2ee.html#UseProperClassLoader"> In J2EE getClassLoader() might not work as expected. Use Thread.currentThread().getContextClassLoader() instead. @@ -42,7 +42,7 @@ public class Foo { name="MDBAndSessionBeanNamingConvention" language="java" since="4.0" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" message="SessionBean or MessageBean should be suffixed by Bean" externalInfoUrl="${pmd.website.baseurl}/rules/j2ee.html#MDBAndSessionBeanNamingConvention"> @@ -87,7 +87,7 @@ public class Foo { name="RemoteSessionInterfaceNamingConvention" language="java" since="4.0" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" message="Remote Home interface of a Session EJB should be suffixed by 'Home'" externalInfoUrl="${pmd.website.baseurl}/rules/j2ee.html#RemoteSessionInterfaceNamingConvention"> @@ -132,7 +132,7 @@ public class Foo { name="LocalInterfaceSessionNamingConvention" language="java" since="4.0" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" message="The Local Interface of a Session EJB should be suffixed by 'Local'" externalInfoUrl="${pmd.website.baseurl}/rules/j2ee.html#LocalInterfaceSessionNamingConvention"> @@ -177,7 +177,7 @@ public class Foo { name="LocalHomeNamingConvention" language="java" since="4.0" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" message="The Local Home interface of a Session EJB should be suffixed by 'LocalHome'" externalInfoUrl="${pmd.website.baseurl}/rules/j2ee.html#LocalHomeNamingConvention"> @@ -222,7 +222,7 @@ public class Foo { name="RemoteInterfaceNamingConvention" language="java" since="4.0" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" message="Remote Interface of a Session EJB should NOT be suffixed" externalInfoUrl="${pmd.website.baseurl}/rules/j2ee.html#RemoteInterfaceNamingConvention"> @@ -276,7 +276,7 @@ public class Foo { language="java" since="4.1" message="System.exit() should not be used in J2EE/JEE apps" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/rules/j2ee.html#DoNotCallSystemExit"> According to the J2EE specification (p.494), an EJB should not have any static fields @@ -353,7 +353,7 @@ public class SomeEJB extends EJBObject implements EJBLocalHome { name="DoNotUseThreads" language="java" since="4.1" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" message="To be compliant to J2EE, a webapp should not use any thread." externalInfoUrl="${pmd.website.baseurl}/rules/j2ee.html#NoThreadInJ2EEContainer"> diff --git a/pmd-core/src/test/resources/rulesets/dummy/basic.xml b/pmd-core/src/test/resources/rulesets/dummy/basic.xml index bc9c94cc4a..bed1c55b28 100644 --- a/pmd-core/src/test/resources/rulesets/dummy/basic.xml +++ b/pmd-core/src/test/resources/rulesets/dummy/basic.xml @@ -23,7 +23,7 @@ Just for test - Test 3 @@ -38,7 +38,7 @@ Just for test - Test Deprecated rule 3 diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java index 8858ba9a69..5f69327654 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java @@ -40,7 +40,7 @@ import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.rule.RuleReference; -import net.sourceforge.pmd.lang.rule.XPathRule; +import net.sourceforge.pmd.lang.rule.xpath.XPathRule; import net.sourceforge.pmd.properties.PropertyDescriptor; public class RuleDocGenerator { diff --git a/pmd-doc/src/test/resources/rulesets/ruledoctest/sample.xml b/pmd-doc/src/test/resources/rulesets/ruledoctest/sample.xml index c6c78e76a8..08d13c7522 100644 --- a/pmd-doc/src/test/resources/rulesets/ruledoctest/sample.xml +++ b/pmd-doc/src/test/resources/rulesets/ruledoctest/sample.xml @@ -16,7 +16,7 @@ Here might be <script>alert('XSS');</script> as well. And "quotes". language="java" since="0.1" message="Tests that <script>alert('XSS');</script> is properly escaped" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_sample.html#xssindocumentation"> <script>alert('XSS at the beginning');</script> HTML tags might appear at various places. @@ -140,7 +140,7 @@ public class Foo { language="java" since="1.0" message="Avoid modifying an outer loop incrementer in an inner loop for update expression" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_sample.html#jumbledincrementer"> Avoid jumbled loop incrementers - its usually a mistake, and is confusing even if intentional. @@ -190,7 +190,7 @@ public class JumbledIncrementerRule1 { language="java" since="1.0" message="Sample rule, which is deprecated" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_sample.html#deprecatedsample" deprecated="true"> diff --git a/pmd-doc/src/test/resources/rulesets/ruledoctest/sample2.xml b/pmd-doc/src/test/resources/rulesets/ruledoctest/sample2.xml index a91a7e6b1f..d8563b3439 100644 --- a/pmd-doc/src/test/resources/rulesets/ruledoctest/sample2.xml +++ b/pmd-doc/src/test/resources/rulesets/ruledoctest/sample2.xml @@ -12,7 +12,7 @@ Sample ruleset to test rule doc generation. language="java" since="1.0" message="Avoid modifying an outer loop incrementer in an inner loop for update expression" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_sample.html#jumbledincrementer"> Avoid jumbled loop incrementers - its usually a mistake, and is confusing even if intentional. diff --git a/pmd-html/src/main/resources/category/html/bestpractices.xml b/pmd-html/src/main/resources/category/html/bestpractices.xml index 775e366565..925d5e4dd0 100644 --- a/pmd-html/src/main/resources/category/html/bestpractices.xml +++ b/pmd-html/src/main/resources/category/html/bestpractices.xml @@ -13,7 +13,7 @@ Rules which enforce generally accepted best practices. language="html" since="6.45.0" message="Avoid inline styles" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_html_bestpractices.html#avoidinlinestyles"> Don't mix content and style. Use separate CSS-files for the style and introduce classes. diff --git a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlXPathRuleTest.java b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlXPathRuleTest.java index 22cd8549af..84a3e6cebf 100644 --- a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlXPathRuleTest.java +++ b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/HtmlXPathRuleTest.java @@ -16,7 +16,7 @@ import net.sourceforge.pmd.lang.html.ast.ASTHtmlComment; import net.sourceforge.pmd.lang.html.ast.ASTHtmlDocument; import net.sourceforge.pmd.lang.html.ast.ASTHtmlTextNode; import net.sourceforge.pmd.lang.html.ast.HtmlParsingHelper; -import net.sourceforge.pmd.lang.rule.XPathRule; +import net.sourceforge.pmd.lang.rule.xpath.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; class HtmlXPathRuleTest { diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index 7843f7d1fa..77527d636f 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -133,7 +133,7 @@ public class Foo { language="java" since="6.18.0" message="You shouldn't declare field of MessageDigest type, because unsynchronized access could cause problems" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidmessagedigestfield"> Declaring a MessageDigest instance as a field make this instance directly available to multiple threads. @@ -183,7 +183,7 @@ public class AvoidMessageDigestFieldExample { language="java" since="3.2" message="Avoid printStackTrace(); use a logger call instead." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidprintstacktrace"> Avoid printStackTrace(); use a logger call instead. @@ -336,7 +336,7 @@ public class Hello { language="java" since="4.2" message="StringBuffers can grow quite a lot, and so may become a source of memory leak (if the owning class has a long life time)." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidstringbufferfield"> StringBuffers/StringBuilders can grow considerably, and so may become a source of memory leaks @@ -414,7 +414,7 @@ if (rst.next()) { // result is properly examined and used language="java" since="5.5" message="Using constants in interfaces is a bad practice." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#constantsininterface"> Using constants in interfaces is a bad practice. Interfaces define types, constants are implementation details better placed in classes or enums. If the constants are best viewed as members of an enumerated type, you should export them with an enum type. @@ -461,7 +461,7 @@ public interface YetAnotherConstantInterface { language="java" since="1.5" message="The default label should be the last label in a switch statement" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitchstmt"> By convention, the default label should be the last label in a switch statement. @@ -498,7 +498,7 @@ public class Foo { language="java" since="6.16.0" message="Double-brace initialization should be avoided" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#doublebraceinitialization"> Double brace initialisation is a pattern to initialise eg collections concisely. But it implicitly @@ -572,7 +572,7 @@ public class MyClass { language="java" since="6.11.0" message="Too many control variables in the 'for' statement" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#forloopvariablecount"> Having a lot of control variables in a 'for' loop makes it harder to see what range of values @@ -632,7 +632,7 @@ log.debug("log something expensive: {}", () -> calculateExpensiveLoggingText()); language="java" since="4.0" message="JUnit 4 indicates test suites via annotations, not the suite method." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit4suitesshouldusesuiteannotation"> In JUnit 3, test suites are indicated by the suite() method. In JUnit 4, suites are indicated @@ -670,7 +670,7 @@ public class GoodTest { language="java" since="4.0" message="JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit4testshoulduseafterannotation"> In JUnit 3, the tearDown method was used to clean up all data entities required in running tests. @@ -714,7 +714,7 @@ public class MyTest2 { language="java" since="4.0" message="JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit4testshouldusebeforeannotation"> In JUnit 3, the setUp method was used to set up all data entities required in running tests. @@ -759,7 +759,7 @@ public class MyTest2 { language="java" since="4.0" message="Unit tests that execute tests should use the @Test annotation. In case of JUnit 5, test methods might use @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest annotations instead." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit4testshouldusetestannotation"> In JUnit 3, the framework executed all methods which started with the word test as a unit test. @@ -813,7 +813,7 @@ public class MyTest { language="java" since="6.35.0" message="JUnit 5 tests should be package-private." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit5testshouldbepackageprivate"> @@ -1242,7 +1242,7 @@ public class Foo { language="java" since="3.4" message="Consider replacing this Enumeration with the newer java.util.Iterator" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#replaceenumerationwithiterator"> Consider replacing Enumeration usages with the newer java.util.Iterator @@ -1276,7 +1276,7 @@ public class Foo implements Enumeration { language="java" since="3.4" message="Consider replacing this Hashtable with the newer java.util.Map" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#replacehashtablewithmap"> Consider replacing Hashtable usage with the newer java.util.Map if thread safety is not required. @@ -1304,7 +1304,7 @@ public class Foo { language="java" since="3.4" message="Consider replacing this Vector with the newer java.util.List" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#replacevectorwithlist"> Consider replacing Vector usages with the newer java.util.ArrayList if expensive thread-safe operations are not required. @@ -1370,7 +1370,7 @@ class SomeTestClass { language="java" since="1.0" message="Switch statements should be exhaustive, add a default case (or missing enum branches)" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#switchstmtsshouldhavedefault"> Switch statements should be exhaustive, to make their control flow @@ -1404,7 +1404,7 @@ class Foo {{ language="java" since="2.1" message="Usage of System.out/err" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#systemprintln"> References to System.(out|err).print are usually intended for debugging purposes and can remain in @@ -1697,7 +1697,7 @@ public class Foo { since="6.34.0" minimumLanguageVersion="1.7" message="Please use StandardCharsets constants" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#usestandardcharsets"> Starting with Java 7, StandardCharsets provides constants for common Charset objects, such as UTF-8. @@ -1786,7 +1786,7 @@ public class TryWithResources { minimumLanguageVersion="1.5" since="5.0" message="Consider using varargs for methods or constructors which take an array the last parameter." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#usevarargs"> Java 5 introduced the varargs parameter declaration for methods and constructors. This syntactic @@ -1825,7 +1825,7 @@ public class Foo { Avoid using dollar signs in variable/method/class/interface names. @@ -70,7 +70,7 @@ public class Fo$o { // not a recommended name language="java" since="2.1" message="Avoid protected fields in a final class. Change to private or package access." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#avoidprotectedfieldinfinalclass"> Do not use protected fields in final classes since they cannot be subclassed. @@ -103,7 +103,7 @@ public final class Bar { language="java" since="5.1" message="Avoid protected methods in a final class that doesn't extend anything other than Object. Change to private or package access." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#avoidprotectedmethodinfinalclassnotextending"> Do not use protected methods in most final classes since they cannot be subclassed. This should @@ -136,7 +136,7 @@ public final class Foo { language="java" since="4.1" message="The use of native code is not recommended." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#avoidusingnativecode"> Unnecessary reliance on Java Native Interface (JNI) calls directly reduces application portability @@ -173,7 +173,7 @@ public class SomeJNIClass { language="java" since="4.0" message="A 'getX()' method which returns a boolean should be named 'isX()'" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#booleangetmethodname"> Methods that return boolean results should be named as predicate statements to denote this. @@ -207,7 +207,7 @@ public boolean getFoo(boolean bar); // ok, unless checkParameterizedMethods=true language="java" since="3.0" message="It is a good practice to call super() in a constructor" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#callsuperinconstructor"> It is a good practice to call super() in a constructor. If super() is not called but @@ -357,7 +357,7 @@ boolean bar(int x, int y) { language="java" since="6.2.0" message="This statement should have braces" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#controlstatementbraces"> Enforce a policy for braces on control statements. It is recommended to use braces on 'if ... else' @@ -419,7 +419,7 @@ while (true) { // preferred approach @@ -509,7 +509,7 @@ class Foo { language="java" since="5.0" message="No need to explicitly extend Object." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#extendsobject"> No need to explicitly extend Object. 4 @@ -600,7 +600,7 @@ public class HelloWorldBean { language="java" since="6.42.0" message="Final parameter in abstract method" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" typeResolution="true" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#finalparameterinabstractmethod"> @@ -632,7 +632,7 @@ public interface MyInterface { language="java" since="1.02" message="This for loop could be simplified to a while loop" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#forloopshouldbewhileloop"> Some for loops can be simplified to while loops, this makes them more concise. @@ -702,7 +702,7 @@ public class Foo { language="java" since="4.2.6" message="Generics names should be a one letter long and upper case." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#genericsnaming"> Names for references to generic values should be limited to a single uppercase letter. @@ -841,7 +841,7 @@ public class LinguisticNaming { @@ -873,7 +873,7 @@ public interface MissingProperSuffix extends javax.ejb.EJBLocalHome {} // non-s @@ -964,7 +964,7 @@ public class Bar { language="java" since="0.3" message="Avoid excessively long variable names like {0}" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#longvariable"> Fields, formal arguments, or local variable names that are too long can make the code difficult to follow. @@ -998,7 +998,7 @@ public class Something { @@ -1080,7 +1080,7 @@ public class Foo { language="java" since="3.3" message="All classes, interfaces, enums and annotations must belong to a named package" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#nopackage"> Detects when a class, interface, enum or annotation does not have a package definition. @@ -1105,7 +1105,7 @@ public class ClassInDefaultPackage { since="6.10.0" minimumLanguageVersion="1.7" message="Number {0} should separate every third digit with an underscore" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#useunderscoresinnumericliterals"> Since Java 1.7, numeric literals can use underscores to separate digits. This rule enforces that @@ -1180,7 +1180,7 @@ public class OneReturnOnly1 { language="java" since="3.3" message="Package name contains upper case characters" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#packagecase"> Detects when a package definition contains uppercase characters. @@ -1261,7 +1261,7 @@ public int getLength(String[] strings) { @@ -1298,7 +1298,7 @@ public interface BadSuffixBean extends javax.ejb.EJBObject {} @@ -1331,7 +1331,7 @@ public interface MissingProperSuffix extends javax.ejb.EJBHome {} // non-stand language="java" since="5.0" message="Avoid short class names like {0}" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#shortclassname"> Short Classnames with fewer than e.g. five characters are not recommended. @@ -1359,7 +1359,7 @@ public class Foo { language="java" since="0.3" message="Avoid using short method names" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#shortmethodname"> Method names that are very short are not helpful to the reader. @@ -1389,7 +1389,7 @@ public class ShortMethod { language="java" since="0.3" message="Avoid variables with short names like {0}" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#shortvariable"> Fields, local variables, enum constant names or parameter names that are very short are not helpful to the reader. @@ -1434,7 +1434,7 @@ public class Something { @@ -1471,7 +1471,7 @@ import static Yoko; // Too much ! language="java" since="6.2.0" message="Avoid the use of value in annotations when it's the only element" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#unnecessaryannotationvalueelement"> Avoid the use of value in annotations when it's the only element. @@ -1798,7 +1798,7 @@ public class Foo { language="java" since="6.46.0" message="Unnecessary semicolon" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#unnecessarysemicolon"> Reports unnecessary semicolons (so called "empty statements" and "empty declarations"). @@ -1882,7 +1882,7 @@ was made possible for anonymous class constructors. minimumLanguageVersion="10" since="7.0.0" message="Use Explicit Types" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#useexplicittypes"> Java 10 introduced the `var` keyword. This reduces the amount of code written because java can infer the type @@ -1968,7 +1968,7 @@ public class Foo { language="java" since="5.4.0" message="Useless qualified this usage in the same class." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#uselessqualifiedthis"> Reports qualified this usages in the same class. @@ -2018,7 +2018,7 @@ public class Foo { language="java" since="6.15.0" message="Array initialization can be written shorter" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#useshortarrayinitializer"> @@ -51,7 +51,7 @@ public abstract class Example { since="4.2.6" language="java" message="Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#avoidcatchinggenericexception"> Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block. @@ -122,7 +122,7 @@ public class Foo { language="java" since="3.8" message="A catch statement that catches an exception only to rethrow it should be avoided." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#avoidrethrowingexception"> Catch blocks that merely rethrow a caught exception only add to code size and runtime complexity. @@ -156,7 +156,7 @@ public void bar() { since="4.2.5" language="java" message="A catch statement that catches an exception only to wrap it in a new instance of the same type of exception and throw it should be avoided" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#avoidthrowingnewinstanceofsameexception"> Catch blocks that merely rethrow a caught exception wrapped inside a new instance of the same type only add to @@ -243,7 +243,7 @@ public class Foo { language="java" since="1.8" message="Avoid throwing raw exception types." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#avoidthrowingrawexceptiontypes"> Avoid throwing certain exception types. Rather than throw a raw RuntimeException, Throwable, @@ -283,7 +283,7 @@ public class Foo { since="6.13.0" language="java" message="A method or constructor should not explicitly declare unchecked exceptions in its ''throws'' clause" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#avoiduncheckedexceptionsinsignatures"> Reports unchecked exceptions in the `throws` clause of a method or constructor. @@ -334,7 +334,7 @@ public class Foo { //Should be final language="java" since="3.1" message="This if statement could be combined with its parent" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#collapsibleifstatements"> Errors are system exceptions. Do not extend them. @@ -796,7 +796,7 @@ public class Foo { language="java" since="1.1" message="This final field could be made static" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#finalfieldcouldbestatic"> If a final field is assigned to a compile-time constant, it could be made static, thus saving overhead @@ -1013,7 +1013,7 @@ public class Foo { @@ -1197,7 +1197,7 @@ public void foo() throws Exception { language="java" since="5.4.0" message="This conditional expression can be simplified with || or &&" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#simplifiedternary"> Avoid unnecessary comparisons in boolean expressions, they serve no purpose and impacts readability. @@ -1401,7 +1401,7 @@ public class Foo { language="java" since="3.0" message="Too many fields" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#toomanyfields"> Classes that have too many fields can become unwieldy and could be redesigned to have fewer fields, @@ -1444,7 +1444,7 @@ public class Person { // this is more manageable @@ -1505,7 +1505,7 @@ public Long getId() { language="java" since="4.2.6" message="Rather than using a lot of String arguments, consider using a container object for those values." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#useobjectforclearerapi"> When you write a public method, you should be thinking in terms of an API. If your method is public, it means other class @@ -1573,7 +1573,7 @@ public class MaybeAUtility { language="java" since="6.35.0" message="Do not use non-final non-private static fields" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#mutablestaticstate"> Non-private static fields should be made constants (or immutable references) by diff --git a/pmd-java/src/main/resources/category/java/documentation.xml b/pmd-java/src/main/resources/category/java/documentation.xml index b948fba2ef..8b51388505 100644 --- a/pmd-java/src/main/resources/category/java/documentation.xml +++ b/pmd-java/src/main/resources/category/java/documentation.xml @@ -83,7 +83,7 @@ Determines whether the dimensions of non-header comments found are within the sp language="java" since="3.4" message="Document empty constructor" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_documentation.html#uncommentedemptyconstructor"> Uncommented Empty Constructor finds instances where a constructor does not @@ -123,7 +123,7 @@ public Foo() { language="java" since="3.4" message="Document empty method body" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_documentation.html#uncommentedemptymethodbody"> Uncommented Empty Method Body finds instances where a method body does not contain diff --git a/pmd-java/src/main/resources/category/java/errorprone.xml b/pmd-java/src/main/resources/category/java/errorprone.xml index 2c4d7bf423..d33cd6aba7 100644 --- a/pmd-java/src/main/resources/category/java/errorprone.xml +++ b/pmd-java/src/main/resources/category/java/errorprone.xml @@ -57,7 +57,7 @@ public class StaticField { language="java" since="4.1" message="You should not modify visibility of constructors, methods or fields using setAccessible()" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidaccessibilityalteration"> Methods such as `getDeclaredConstructors()`, `getDeclaredMethods()`, and `getDeclaredFields()` also @@ -135,7 +135,7 @@ public class Violation { maximumLanguageVersion="1.3" since="3.4" message="Avoid using assert as an identifier; it became a reserved word in JDK 1.4" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidassertasidentifier"> Use of the term `assert` will conflict with newer versions of Java since it is a reserved word. @@ -196,7 +196,7 @@ for (int i = 0; i < 10; i++) { language="java" since="3.0" message="Avoid calling finalize() explicitly" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcallingfinalize"> The method Object.finalize() is called by the garbage collector on an object when garbage collection determines @@ -230,7 +230,7 @@ void foo() { language="java" since="1.8" message="Avoid catching NullPointerException; consider removing the cause of the NPE." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingnpe"> Code should never throw NullPointerExceptions under normal circumstances. A catch block may hide the @@ -264,7 +264,7 @@ public class Foo { language="java" since="1.2" message="A catch statement should never catch throwable since it includes errors." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingthrowable"> Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as @@ -295,7 +295,7 @@ public void bar() { language="java" since="3.4" message="Avoid creating BigDecimal with a decimal (float/double) literal. Use a String literal" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoiddecimalliteralsinbigdecimalconstructor"> One might assume that the result of "new BigDecimal(0.1)" is exactly equal to 0.1, but it is actually @@ -357,7 +357,7 @@ private void buz(String x) {} maximumLanguageVersion="1.4" since="3.4" message="Avoid using enum as an identifier; it's a reserved word in JDK 1.5" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidenumasidentifier"> Use of the term `enum` will conflict with newer versions of Java since it is a reserved word. @@ -387,7 +387,7 @@ public class A { language="java" since="3.0" message="Field {0} has the same name as a method" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingmethodname"> It can be confusing to have a field name with the same name as a method. While this is permitted, @@ -422,7 +422,7 @@ public class Foo { language="java" since="3.0" message="It is somewhat confusing to have a field name matching the declaring class name" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingtypename"> It is somewhat confusing to have a field name matching the declaring type name. @@ -455,7 +455,7 @@ public interface Operation { language="java" since="3.0" message="An instanceof check is being performed on the caught exception. Create a separate catch clause for this exception type." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidinstanceofchecksincatchclause"> Each caught exception type should be handled in its own catch clause. @@ -495,7 +495,7 @@ try { // Prefer this: language="java" since="4.2.6" message="Avoid using literals in if statements" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidliteralsinifcondition"> Avoid using hard-coded literals in conditional statements. By declaring them as static variables @@ -576,7 +576,7 @@ public void checkRequests() { since="4.2.6" language="java" message="Avoid statements in a catch block that invoke accessors on the exception without using the information" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidlosingexceptioninformation"> Statements in a catch block that invoke accessors on the exception without using the information @@ -614,7 +614,7 @@ public void bar() { @@ -704,7 +704,7 @@ public String bar(String string) { since="4.2.5" language="java" message="super should be called at the start of the method" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#callsuperfirst"> Super should be called at the start of the method 3 @@ -747,7 +747,7 @@ public class DummyActivity extends Activity { since="4.2.5" language="java" message="super should be called at the end of the method" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#callsuperlast"> Super should be called at the end of the method @@ -822,7 +822,7 @@ public class Foo { language="java" since="3.4" message="This usage of the Collection.toArray() method will throw a ClassCastException." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#classcastexceptionwithtoarray"> When deriving an array of a specific class from your Collection, one should provide an array of @@ -859,7 +859,7 @@ Integer[] b = (Integer [])c.toArray(new Integer[0]); language="java" since="5.4.0" message="clone() method must be public if the class implements Cloneable" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodmustbepublic"> The java manual says "By convention, classes that implement this interface should override @@ -928,7 +928,7 @@ public class MyClass { minimumLanguageVersion="1.5" since="5.4.0" message="The return type of the clone() method must be the class name when implements Cloneable" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodreturntypemustmatchclassname"> If a class implements `Cloneable` the return type of the method `clone()` must be the class name. That way, the caller @@ -1020,7 +1020,7 @@ public class Bar { language="java" since="3.2" message="Use equals() to compare object references." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#compareobjectswithequals"> Use `equals()` to compare object references; avoid comparing them with `==`. @@ -1074,7 +1074,7 @@ class Foo { language="java" since="6.36.0" message="Comparisons with NaN always return false" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#comparisonwithnan"> Calls to `System.gc()`, `Runtime.getRuntime().gc()`, and `System.runFinalization()` are not advised. @@ -1240,7 +1240,7 @@ public class GCCall { language="java" since="6.0.0" message="Exceptions should not extend java.lang.Throwable" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotextendjavalangthrowable"> Extend Exception or RuntimeException instead of Throwable. @@ -1267,7 +1267,7 @@ public class Foo extends Throwable { } since="4.2.6" language="java" message="Do not hardcode /sdcard." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donothardcodesdcard"> Use Environment.getExternalStorageDirectory() instead of "/sdcard" @@ -1295,7 +1295,7 @@ public class MyActivity extends Activity { language="java" since="4.1" message="System.exit() should not be used in J2EE/JEE apps" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotterminatevm"> Web applications should not call `System.exit()`, since only the web container or the @@ -1336,7 +1336,7 @@ public void foo() { language="java" since="4.2" message="A throw statement in a finally block makes the control flow hard to understand." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotthrowexceptioninfinally"> Throwing exceptions within a 'finally' block is confusing since they may mask other exceptions @@ -1371,7 +1371,7 @@ public class Foo { language="java" since="1.5" message="Avoid importing anything from the 'sun.*' packages" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dontimportsun"> Avoid importing anything from the 'sun.*' packages. These packages are not portable @@ -1404,7 +1404,7 @@ public class Foo {} language="java" since="4.3" message="Don't use floating point for loop indices. If you must use floating point, use double." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dontusefloattypeforloopindices"> Don't use floating point for loop indices. If you must use floating point, use double @@ -1442,7 +1442,7 @@ public class Count { language="java" since="0.1" message="Avoid empty catch blocks" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptycatchblock"> Empty Catch Block finds instances where an exception is caught, but nothing is done. @@ -1484,7 +1484,7 @@ public void doSomething() { language="java" since="1.5" message="Avoid empty finalize methods" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyfinalizer"> Empty finalize methods serve no purpose and should be removed. Note that Oracle has declared Object.finalize() as deprecated since JDK 9. @@ -1514,7 +1514,7 @@ public class Foo { language="java" since="0.4" message="Avoid empty finally blocks" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyfinallyblock"> Empty finally blocks serve no purpose and should be removed. @@ -1552,7 +1552,7 @@ public class Foo { language="java" since="0.1" message="Avoid empty 'if' statements" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyifstmt"> Empty If Statement finds instances where a condition is checked but nothing is done about it. @@ -1588,7 +1588,7 @@ public class Foo { language="java" since="5.0" message="Empty initializer was found" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyinitializer"> Empty initializers serve no purpose and should be removed. @@ -1620,7 +1620,7 @@ public class Foo { language="java" since="5.0" message="Avoid empty block statements." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptystatementblock"> Empty block statements serve no purpose and should be removed. @@ -1655,7 +1655,7 @@ public class Foo { since="1.5" deprecated="true" message="An empty statement (semicolon) not part of a loop" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptystatementnotinloop"> An empty statement (or a semicolon by itself) that is not used as the sole body of a 'for' @@ -1699,7 +1699,7 @@ public void doit() { language="java" since="1.0" message="Avoid empty switch statements" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyswitchstatements"> Empty switch statements serve no purpose and should be removed.# @@ -1731,7 +1731,7 @@ public void bar() { language="java" since="1.3" message="Avoid empty synchronized blocks" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptysynchronizedblock"> Empty synchronized blocks serve no purpose and should be removed. @@ -1763,7 +1763,7 @@ public class Foo { language="java" since="0.4" message="Avoid empty try blocks" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptytryblock"> Avoid empty try blocks - what's the point? @@ -1800,7 +1800,7 @@ public class Foo { language="java" since="0.2" message="Avoid empty 'while' statements" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptywhilestmt"> Empty While Statement finds all instances where a while statement does nothing. @@ -1835,7 +1835,7 @@ void bar(int a, int b) { language="java" since="1.9" message="Avoid using equals() to compare against null" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#equalsnull"> Tests for null should not use the equals() method. The '==' operator should be used instead. @@ -1869,7 +1869,7 @@ if (x == null) { // preferred language="java" since="1.5" message="Last statement in finalize method should be a call to super.finalize()" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#finalizedoesnotcallsuperfinalize"> If the finalize() is implemented, its last action should be to call super.finalize. Note that Oracle has declared Object.finalize() as deprecated since JDK 9. @@ -1904,7 +1904,7 @@ protected void finalize() { language="java" since="1.5" message="Finalize should do something besides just calling super.finalize()" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#finalizeonlycallssuperfinalize"> If the finalize() is implemented, it should do something besides just calling super.finalize(). Note that Oracle has declared Object.finalize() as deprecated since JDK 9. @@ -1933,7 +1933,7 @@ protected void finalize() { language="java" since="1.5" message="Finalize methods should not be overloaded" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#finalizeoverloaded"> Methods named finalize() should not have parameters. It is confusing and most likely an attempt to @@ -1966,7 +1966,7 @@ public class Foo { language="java" since="1.1" message="If you override finalize(), make it protected" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#finalizeshouldbeprotected"> When overriding the finalize(), the new method should be set as protected. If made public, @@ -2060,7 +2060,7 @@ public void bar(int status) { language="java" since="2.0" message="Avoid instantiating an object just to call getClass() on it; use the .class public member instead" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#instantiationtogetclass"> Avoid instantiating an object just to call getClass() on it; use the .class public member instead. @@ -2117,7 +2117,7 @@ LOGGER.error("param {}", "arg1", new IllegalStateException("arg")); //The except language="java" since="1.0" message="Avoid modifying an outer loop incrementer in an inner loop for update expression" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#jumbledincrementer"> Avoid jumbled loop incrementers - it's usually a mistake, and is confusing even if intentional. @@ -2202,7 +2202,7 @@ public class Foo extends TestCase { language="java" since="1.5" message="A method should not have the same name as its containing class" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#methodwithsamenameasenclosingclass"> A method should not have the same name as its containing class. @@ -2234,7 +2234,7 @@ public class MyClass { language="java" since="3.5" message="The null check here is misplaced; if the variable ''{0}'' is null there will be a NullPointerException" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#misplacednullcheck"> The null check here is misplaced. If the variable is null a `NullPointerException` will be thrown. @@ -2304,7 +2304,7 @@ public class Foo { language="java" since="3.0" message="Classes implementing Serializable should set a serialVersionUID" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#missingserialversionuid"> Serializable classes should provide a serialVersionUID field. @@ -2339,7 +2339,7 @@ public class Foo implements java.io.Serializable { language="java" since="3.0" message="Class cannot be instantiated and does not provide any static methods or fields" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#missingstaticmethodinnoninstantiatableclass"> A class that has private constructors and does not have any static methods or fields cannot be used. @@ -2415,7 +2415,7 @@ public class Foo { language="java" since="2.0" message="Class contains more than one logger." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#morethanonelogger"> Normally only one logger is used in each class. This rule supports slf4j, log4j, Java Util Logging and @@ -2455,7 +2455,7 @@ public class Foo { language="java" since="1.5" message="A non-case label was present in a switch statement" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#noncaselabelinswitchstatement"> A non-case label (e.g. a named break/continue label) was present in a switch statement. @@ -2531,7 +2531,7 @@ class Buzz implements java.io.Serializable { language="java" since="1.5" message="Non-static initializers are confusing" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#nonstaticinitializer"> A non-static initializer block will be called any time a constructor is invoked (just prior to @@ -2648,7 +2648,7 @@ class Foo{ language="java" since="3.3" message="Logger should be defined private static final and have the correct class" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#properlogger"> A logger should normally be defined private static final and be associated with the correct class. @@ -2703,7 +2703,7 @@ public class Foo { @@ -2753,7 +2753,7 @@ public class Example { language="java" since="1.05" message="Avoid returning from a finally block" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#returnfromfinallyblock"> Avoid returning from a finally block, this can discard exceptions. @@ -2785,7 +2785,7 @@ public class Bar { language="java" since="2.0" message="When instantiating a SimpleDateFormat object, specify a Locale" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#simpledateformatneedslocale"> Be sure to specify a Locale when creating SimpleDateFormat instances to ensure that locale-appropriate @@ -2876,7 +2876,7 @@ class Singleton { language="java" since="4.1" message="EJB's shouldn't have non-final static fields" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#staticejbfieldshouldbefinal"> According to the J2EE specification, an EJB should not have any static fields @@ -2918,7 +2918,7 @@ public class SomeEJB extends EJBObject implements EJBLocalHome { language="java" since="3.9" message="Do not instantiate a StringBuffer or StringBuilder with a char" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#stringbufferinstantiationwithchar"> Individual character values provided as initialization arguments will be converted into integers. @@ -2967,7 +2967,7 @@ StringBuilder sb4 = new StringBuilder("c"); language="java" since="2.0" message="The method name and parameter number are suspiciously close to equals(Object)" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#suspiciousequalsmethodname"> The method name and parameter number are suspiciously close to `Object.equals`, which can denote an @@ -3022,7 +3022,7 @@ public class Foo { language="java" since="1.5" message="The method name and return type are suspiciously close to hashCode()" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#suspicioushashcodemethodname"> The method name and return type are suspiciously close to hashCode(), which may denote an intention @@ -3115,7 +3115,7 @@ public class CarTest { language="java" since="1.5" message="Do not use 'if' statements that are always true or always false" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#unconditionalifstatement"> Do not use "if" statements whose conditionals are always true or always false. @@ -3147,7 +3147,7 @@ public class Foo { language="java" since="3.0" message="assertTrue(true) or similar statements are unnecessary" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#unnecessarybooleanassertion"> A JUnit test assertion with a boolean literal is unnecessary since it always will evaluate to the same thing. @@ -3215,7 +3215,7 @@ boolean answer2 = buz.toUpperCase().equalsIgnoreCase("BAZ"); // another unnec language="java" since="0.1" message="Avoid unnecessary temporaries when converting primitives to Strings" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#unnecessaryconversiontemporary"> Avoid the use temporary objects when converting primitives to Strings. Use the static conversion methods @@ -3256,7 +3256,7 @@ public String convert(int x) { language="java" since="3.5" message="Invoke equals() on the object you''ve already ensured is not null" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#unusednullcheckinequals"> After checking an object reference for null, you should invoke equals() on that object rather than passing @@ -3321,7 +3321,7 @@ public class Test { language="java" since="3.2" message="Use the correct logging statement for logging exceptions" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#usecorrectexceptionlogging"> To make sure the full stacktrace is printed out, use the logging statement with two arguments: a String and a Throwable. @@ -3361,7 +3361,7 @@ public class Main { language="java" since="4.1" message="Use equals() to compare strings instead of ''=='' or ''!=''" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#useequalstocomparestrings"> Using '==' or '!=' to compare strings is only reliable if the interned string (`String#intern()`) @@ -3424,7 +3424,7 @@ class Test { language="java" since="2.0" message="When doing a String.toLowerCase()/toUpperCase() call, use a Locale" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#uselocalewithcaseconversions"> When doing `String::toLowerCase()/toUpperCase()` conversions, use an explicit locale argument to specify the case @@ -3478,7 +3478,7 @@ String z2 = a.toLowerCase(Locale.getDefault()); language="java" since="3.7" message="In J2EE, getClassLoader() might not work as expected. Use Thread.currentThread().getContextClassLoader() instead." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#useproperclassloader"> In J2EE, the getClassLoader() method might not work as expected. Use diff --git a/pmd-java/src/main/resources/category/java/multithreading.xml b/pmd-java/src/main/resources/category/java/multithreading.xml index a2a2dfe05b..ffc652b82e 100644 --- a/pmd-java/src/main/resources/category/java/multithreading.xml +++ b/pmd-java/src/main/resources/category/java/multithreading.xml @@ -13,7 +13,7 @@ Rules that flag issues when dealing with multiple threads of execution. language="java" since="3.0" message="Use block level rather than method level synchronization" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#avoidsynchronizedatmethodlevel"> Method-level synchronization can cause problems when new code is added to the method. @@ -76,7 +76,7 @@ public class Foo { language="java" since="3.6" message="Avoid using java.lang.ThreadGroup; it is not thread safe" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#avoidthreadgroup"> Avoid using java.lang.ThreadGroup; although it is intended to be used in a threaded environment @@ -110,7 +110,7 @@ public class Bar { @@ -137,7 +137,7 @@ public class ThrDeux { @@ -209,7 +209,7 @@ public class UsingExecutors { language="java" since="4.3" message="Don't call Thread.run() explicitly, use Thread.start()" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#dontcallthreadrun"> Explicitly calling Thread.run() method will execute in the caller's thread of control. Instead, call Thread.start() for the intended behavior. @@ -339,7 +339,7 @@ public class Foo { minimumLanguageVersion="1.5" since="4.2.6" message="If you run in Java5 or newer and have concurrent access, you should use the ConcurrentHashMap implementation" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#useconcurrenthashmap"> Since Java5 brought a new implementation of the Map designed for multi-threaded access, you can @@ -374,7 +374,7 @@ public class ConcurrentApp { language="java" since="3.0" message="Call Thread.notifyAll() rather than Thread.notify()" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#usenotifyallinsteadofnotify"> Thread.notify() awakens a thread monitoring the object. If more than one thread is monitoring, then only diff --git a/pmd-java/src/main/resources/category/java/performance.xml b/pmd-java/src/main/resources/category/java/performance.xml index 3e2629e681..5f5eff7937 100644 --- a/pmd-java/src/main/resources/category/java/performance.xml +++ b/pmd-java/src/main/resources/category/java/performance.xml @@ -53,7 +53,7 @@ sb.append('a'); // use this instead language="java" since="3.5" message="Arrays.copyOf or System.arraycopy are more efficient" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#avoidarrayloops"> Instead of manually copying data between two arrays, use the more efficient `Arrays.copyOf` @@ -157,7 +157,7 @@ class Scratch { since="6.25.0" language="java" message="A Calendar is used to get the current time, this is expensive." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" typeResolution="true" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#avoidcalendardatecreation"> @@ -231,7 +231,7 @@ public class DateStuff { message="Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter" language="java" minimumLanguageVersion="1.7" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#avoidfilestream"> The FileInputStream and FileOutputStream classes contains a finalizer method which will cause garbage @@ -487,7 +487,7 @@ good.append("This is a long string, which is pre-sized"); since="1.8" minimumLanguageVersion="1.6" message="This call to Collection.toArray() may be optimizable" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#optimizabletoarraycall"> Calls to a collection's `toArray(E[])` method should specify a target array of zero size. This allows the JVM @@ -584,7 +584,7 @@ private String bar = new String("bar"); // just do a String bar = "bar"; language="java" since="1.0" message="Avoid calling toString() on String objects; this is unnecessary." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#stringtostring"> Avoid calling toString() on objects already known to be string instances; this is unnecessary. @@ -610,7 +610,7 @@ private String baz() { @@ -651,7 +651,7 @@ public class Foo { language="java" since="3.0" message="Use ArrayList instead of Vector" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#usearraylistinsteadofvector"> ArrayList is a much better Collection implementation than Vector if thread-safe operation is not required. @@ -683,7 +683,7 @@ public class SimpleTest extends TestCase { language="java" since="3.5" message="Use asList instead of tight loops" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#usearraysaslist"> @@ -877,7 +877,7 @@ public class Foo { language="java" since="3.4" message="This is an inefficient use of CharSequence.toString; call CharSequence.length instead." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#usestringbufferlength"> Use StringBuffer.length() to determine StringBuffer length rather than using StringBuffer.toString().equals("") diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java index 1b8de97629..82633f988f 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java @@ -20,7 +20,7 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.JavaParsingHelper; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.JavaNode; -import net.sourceforge.pmd.lang.rule.XPathRule; +import net.sourceforge.pmd.lang.rule.xpath.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathHandler; import net.sourceforge.pmd.lang.rule.xpath.internal.DeprecatedAttrLogger; diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java index 037cb92c30..461849b570 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java @@ -20,9 +20,9 @@ import net.sourceforge.pmd.lang.ast.FileAnalysisException; import net.sourceforge.pmd.lang.ast.test.TestUtilsKt; import net.sourceforge.pmd.lang.java.BaseParserTest; import net.sourceforge.pmd.lang.java.JavaLanguageModule; -import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase; +import net.sourceforge.pmd.lang.rule.xpath.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; /** diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/ant/classpathtest/ruleset.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/ant/classpathtest/ruleset.xml index 660898adc4..28f462c5ef 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/ant/classpathtest/ruleset.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/ant/classpathtest/ruleset.xml @@ -12,7 +12,7 @@ The Basic ruleset contains a collection of good practices which should be follow language="java" since="1.0" message="Avoid modifying an outer loop incrementer in an inner loop for update expression" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/rules/java/basic.html#JumbledIncrementer"> Avoid jumbled loop incrementers - its usually a mistake, and is confusing even if intentional. diff --git a/pmd-javascript/src/main/resources/category/ecmascript/bestpractices.xml b/pmd-javascript/src/main/resources/category/ecmascript/bestpractices.xml index 3e476dacdd..24785b07a9 100644 --- a/pmd-javascript/src/main/resources/category/ecmascript/bestpractices.xml +++ b/pmd-javascript/src/main/resources/category/ecmascript/bestpractices.xml @@ -13,7 +13,7 @@ Rules which enforce generally accepted best practices. message="Avoid using with - it's bad news" language="ecmascript" since="5.0.1" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_bestpractices.html#avoidwithstatement"> Avoid using with - it's bad news 1 @@ -72,7 +72,7 @@ function bar() { message="Avoid using global variables" language="ecmascript" since="5.0" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_bestpractices.html#globalvariable"> This rule helps to avoid using accidently global variables by simply missing the "var" declaration. @@ -105,7 +105,7 @@ function(arg) { language="ecmascript" since="5.0" message="The for-in loop variable ''{0}'' should be explicitly scoped with 'var' to avoid pollution." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_bestpractices.html#scopeforinvariable"> A for-in loop in which the variable name is not explicitly scoped to the enclosing scope with the 'var' keyword can @@ -161,7 +161,7 @@ function bar() { message="Always provide a base when using parseInt() functions" language="ecmascript" since="5.0.1" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_bestpractices.html#usebasewithparseint"> This rule checks for usages of parseInt. While the second parameter is optional and usually defaults diff --git a/pmd-javascript/src/main/resources/category/ecmascript/codestyle.xml b/pmd-javascript/src/main/resources/category/ecmascript/codestyle.xml index 42bdcb2d57..82b38cbf08 100644 --- a/pmd-javascript/src/main/resources/category/ecmascript/codestyle.xml +++ b/pmd-javascript/src/main/resources/category/ecmascript/codestyle.xml @@ -14,7 +14,7 @@ Rules which enforce a specific coding style. language="ecmascript" since="5.0" message="Avoid assignments in operands" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_codestyle.html#assignmentinoperand"> Avoid assignments in operands; this can make code more complicated and harder to read. This is sometime @@ -65,7 +65,7 @@ function getX() { language="ecmascript" since="5.0" message="Avoid using 'for' statements without curly braces" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_codestyle.html#forloopsmustusebraces"> Avoid using 'for' statements without using curly braces. @@ -100,7 +100,7 @@ for (var i = 0; i < 42; i++) language="ecmascript" since="5.0" message="Avoid using 'if...else' statements without curly braces" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_codestyle.html#ifelsestmtsmustusebraces"> Avoid using if..else statements without using curly braces. @@ -139,7 +139,7 @@ else language="ecmascript" since="5.0" message="Avoid using if statements without curly braces" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_codestyle.html#ifstmtsmustusebraces"> Avoid using if statements without using curly braces. @@ -172,7 +172,7 @@ if (foo) language="ecmascript" since="5.5.0" message="The else block is unnecessary" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_codestyle.html#noelsereturn"> The else block in a if-else-construct is unnecessary if the `if` block contains a return. @@ -212,7 +212,7 @@ return z; language="ecmascript" since="5.0" message="Unnecessary block." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_codestyle.html#unnecessaryblock"> An unnecessary Block is present. Such Blocks are often used in other languages to @@ -251,7 +251,7 @@ if (bar) { language="ecmascript" since="5.0" message="Unnecessary parentheses." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_codestyle.html#unnecessaryparentheses"> Unnecessary parentheses should be removed. 4 @@ -277,7 +277,7 @@ var z = ((1 + 1)); // Bad language="ecmascript" since="5.0" message="A ''return'', ''break'', ''continue'', or ''throw'' statement should be the last in a block." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_codestyle.html#unreachablecode"> A 'return', 'break', 'continue', or 'throw' statement should be the last in a block. Statements after these @@ -319,7 +319,7 @@ function bar() { language="ecmascript" since="5.0" message="Avoid using 'while' statements without curly braces" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_codestyle.html#whileloopsmustusebraces"> Avoid using 'while' statements without using curly braces. diff --git a/pmd-javascript/src/main/resources/category/ecmascript/errorprone.xml b/pmd-javascript/src/main/resources/category/ecmascript/errorprone.xml index 4eab35baa8..0eb8a13656 100644 --- a/pmd-javascript/src/main/resources/category/ecmascript/errorprone.xml +++ b/pmd-javascript/src/main/resources/category/ecmascript/errorprone.xml @@ -13,7 +13,7 @@ Rules to detect constructs that are either broken, extremely confusing or prone message="Avoid trailing commas in object or array literals" language="ecmascript" since="5.1" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_errorprone.html#avoidtrailingcomma"> This rule helps improve code portability due to differences in browser treatment of trailing commas in object or array literals. @@ -49,7 +49,7 @@ function(arg) { language="ecmascript" since="5.0" message="Use '==='/'!==' to compare with true/false or Numbers" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_errorprone.html#equalcomparison"> Using == in condition may lead to unexpected results, as the variables are automatically casted to be of the @@ -95,7 +95,7 @@ if (someVar != 3) { language="ecmascript" since="5.0" message="The numeric literal ''{0}'' will have at different value at runtime." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_errorprone.html#innaccuratenumericliteral"> The numeric literal will have a different value at runtime, which can happen if you provide too much diff --git a/pmd-jsp/src/main/resources/category/jsp/bestpractices.xml b/pmd-jsp/src/main/resources/category/jsp/bestpractices.xml index 986833ca55..bac992c27f 100644 --- a/pmd-jsp/src/main/resources/category/jsp/bestpractices.xml +++ b/pmd-jsp/src/main/resources/category/jsp/bestpractices.xml @@ -13,7 +13,7 @@ Rules which enforce generally accepted best practices. language="jsp" since="3.6" message="Do not nest JSF component custom actions inside a custom action that iterates over its body." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_jsp_bestpractices.html#dontnestjsfinjstliteration"> Do not nest JSF component custom actions inside a custom action that iterates over its body. @@ -47,7 +47,7 @@ Do not nest JSF component custom actions inside a custom action that iterates ov language="jsp" since="3.6" message="Do not use an attribute called 'class'." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_jsp_bestpractices.html#noclassattribute"> Do not use an attribute called 'class'. Use "styleclass" for CSS styles. @@ -75,7 +75,7 @@ Do not use an attribute called 'class'. Use "styleclass" for CSS styles. language="jsp" since="3.6" message="Use JSP comments instead of HTML comments" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_jsp_bestpractices.html#nohtmlcomments"> In a production system, HTML comments increase the payload @@ -109,7 +109,7 @@ little other purpose. Consider switching to JSP comments. language="jsp" since="3.6" message="Do not do a forward from within a JSP file." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_jsp_bestpractices.html#nojspforward"> Do not do a forward from within a JSP file. diff --git a/pmd-jsp/src/main/resources/category/jsp/design.xml b/pmd-jsp/src/main/resources/category/jsp/design.xml index 2d23cbc41a..3e7f60add5 100644 --- a/pmd-jsp/src/main/resources/category/jsp/design.xml +++ b/pmd-jsp/src/main/resources/category/jsp/design.xml @@ -12,7 +12,7 @@ Rules that help you discover design issues. @@ -53,7 +53,7 @@ tags, or attributes like "align='center'". language="jsp" since="3.6" message="Avoid having long scripts (e.g. Javascript) inside a JSP file." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_jsp_design.html#nolongscripts"> Scripts should be part of Tag Libraries, rather than part of JSP pages. @@ -99,7 +99,7 @@ onload=calcDays; language="jsp" since="3.6" message="Avoid having scriptlets inside a JSP file." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_jsp_design.html#noscriptlets"> Scriptlets should be factored into Tag Libraries or JSP declarations, rather than being part of JSP pages. diff --git a/pmd-jsp/src/main/resources/category/jsp/errorprone.xml b/pmd-jsp/src/main/resources/category/jsp/errorprone.xml index 635dec3a6a..1d836d565a 100644 --- a/pmd-jsp/src/main/resources/category/jsp/errorprone.xml +++ b/pmd-jsp/src/main/resources/category/jsp/errorprone.xml @@ -12,7 +12,7 @@ Rules to detect constructs that are either broken, extremely confusing or prone diff --git a/pmd-jsp/src/main/resources/category/jsp/security.xml b/pmd-jsp/src/main/resources/category/jsp/security.xml index 4a29b0fba4..c335fe7f93 100644 --- a/pmd-jsp/src/main/resources/category/jsp/security.xml +++ b/pmd-jsp/src/main/resources/category/jsp/security.xml @@ -13,7 +13,7 @@ Rules that flag potential security flaws. language="jsp" since="3.6" message="IFrames must have a src attribute." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_jsp_security.html#iframemissingsrcattribute"> IFrames which are missing a src element can cause security information popups in IE if you are accessing the page diff --git a/pmd-kotlin/src/main/resources/category/kotlin/bestpractices.xml b/pmd-kotlin/src/main/resources/category/kotlin/bestpractices.xml index a28c34e39a..488e7778ce 100644 --- a/pmd-kotlin/src/main/resources/category/kotlin/bestpractices.xml +++ b/pmd-kotlin/src/main/resources/category/kotlin/bestpractices.xml @@ -13,7 +13,7 @@ Rules which enforce generally accepted best practices. since="7.0.0" language="kotlin" message="Function names should have non-cryptic and clear names." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_kotlin_bestpractices.html#functionnametooshort"> Function names should be easy to understand and describe the intention. Makes developers happy. diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt index 46c3d9b272..af9cc7f30f 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt @@ -13,7 +13,7 @@ import net.sourceforge.pmd.lang.ast.RootNode 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.lang.rule.XPathRule +import net.sourceforge.pmd.lang.rule.xpath.XPathRule import net.sourceforge.pmd.lang.rule.xpath.XPathVersion import net.sourceforge.pmd.reporting.GlobalAnalysisListener import java.io.InputStream diff --git a/pmd-modelica/src/main/resources/category/modelica/bestpractices.xml b/pmd-modelica/src/main/resources/category/modelica/bestpractices.xml index 95453f30e6..a6fd8e05b0 100644 --- a/pmd-modelica/src/main/resources/category/modelica/bestpractices.xml +++ b/pmd-modelica/src/main/resources/category/modelica/bestpractices.xml @@ -13,7 +13,7 @@ Rules which enforce generally accepted best practices. since="6.21.0" message="Class ends with an end clause with a different name" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_modelica_bestpractices.html#classstartnameequalsendname" - class="net.sourceforge.pmd.lang.rule.XPathRule"> + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"> Having a class starting with some name and some *different* name in its end clause is an error. diff --git a/pmd-plsql/src/main/resources/category/plsql/bestpractices.xml b/pmd-plsql/src/main/resources/category/plsql/bestpractices.xml index 1af8bcde7b..d859856eac 100644 --- a/pmd-plsql/src/main/resources/category/plsql/bestpractices.xml +++ b/pmd-plsql/src/main/resources/category/plsql/bestpractices.xml @@ -14,7 +14,7 @@ Rules which enforce generally accepted best practices. language="plsql" since="5.1" message="WHEN OTHERS THEN NULL - when you do this, Tom Kyte cries" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_bestpractices.html#tomkytesdespair"> "WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR diff --git a/pmd-plsql/src/main/resources/category/plsql/codestyle.xml b/pmd-plsql/src/main/resources/category/plsql/codestyle.xml index 113f0c71e7..386f4cdf4f 100644 --- a/pmd-plsql/src/main/resources/category/plsql/codestyle.xml +++ b/pmd-plsql/src/main/resources/category/plsql/codestyle.xml @@ -96,7 +96,7 @@ END; language="plsql" since="5.5.2" message="Pragma should be used only inside the declaration block before 'BEGIN'." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_codestyle.html#misplacedpragma"> Oracle states that the PRAQMA AUTONOMOUS_TRANSACTION must be in the declaration block, @@ -139,7 +139,7 @@ end inline_pragma_error; language="plsql" since="6.7.0" message="Use meaningful names for loop variables" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_codestyle.html#forloopnaming"> In case you have loops please name the loop variables more meaningful. diff --git a/pmd-plsql/src/main/resources/category/plsql/design.xml b/pmd-plsql/src/main/resources/category/plsql/design.xml index 2e27b89f79..f11ccc7fbf 100644 --- a/pmd-plsql/src/main/resources/category/plsql/design.xml +++ b/pmd-plsql/src/main/resources/category/plsql/design.xml @@ -489,7 +489,7 @@ END pkg_too_many_fields; diff --git a/pmd-plsql/src/main/resources/category/plsql/errorprone.xml b/pmd-plsql/src/main/resources/category/plsql/errorprone.xml index 72f00e6bb8..af87467a67 100644 --- a/pmd-plsql/src/main/resources/category/plsql/errorprone.xml +++ b/pmd-plsql/src/main/resources/category/plsql/errorprone.xml @@ -13,7 +13,7 @@ Rules to detect constructs that are either broken, extremely confusing or prone language="plsql" since="5.1" message="TO_DATE(TO_CHAR(variable)) instead of TRUNC(variable)" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_errorprone.html#to_date_to_char"> TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-variable) @@ -53,7 +53,7 @@ END date_utilities; language="plsql" since="5.1" message="TO_DATE without date format" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_errorprone.html#to_datewithoutdateformat"> TO_DATE without date format- use TO_DATE(expression, date-format) @@ -104,7 +104,7 @@ END date_utilities; diff --git a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/PLSQLXPathRuleTest.java b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/PLSQLXPathRuleTest.java index 09f9013008..7a6448ccc9 100644 --- a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/PLSQLXPathRuleTest.java +++ b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/PLSQLXPathRuleTest.java @@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.lang.rule.XPathRule; +import net.sourceforge.pmd.lang.rule.xpath.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; /** diff --git a/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/XPathRuleTest.java b/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/XPathRuleTest.java index 303040dc59..9294fa105c 100644 --- a/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/XPathRuleTest.java +++ b/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/XPathRuleTest.java @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.RuleViolation; -import net.sourceforge.pmd.lang.rule.XPathRule; +import net.sourceforge.pmd.lang.rule.xpath.XPathRule; import net.sourceforge.pmd.lang.scala.ast.BaseScalaTest; class XPathRuleTest extends BaseScalaTest { diff --git a/pmd-swift/src/main/resources/category/swift/bestpractices.xml b/pmd-swift/src/main/resources/category/swift/bestpractices.xml index e1d9ad423e..b34f346cbe 100644 --- a/pmd-swift/src/main/resources/category/swift/bestpractices.xml +++ b/pmd-swift/src/main/resources/category/swift/bestpractices.xml @@ -13,7 +13,7 @@ Rules which enforce generally accepted best practices. since="7.0.0" language="swift" message="Creating views using Interface Builder should be avoided." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_swift_bestpractices.html#prohibitedinterfacebuilder"> Creating views using Interface Builder should be avoided. diff --git a/pmd-swift/src/main/resources/category/swift/errorprone.xml b/pmd-swift/src/main/resources/category/swift/errorprone.xml index 7bf277656b..b771ba9838 100644 --- a/pmd-swift/src/main/resources/category/swift/errorprone.xml +++ b/pmd-swift/src/main/resources/category/swift/errorprone.xml @@ -13,7 +13,7 @@ language="swift" since="7.0.0" message="Force casts should be avoided." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_swift_errorprone.html#forcecast"> Force casts should be avoided. This may lead to a crash if it's not used carefully. @@ -43,7 +43,7 @@ NSNumber() as? Int // no violation language="swift" since="7.0.0" message="Force tries should be avoided." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_swift_errorprone.html#forcetry"> Force tries should be avoided. If the code being wrapped happens to raise and exception, our application will crash. diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java index dd5f81745c..1e2e84755b 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java @@ -46,7 +46,7 @@ import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.rule.RuleReference; -import net.sourceforge.pmd.lang.rule.XPathRule; +import net.sourceforge.pmd.lang.rule.xpath.XPathRule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.util.log.internal.MessageReporterBase; diff --git a/pmd-test/src/main/resources/rulesets/dummy/basic.xml b/pmd-test/src/main/resources/rulesets/dummy/basic.xml index ba7589bf21..97849df3dd 100644 --- a/pmd-test/src/main/resources/rulesets/dummy/basic.xml +++ b/pmd-test/src/main/resources/rulesets/dummy/basic.xml @@ -20,7 +20,7 @@ Just for test - Test 3 diff --git a/pmd-vm/src/main/resources/category/vm/design.xml b/pmd-vm/src/main/resources/category/vm/design.xml index 50e5bae9fe..eaad2f1fe4 100644 --- a/pmd-vm/src/main/resources/category/vm/design.xml +++ b/pmd-vm/src/main/resources/category/vm/design.xml @@ -61,7 +61,7 @@ Avoid inline JavaScript. Import .js files instead. language="vm" since="5.1" message="Avoid inline styles" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_vm_design.html#noinlinestyles"> Avoid inline styles. Use css classes instead. diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/DomXPathRule.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/DomXPathRule.java index ce2df9d9de..759714f13b 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/DomXPathRule.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/DomXPathRule.java @@ -10,7 +10,7 @@ import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; -import net.sourceforge.pmd.lang.rule.XPathRule; +import net.sourceforge.pmd.lang.rule.xpath.XPathRule; import net.sourceforge.pmd.lang.xml.ast.internal.XmlParserImpl.RootXmlNode; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; diff --git a/pmd-xml/src/main/resources/category/pom/errorprone.xml b/pmd-xml/src/main/resources/category/pom/errorprone.xml index f4f3993cde..4f5432e4bd 100644 --- a/pmd-xml/src/main/resources/category/pom/errorprone.xml +++ b/pmd-xml/src/main/resources/category/pom/errorprone.xml @@ -13,7 +13,7 @@ Rules to detect constructs that are either broken, extremely confusing or prone language="pom" since="5.4" message="By default, Maven only recognizes the following types: pom, jar, maven-plugin, ejb, war, ear, rar, par." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_pom_errorprone.html#invaliddependencytypes"> If you use an invalid dependency type in the dependency management section, Maven doesn't fail. Instead, @@ -59,7 +59,7 @@ The following types are considered valid: pom, jar, maven-plugin, ejb, war, ear, language="pom" since="5.4" message="Do not use project.version to express a dependency version." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_pom_errorprone.html#projectversionasdependencyversion"> Using that expression in dependency declarations seems like a shortcut, but it can go wrong. diff --git a/pmd-xml/src/main/resources/category/xml/bestpractices.xml b/pmd-xml/src/main/resources/category/xml/bestpractices.xml index dd25bea6e8..dbcfc183bf 100644 --- a/pmd-xml/src/main/resources/category/xml/bestpractices.xml +++ b/pmd-xml/src/main/resources/category/xml/bestpractices.xml @@ -13,7 +13,7 @@ Rules which enforce generally accepted best practices. language="xml" since="7.0.0" message="Set an explicit XML encoding in the XML declaration to ensure proper parsing" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_xml_bestpractices.html#missingencoding"> When the character encoding is missing from the XML declaration, diff --git a/pmd-xml/src/main/resources/category/xml/errorprone.xml b/pmd-xml/src/main/resources/category/xml/errorprone.xml index c07912ff5b..d6708363f1 100644 --- a/pmd-xml/src/main/resources/category/xml/errorprone.xml +++ b/pmd-xml/src/main/resources/category/xml/errorprone.xml @@ -13,7 +13,7 @@ Rules to detect constructs that are either broken, extremely confusing or prone language="xml" since="5.0" message="Potentially mistyped CDATA section with extra [ at beginning or ] at the end." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_xml_errorprone.html#mistypedcdatasection"> An XML CDATA section begins with a <![CDATA[ marker, which has only one [, and ends with a ]]> marker, which has two ]. diff --git a/pmd-xml/src/main/resources/category/xsl/codestyle.xml b/pmd-xml/src/main/resources/category/xsl/codestyle.xml index 6363dfbf23..d6d09bc5b0 100644 --- a/pmd-xml/src/main/resources/category/xsl/codestyle.xml +++ b/pmd-xml/src/main/resources/category/xsl/codestyle.xml @@ -13,7 +13,7 @@ Rules which enforce a specific coding style. language="xsl" since="5.0" message="The xpath concat() function accepts as many arguments as required, you may be able to factorize this expression" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_xsl_codestyle.html#useconcatonce"> The XPath concat() functions accepts as many arguments as required so you can have diff --git a/pmd-xml/src/main/resources/category/xsl/performance.xml b/pmd-xml/src/main/resources/category/xsl/performance.xml index 0e5201d43d..223b7f8de5 100644 --- a/pmd-xml/src/main/resources/category/xsl/performance.xml +++ b/pmd-xml/src/main/resources/category/xsl/performance.xml @@ -13,7 +13,7 @@ Rules that flag suboptimal code. language="xsl" since="5.0" message="Axis navigation has the largest impact when writing an XPath query." - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_xsl_performance.html#avoidaxisnavigation"> Avoid using the 'following' or 'preceding' axes whenever possible, as these can cut From 049f2c7c596d015e5e496279ae1c43332657eb39 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 20 Jan 2024 17:28:33 +0100 Subject: [PATCH 10/23] [core] XPathRule - remove version property (#4309) --- .../userdocs/extending/defining_properties.md | 1 - .../userdocs/extending/writing_xpath_rules.md | 3 +- docs/pages/pmd/userdocs/migrating_to_pmd7.md | 2 +- docs/pages/release_notes.md | 5 ++ .../resources/category/apex/bestpractices.xml | 1 - .../resources/category/apex/performance.xml | 2 - .../pmd/lang/rule/xpath/XPathRule.java | 46 ++----------------- .../xpath/internal/SaxonXPathRuleQuery.java | 3 +- .../net/sourceforge/pmd/xml/j2ee.xml | 9 ---- .../test/resources/rulesets/dummy/basic.xml | 6 +-- .../pmd/docs/RuleDocGenerator.java | 1 - .../resources/rulesets/ruledoctest/sample.xml | 3 -- .../rulesets/ruledoctest/sample2.xml | 1 - .../resources/category/html/bestpractices.xml | 1 - .../resources/category/java/bestpractices.xml | 2 - .../resources/category/java/codestyle.xml | 3 -- .../main/resources/category/java/design.xml | 1 - .../resources/category/java/errorprone.xml | 5 -- .../resources/category/java/performance.xml | 1 - .../pmd/ant/classpathtest/ruleset.xml | 1 - .../category/kotlin/bestpractices.xml | 1 - .../main/resources/rulesets/dummy/basic.xml | 1 - .../pmd/lang/xml/rule/DomXPathRule.java | 2 - .../resources/category/xml/bestpractices.xml | 1 - 24 files changed, 14 insertions(+), 88 deletions(-) diff --git a/docs/pages/pmd/userdocs/extending/defining_properties.md b/docs/pages/pmd/userdocs/extending/defining_properties.md index 750ed79ebe..a1bef2fe1c 100644 --- a/docs/pages/pmd/userdocs/extending/defining_properties.md +++ b/docs/pages/pmd/userdocs/extending/defining_properties.md @@ -165,7 +165,6 @@ with a backslash when needed. ```xml - diff --git a/docs/pages/pmd/userdocs/extending/writing_xpath_rules.md b/docs/pages/pmd/userdocs/extending/writing_xpath_rules.md index c8bccc167a..3fd5c012e8 100644 --- a/docs/pages/pmd/userdocs/extending/writing_xpath_rules.md +++ b/docs/pages/pmd/userdocs/extending/writing_xpath_rules.md @@ -27,7 +27,8 @@ with opt-in support for XPath 2.0. See [the Saxonica documentation](https://www.saxonica.com/html/documentation/expressions/xpath31new.html) for an introduction to new features in XPath 3.1. -The property `version` of {% jdoc core::lang.rule.XPathRule %} is deprecated and will be removed. +The property `version` of {% jdoc core::lang.rule.XPathRule %} is deprecated and +has been removed with PMD 7. ## DOM representation of ASTs diff --git a/docs/pages/pmd/userdocs/migrating_to_pmd7.md b/docs/pages/pmd/userdocs/migrating_to_pmd7.md index ef04f34a48..8118caa4fa 100644 --- a/docs/pages/pmd/userdocs/migrating_to_pmd7.md +++ b/docs/pages/pmd/userdocs/migrating_to_pmd7.md @@ -93,7 +93,7 @@ XPath 2.0 is available in PMD 6 already and can be used right away. PMD 7 will u won't support XPath 1.0 anymore. The difference between XPath 2.0 and XPath 3.1 is not big, so your XPath 2.0 can be expected to work in PMD 7 without any further changes. So the migration path is to simply migrate to XPath 2.0. -After you have migrated your XPath rules to XPath 2.0, remove the "version" property, since that will be removed +After you have migrated your XPath rules to XPath 2.0, remove the "version" property, since that has been removed with PMD 7. PMD 7 by default uses XPath 3.1. See below [XPath](#xpath-migrating-from-10-to-20) for details. Then change the `class` attribute of your rule to `net.sourceforge.pmd.lang.rule.xpath.XPathRule` - because the diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 814730cb48..4b4f2eb93b 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -152,6 +152,11 @@ in the Migration Guide. #### API Changes +**XPath Rules** +* The property `version` was already deprecated and has finally been removed. Please don't define the version + property anymore in your custom XPath rules. By default, the latest XPath version will be used, which + is XPath 3.1. + **Moved classes/consolidated packages** * pmd-core diff --git a/pmd-apex/src/main/resources/category/apex/bestpractices.xml b/pmd-apex/src/main/resources/category/apex/bestpractices.xml index 637a647543..f2d723cb8c 100644 --- a/pmd-apex/src/main/resources/category/apex/bestpractices.xml +++ b/pmd-apex/src/main/resources/category/apex/bestpractices.xml @@ -116,7 +116,6 @@ annotation for test classes and methods. 3 - 3 - 3 - VERSION_DESCRIPTOR = - PropertyFactory.enumProperty("version", getXPathVersions()) - .desc("XPath specification version") - .defaultValue(XPathVersion.DEFAULT) - .build(); - /** * This is initialized only once when calling {@link #apply(Node, RuleContext)} or {@link #getTargetSelector()}. */ @@ -75,7 +60,6 @@ public final class XPathRule extends AbstractRule { @Deprecated public XPathRule() { definePropertyDescriptor(XPATH_DESCRIPTOR); - definePropertyDescriptor(VERSION_DESCRIPTOR); } /** @@ -93,7 +77,6 @@ public final class XPathRule extends AbstractRule { Objects.requireNonNull(expression, "XPath expression is null"); setProperty(XPathRule.XPATH_DESCRIPTOR, expression); - setProperty(XPathRule.VERSION_DESCRIPTOR, XPathVersion.ofId(version.getXmlName())); } @@ -104,14 +87,6 @@ public final class XPathRule extends AbstractRule { return rule; } - /** - * Returns the version for this rule. Returns null if this is not - * set or invalid. - */ - public XPathVersion getVersion() { - return getProperty(VERSION_DESCRIPTOR); - } - /** * Returns the XPath expression that implements this rule. */ @@ -143,11 +118,7 @@ public final class XPathRule extends AbstractRule { @Override public void initialize(LanguageProcessor languageProcessor) { String xpath = getXPathExpression(); - XPathVersion version = getVersion(); - - if (version == null) { - throw new IllegalStateException("Invalid XPath version, should have been caught by Rule::dysfunctionReason"); - } + XPathVersion version = XPathVersion.DEFAULT; try { xpathRuleQuery = new SaxonXPathRuleQuery(xpath, @@ -181,9 +152,8 @@ public final class XPathRule extends AbstractRule { private void logXPathRuleChainUsage(boolean usesRuleChain) { - LOG.debug("{} rule chain for XPath {} rule: {} ({})", + LOG.debug("{} rule chain for XPath rule: {} ({})", usesRuleChain ? "Using" : "no", - getProperty(XPathRule.VERSION_DESCRIPTOR), getName(), getRuleSetName()); } @@ -191,19 +161,9 @@ public final class XPathRule extends AbstractRule { @Override public String dysfunctionReason() { - if (getVersion() == null) { - return "Invalid XPath version '" + getProperty(VERSION_DESCRIPTOR) + "'"; - } else if (StringUtils.isBlank(getXPathExpression())) { + if (StringUtils.isBlank(getXPathExpression())) { return "Missing XPath expression"; } return null; } - - private static Map getXPathVersions() { - Map tmp = new HashMap<>(); - for (XPathVersion v : XPathVersion.values()) { - tmp.put(v.getXmlName(), v); - } - return Collections.unmodifiableMap(tmp); - } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java index 4995b4ee95..bb14c23b4c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java @@ -19,7 +19,6 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase; -import net.sourceforge.pmd.lang.rule.xpath.XPathRule; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathHandler; import net.sourceforge.pmd.properties.PropertyDescriptor; @@ -194,7 +193,7 @@ public class SaxonXPathRuleQuery { for (final PropertyDescriptor propertyDescriptor : properties.keySet()) { final String name = propertyDescriptor.name(); - if (!"xpath".equals(name) && !XPathRule.VERSION_DESCRIPTOR.name().equals(name)) { + if (!"xpath".equals(name)) { staticCtx.declareProperty(propertyDescriptor); } } diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/xml/j2ee.xml b/pmd-core/src/test/resources/net/sourceforge/pmd/xml/j2ee.xml index af716d45fb..40af25174a 100644 --- a/pmd-core/src/test/resources/net/sourceforge/pmd/xml/j2ee.xml +++ b/pmd-core/src/test/resources/net/sourceforge/pmd/xml/j2ee.xml @@ -20,7 +20,6 @@ 3 - 4 - 4 - 4 - 4 - 4 - 3 - 3 - 3 - Test 3 - - + Test Deprecated rule 3 - - + diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java index 5f69327654..13677e50e7 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java @@ -437,7 +437,6 @@ public class RuleDocGenerator { properties.remove(Rule.VIOLATION_SUPPRESS_REGEX_DESCRIPTOR); properties.remove(Rule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR); properties.remove(XPathRule.XPATH_DESCRIPTOR); - properties.remove(XPathRule.VERSION_DESCRIPTOR); if (!properties.isEmpty()) { lines.add("**This rule has the following properties:**"); diff --git a/pmd-doc/src/test/resources/rulesets/ruledoctest/sample.xml b/pmd-doc/src/test/resources/rulesets/ruledoctest/sample.xml index 08d13c7522..119a865b0d 100644 --- a/pmd-doc/src/test/resources/rulesets/ruledoctest/sample.xml +++ b/pmd-doc/src/test/resources/rulesets/ruledoctest/sample.xml @@ -57,7 +57,6 @@ Here might be <script>alert('XSS');</script> as well. And "quotes". 3 - 3 - 3 - 3 - 3 - 3 - - 1 - 3 - - 3 - 3 - java.lang.Enum,java.lang.Class @@ -1091,7 +1090,6 @@ class Foo { ]]> 3 - 2 - 3 - 1 - 3 - 3 - 3 - 3 - 3 - Date: Sat, 20 Jan 2024 18:20:45 +0100 Subject: [PATCH 11/23] [compat6] Fix SuppressedViolations compatibility --- .../it/pmd-for-java/src/main/java/org/example/Main.java | 2 ++ .../main/java/net/sourceforge/pmd/reporting/Report.java | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pmd-compat6/src/it/pmd-for-java/src/main/java/org/example/Main.java b/pmd-compat6/src/it/pmd-for-java/src/main/java/org/example/Main.java index a1609790b5..8b4ddb6e37 100644 --- a/pmd-compat6/src/it/pmd-for-java/src/main/java/org/example/Main.java +++ b/pmd-compat6/src/it/pmd-for-java/src/main/java/org/example/Main.java @@ -4,5 +4,7 @@ public class Main { public static void main(String[] args) { String thisIsAUnusedLocalVar = "a"; System.out.println("Hello world!"); + + String thisIsASuppressedUnusedLocalVar = "b"; // NOPMD suppressed } } diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/Report.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/Report.java index 5132f8ee29..22d8b59758 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/Report.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/reporting/Report.java @@ -5,7 +5,6 @@ package net.sourceforge.pmd.reporting; import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.document.FileId; public class Report extends net.sourceforge.pmd.Report { @@ -23,8 +22,16 @@ public class Report extends net.sourceforge.pmd.Report { } public static class SuppressedViolation extends net.sourceforge.pmd.Report.SuppressedViolation { + private final RuleViolation rv; + public SuppressedViolation(RuleViolation rv, ViolationSuppressor suppressor, String userMessage) { super(rv, suppressor, userMessage); + this.rv = rv; + } + + @Override + public net.sourceforge.pmd.reporting.RuleViolation getRuleViolation() { + return rv; } } From c800bba7335f62fb5a178c8f66c64e7375312316 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 21 Jan 2024 10:02:19 +0100 Subject: [PATCH 12/23] [compat6] Provide XPathRule under old package --- .../sourceforge/pmd/lang/rule/XPathRule.java | 8 + .../pmd/lang/rule/xpath/XPathRule.java | 172 ++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java create mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java new file mode 100644 index 0000000000..eb11ac7e77 --- /dev/null +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java @@ -0,0 +1,8 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.rule; + +public class XPathRule extends net.sourceforge.pmd.lang.rule.xpath.XPathRule { +} diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java new file mode 100644 index 0000000000..f8ddce578b --- /dev/null +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java @@ -0,0 +1,172 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +// This class has been taken from 7.0.0-SNAPSHOT +// Changes: not final anymore to allow a subclass in the old package + +package net.sourceforge.pmd.lang.rule.xpath; + +import java.util.List; +import java.util.Objects; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.exception.ContextedRuntimeException; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sourceforge.pmd.Rule; +import net.sourceforge.pmd.RuleContext; +import net.sourceforge.pmd.lang.LanguageProcessor; +import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.lang.rule.RuleTargetSelector; +import net.sourceforge.pmd.lang.rule.xpath.internal.DeprecatedAttrLogger; +import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery; +import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.properties.PropertyFactory; + + +/** + * Rule that tries to match an XPath expression against a DOM view of an AST. + */ +public /*final*/ class XPathRule extends AbstractRule { + + private static final Logger LOG = LoggerFactory.getLogger(XPathRule.class); + + /** + * @deprecated Use {@link #XPathRule(XPathVersion, String)} + */ + @Deprecated + public static final PropertyDescriptor XPATH_DESCRIPTOR = + PropertyFactory.stringProperty("xpath") + .desc("XPath expression") + .defaultValue("") + .build(); + + /** + * This is initialized only once when calling {@link #apply(Node, RuleContext)} or {@link #getTargetSelector()}. + */ + private SaxonXPathRuleQuery xpathRuleQuery; + + + // this is shared with rules forked by deepCopy, used by the XPathRuleQuery + private DeprecatedAttrLogger attrLogger = DeprecatedAttrLogger.create(this); + + + /** + * @deprecated This is now only used by the ruleset loader. When + * we have syntactic sugar for XPath rules in the XML, we won't + * need this anymore. + */ + @Deprecated + public XPathRule() { + definePropertyDescriptor(XPATH_DESCRIPTOR); + } + + /** + * Make a new XPath rule with the given version + expression + * + * @param version Version of the XPath language + * @param expression XPath expression + * + * @throws NullPointerException If any of the arguments is null + */ + public XPathRule(XPathVersion version, String expression) { + this(); + + Objects.requireNonNull(version, "XPath version is null"); + Objects.requireNonNull(expression, "XPath expression is null"); + + setProperty(XPathRule.XPATH_DESCRIPTOR, expression); + } + + + @Override + public Rule deepCopy() { + XPathRule rule = (XPathRule) super.deepCopy(); + rule.attrLogger = this.attrLogger; + return rule; + } + + /** + * Returns the XPath expression that implements this rule. + */ + public String getXPathExpression() { + return getProperty(XPATH_DESCRIPTOR); + } + + + @Override + public void apply(Node target, RuleContext ctx) { + SaxonXPathRuleQuery query = getQueryMaybeInitialize(); + + List nodesWithViolation; + try { + nodesWithViolation = query.evaluate(target); + } catch (PmdXPathException e) { + throw addExceptionContext(e); + } + + for (Node nodeWithViolation : nodesWithViolation) { + addViolation(ctx, nodeWithViolation, nodeWithViolation.getImage()); + } + } + + private ContextedRuntimeException addExceptionContext(PmdXPathException e) { + return e.addRuleName(getName()); + } + + @Override + public void initialize(LanguageProcessor languageProcessor) { + String xpath = getXPathExpression(); + XPathVersion version = XPathVersion.DEFAULT; + + try { + xpathRuleQuery = new SaxonXPathRuleQuery(xpath, + version, + getPropertiesByPropertyDescriptor(), + languageProcessor.services().getXPathHandler(), + attrLogger); + } catch (PmdXPathException e) { + throw addExceptionContext(e); + } + } + + private SaxonXPathRuleQuery getQueryMaybeInitialize() throws PmdXPathException { + if (xpathRuleQuery == null) { + throw new IllegalStateException("Not initialized"); + } + return xpathRuleQuery; + } + + + @Override + protected @NonNull RuleTargetSelector buildTargetSelector() { + + List visits = getQueryMaybeInitialize().getRuleChainVisits(); + + logXPathRuleChainUsage(!visits.isEmpty()); + + return visits.isEmpty() ? RuleTargetSelector.forRootOnly() + : RuleTargetSelector.forXPathNames(visits); + } + + + private void logXPathRuleChainUsage(boolean usesRuleChain) { + LOG.debug("{} rule chain for XPath rule: {} ({})", + usesRuleChain ? "Using" : "no", + getName(), + getRuleSetName()); + } + + + @Override + public String dysfunctionReason() { + if (StringUtils.isBlank(getXPathExpression())) { + return "Missing XPath expression"; + } + return null; + } +} From b8ecc890afcbd4d034e5a4d7abd08b57a743d1f5 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 25 Jan 2024 10:23:58 +0100 Subject: [PATCH 13/23] [core] XPathHandler: Avoid direct dependency on saxon, Part 1 --- .../xpath/impl/AbstractXPathFunctionDef.java | 40 ------- .../xpath/impl/XPathFunctionDefinition.java | 63 +++++++++++ .../lang/rule/xpath/impl/XPathHandler.java | 8 +- .../internal/CoordinateXPathFunction.java | 19 ++-- .../xpath/internal/DefaultXPathFunctions.java | 7 +- .../xpath/internal/FileNameXPathFunction.java | 16 +-- .../xpath/internal/SaxonXPathRuleQuery.java | 103 +++++++++++++++++- .../internal/SaxonXPathRuleQueryTest.java | 17 ++- .../internal/BaseContextNodeTestFun.java | 11 +- .../xpath/internal/BaseJavaXPathFunction.java | 4 +- .../xpath/internal/BaseRewrittenFunction.java | 9 +- .../xpath/internal/GetCommentOnFunction.java | 13 +-- .../rule/xpath/internal/GetModifiersFun.java | 13 +-- .../rule/xpath/internal/MetricFunction.java | 11 +- .../internal/BaseKotlinXPathFunction.java | 4 +- .../pmd/lang/xml/rule/SaxonDomXPathQuery.java | 6 +- 16 files changed, 220 insertions(+), 124 deletions(-) delete mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/AbstractXPathFunctionDef.java create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/AbstractXPathFunctionDef.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/AbstractXPathFunctionDef.java deleted file mode 100644 index 8963a9071b..0000000000 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/AbstractXPathFunctionDef.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -package net.sourceforge.pmd.lang.rule.xpath.impl; - -import net.sourceforge.pmd.lang.Language; - -import net.sf.saxon.lib.ExtensionFunctionDefinition; -import net.sf.saxon.om.StructuredQName; - - -/** - * Base impl for an XPath function definition. - * This uses Saxon API. - * - * @since 7.0.0 - */ -public abstract class AbstractXPathFunctionDef extends ExtensionFunctionDefinition { - - private static final String PMD_URI_PREFIX = "http://pmd.sourceforge.net/"; - private final StructuredQName qname; - - private AbstractXPathFunctionDef(String localName, String namespacePrefix, String uri) { - this.qname = new StructuredQName(namespacePrefix, uri, localName); - } - - protected AbstractXPathFunctionDef(String localName) { - this(localName, "pmd", PMD_URI_PREFIX + "pmd-core"); - } - - protected AbstractXPathFunctionDef(String localName, Language language) { - this(localName, "pmd-" + language.getId(), PMD_URI_PREFIX + "pmd-" + language.getId()); - } - - @Override - public final StructuredQName getFunctionQName() { - return qname; - } -} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java new file mode 100644 index 0000000000..1e637d820b --- /dev/null +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java @@ -0,0 +1,63 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.rule.xpath.impl; + +import javax.xml.namespace.QName; + +import net.sourceforge.pmd.lang.Language; + +import net.sf.saxon.lib.ExtensionFunctionCall; + + +/** + * Base impl for an XPath function definition. + * + * @since 7.0.0 + */ +public abstract class XPathFunctionDefinition { + + private static final String PMD_URI_PREFIX = "http://pmd.sourceforge.net/"; + private final QName qname; + + private XPathFunctionDefinition(String localName, String namespacePrefix, String uri) { + this.qname = new QName(uri, localName, namespacePrefix); + } + + protected XPathFunctionDefinition(String localName) { + this(localName, "pmd", PMD_URI_PREFIX + "pmd-core"); + } + + protected XPathFunctionDefinition(String localName, Language language) { + this(localName, "pmd-" + language.getId(), PMD_URI_PREFIX + "pmd-" + language.getId()); + } + + public final QName getQName() { + return qname; + } + + public Type[] getArgumentTypes() { + return new Type[0]; + } + + public abstract Type getResultType(Type[] suppliedArgumentTypes); + + /** + * If the function depends on the context item or the default XPath namespace, then + * this method should return {@code true}. + */ + public boolean dependsOnContext() { + return false; + } + + public abstract ExtensionFunctionCall makeCallExpression(); + + public enum Type { + SINGLE_STRING, + SINGLE_BOOLEAN, + SINGLE_INTEGER, + SINGLE_ELEMENT, + STRING_SEQUENCE, OPTIONAL_STRING, OPTIONAL_DECIMAL, + } +} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathHandler.java index 0ef25b7884..73af54e17d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathHandler.java @@ -11,8 +11,6 @@ import java.util.Set; import net.sourceforge.pmd.lang.rule.xpath.internal.DefaultXPathFunctions; import net.sourceforge.pmd.util.CollectionUtil; -import net.sf.saxon.lib.ExtensionFunctionDefinition; - /** * Interface for performing Language specific XPath handling, such as @@ -24,7 +22,7 @@ public interface XPathHandler { * Returns the set of extension functions for this language module. * These are the additional functions available in XPath queries. */ - Set getRegisteredExtensionFunctions(); + Set getRegisteredExtensionFunctions(); static XPathHandler noFunctionDefinitions() { @@ -34,8 +32,8 @@ public interface XPathHandler { /** * Returns a default XPath handler. */ - static XPathHandler getHandlerForFunctionDefs(ExtensionFunctionDefinition first, ExtensionFunctionDefinition... defs) { - Set set = new HashSet<>(CollectionUtil.setOf(first, defs)); + static XPathHandler getHandlerForFunctionDefs(XPathFunctionDefinition first, XPathFunctionDefinition... defs) { + Set set = new HashSet<>(CollectionUtil.setOf(first, defs)); set.addAll(DefaultXPathFunctions.getDefaultFunctions()); return () -> Collections.unmodifiableSet(set); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/CoordinateXPathFunction.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/CoordinateXPathFunction.java index 31d41783e2..c9eca24fe0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/CoordinateXPathFunction.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/CoordinateXPathFunction.java @@ -7,23 +7,20 @@ package net.sourceforge.pmd.lang.rule.xpath.internal; import java.util.function.ToIntFunction; import net.sourceforge.pmd.lang.ast.Node; -import net.sourceforge.pmd.lang.rule.xpath.impl.AbstractXPathFunctionDef; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionDefinition; import net.sf.saxon.expr.XPathContext; import net.sf.saxon.lib.ExtensionFunctionCall; import net.sf.saxon.om.Sequence; -import net.sf.saxon.pattern.NodeKindTest; import net.sf.saxon.trans.XPathException; -import net.sf.saxon.type.Type; import net.sf.saxon.value.Int64Value; -import net.sf.saxon.value.SequenceType; /** * A function that returns the current file name. * * @author Clément Fournier */ -public final class CoordinateXPathFunction extends AbstractXPathFunctionDef { +public final class CoordinateXPathFunction extends XPathFunctionDefinition { public static final CoordinateXPathFunction START_LINE = new CoordinateXPathFunction("startLine", Node::getBeginLine); @@ -34,9 +31,7 @@ public final class CoordinateXPathFunction extends AbstractXPathFunctionDef { public static final CoordinateXPathFunction END_COLUMN = new CoordinateXPathFunction("endColumn", Node::getEndColumn); - private static final SequenceType[] A_SINGLE_ELEMENT = { - NodeKindTest.makeNodeKindTest(Type.ELEMENT).one(), - }; + private static final Type[] A_SINGLE_ELEMENT = { Type.SINGLE_ELEMENT }; public static final String PMD_NODE_USER_DATA = "pmd.node"; private final ToIntFunction getter; @@ -46,13 +41,13 @@ public final class CoordinateXPathFunction extends AbstractXPathFunctionDef { } @Override - public SequenceType[] getArgumentTypes() { + public Type[] getArgumentTypes() { return A_SINGLE_ELEMENT; } @Override - public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) { - return SequenceType.SINGLE_INTEGER; + public Type getResultType(Type[] suppliedArgumentTypes) { + return Type.SINGLE_INTEGER; } @Override @@ -64,7 +59,7 @@ public final class CoordinateXPathFunction extends AbstractXPathFunctionDef { Node node = XPathElementToNodeHelper.itemToNode(arguments[0]); if (node == null) { throw new XPathException( - "Cannot call function '" + getFunctionQName().getLocalPart() + "Cannot call function '" + getQName().getLocalPart() + "' on argument " + arguments[0] ); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DefaultXPathFunctions.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DefaultXPathFunctions.java index bfd58f98fa..fddc9bc8e6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DefaultXPathFunctions.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DefaultXPathFunctions.java @@ -7,16 +7,15 @@ package net.sourceforge.pmd.lang.rule.xpath.internal; import java.util.Set; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionDefinition; import net.sourceforge.pmd.util.CollectionUtil; -import net.sf.saxon.lib.ExtensionFunctionDefinition; - /** * Default XPath functions provided by pmd-core. */ public final class DefaultXPathFunctions { - private static final Set DEFAULTS = + private static final Set DEFAULTS = CollectionUtil.immutableSetOf( FileNameXPathFunction.INSTANCE, CoordinateXPathFunction.START_LINE, @@ -29,7 +28,7 @@ public final class DefaultXPathFunctions { // utility class } - public static Set getDefaultFunctions() { + public static Set getDefaultFunctions() { return DEFAULTS; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/FileNameXPathFunction.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/FileNameXPathFunction.java index 97131458e1..e356332fd4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/FileNameXPathFunction.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/FileNameXPathFunction.java @@ -8,13 +8,12 @@ import java.util.Objects; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; -import net.sourceforge.pmd.lang.rule.xpath.impl.AbstractXPathFunctionDef; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionDefinition; import net.sf.saxon.expr.XPathContext; import net.sf.saxon.lib.ExtensionFunctionCall; import net.sf.saxon.om.Sequence; import net.sf.saxon.trans.XPathException; -import net.sf.saxon.value.SequenceType; import net.sf.saxon.value.StringValue; /** @@ -22,7 +21,7 @@ import net.sf.saxon.value.StringValue; * * @author Clément Fournier */ -public final class FileNameXPathFunction extends AbstractXPathFunctionDef { +public final class FileNameXPathFunction extends XPathFunctionDefinition { public static final FileNameXPathFunction INSTANCE = new FileNameXPathFunction(); @@ -31,13 +30,8 @@ public final class FileNameXPathFunction extends AbstractXPathFunctionDef { } @Override - public SequenceType[] getArgumentTypes() { - return new SequenceType[0]; - } - - @Override - public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) { - return SequenceType.STRING_SEQUENCE; + public Type getResultType(Type[] suppliedArgumentTypes) { + return Type.STRING_SEQUENCE; } @Override @@ -49,7 +43,7 @@ public final class FileNameXPathFunction extends AbstractXPathFunctionDef { Node node = XPathElementToNodeHelper.itemToNode(context.getContextItem()); if (node == null) { throw new XPathException( - "Cannot call function '" + getFunctionQName().getLocalPart() + "Cannot call function '" + getQName().getLocalPart() + "' with context item " + context.getContextItem() ); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java index bb14c23b4c..a99007f67f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java @@ -10,6 +10,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import javax.xml.namespace.QName; import org.apache.commons.lang3.exception.ContextedRuntimeException; import org.slf4j.Logger; @@ -20,6 +21,7 @@ import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionDefinition; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathHandler; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.util.DataMap; @@ -28,6 +30,7 @@ import net.sourceforge.pmd.util.DataMap.SimpleDataKey; import net.sf.saxon.Configuration; import net.sf.saxon.expr.Expression; import net.sf.saxon.expr.LocalVariableReference; +import net.sf.saxon.lib.ExtensionFunctionCall; import net.sf.saxon.lib.ExtensionFunctionDefinition; import net.sf.saxon.lib.NamespaceConstant; import net.sf.saxon.om.AtomicSequence; @@ -35,12 +38,15 @@ import net.sf.saxon.om.Item; import net.sf.saxon.om.NamePool; import net.sf.saxon.om.SequenceIterator; import net.sf.saxon.om.StructuredQName; +import net.sf.saxon.pattern.NameTest; +import net.sf.saxon.pattern.NodeKindTest; import net.sf.saxon.sxpath.IndependentContext; import net.sf.saxon.sxpath.XPathDynamicContext; import net.sf.saxon.sxpath.XPathEvaluator; import net.sf.saxon.sxpath.XPathExpression; import net.sf.saxon.sxpath.XPathVariable; import net.sf.saxon.trans.XPathException; +import net.sf.saxon.value.SequenceType; /** @@ -198,7 +204,8 @@ public class SaxonXPathRuleQuery { } } - for (ExtensionFunctionDefinition fun : xPathHandler.getRegisteredExtensionFunctions()) { + for (XPathFunctionDefinition xpathFun : xPathHandler.getRegisteredExtensionFunctions()) { + ExtensionFunctionDefinition fun = convertAbstractXPathFunctionDefinition(xpathFun); StructuredQName qname = fun.getFunctionQName(); staticCtx.declareNamespace(qname.getPrefix(), qname.getURI()); this.configuration.registerExtensionFunction(fun); @@ -283,4 +290,98 @@ public class SaxonXPathRuleQuery { return local; } } + + public static ExtensionFunctionDefinition convertAbstractXPathFunctionDefinition(XPathFunctionDefinition definition) { + final SequenceType SINGLE_ELEMENT_SEQUENCE_TYPE = NodeKindTest.ELEMENT.one(); + + return new ExtensionFunctionDefinition() { + private SequenceType convertToSequenceType(XPathFunctionDefinition.Type type) { + switch (type) { + case SINGLE_STRING: return SequenceType.SINGLE_STRING; + case SINGLE_BOOLEAN: return SequenceType.SINGLE_BOOLEAN; + case SINGLE_ELEMENT: return SINGLE_ELEMENT_SEQUENCE_TYPE; + case SINGLE_INTEGER: return SequenceType.SINGLE_INTEGER; + case STRING_SEQUENCE: return SequenceType.STRING_SEQUENCE; + case OPTIONAL_STRING: return SequenceType.OPTIONAL_STRING; + case OPTIONAL_DECIMAL: return SequenceType.OPTIONAL_DECIMAL; + default: + throw new UnsupportedOperationException("Type " + type + " is not supported"); + } + } + + private XPathFunctionDefinition.Type convertToType(SequenceType sequenceType) { + if (SequenceType.SINGLE_STRING.equals(sequenceType)) { + return XPathFunctionDefinition.Type.SINGLE_STRING; + } + if (SequenceType.SINGLE_BOOLEAN.equals(sequenceType)) { + return XPathFunctionDefinition.Type.SINGLE_BOOLEAN; + } + if (SequenceType.SINGLE_INTEGER.equals(sequenceType)) { + return XPathFunctionDefinition.Type.SINGLE_INTEGER; + } + if (SequenceType.STRING_SEQUENCE.equals(sequenceType)) { + return XPathFunctionDefinition.Type.STRING_SEQUENCE; + } + if (SequenceType.OPTIONAL_STRING.equals(sequenceType)) { + return XPathFunctionDefinition.Type.OPTIONAL_STRING; + } + if (SequenceType.OPTIONAL_DECIMAL.equals(sequenceType)) { + return XPathFunctionDefinition.Type.OPTIONAL_DECIMAL; + } + if (sequenceType.getCardinality() == SINGLE_ELEMENT_SEQUENCE_TYPE.getCardinality() + && sequenceType.getPrimaryType() instanceof NameTest + && ((NameTest) sequenceType.getPrimaryType()).getNodeKind() + == ((NodeKindTest) SINGLE_ELEMENT_SEQUENCE_TYPE.getPrimaryType()).getNodeKind()) { + return XPathFunctionDefinition.Type.SINGLE_ELEMENT; + } + if (SINGLE_ELEMENT_SEQUENCE_TYPE.equals(sequenceType)) { + return XPathFunctionDefinition.Type.SINGLE_ELEMENT; + } + + throw new UnsupportedOperationException("Type " + sequenceType + " is not supported"); + } + + private SequenceType[] convertToSequenceTypes(XPathFunctionDefinition.Type[] types) { + SequenceType[] result = new SequenceType[types.length]; + for (int i = 0; i < types.length; i++) { + result[i] = convertToSequenceType(types[i]); + } + return result; + } + + private XPathFunctionDefinition.Type[] convertToTypes(SequenceType[] sequenceTypes) { + XPathFunctionDefinition.Type[] result = new XPathFunctionDefinition.Type[sequenceTypes.length]; + for (int i = 0; i < sequenceTypes.length; i++) { + result[i] = convertToType(sequenceTypes[i]); + } + return result; + } + + @Override + public StructuredQName getFunctionQName() { + QName qName = definition.getQName(); + return new StructuredQName(qName.getPrefix(), qName.getNamespaceURI(), qName.getLocalPart()); + } + + @Override + public SequenceType[] getArgumentTypes() { + return convertToSequenceTypes(definition.getArgumentTypes()); + } + + @Override + public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) { + return convertToSequenceType(definition.getResultType(convertToTypes(suppliedArgumentTypes))); + } + + @Override + public boolean dependsOnFocus() { + return definition.dependsOnContext(); + } + + @Override + public ExtensionFunctionCall makeCallExpression() { + return definition.makeCallExpression(); + } + }; + } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQueryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQueryTest.java index d24b7e9869..d0097690e8 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQueryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQueryTest.java @@ -31,7 +31,7 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; -import net.sourceforge.pmd.lang.rule.xpath.impl.AbstractXPathFunctionDef; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionDefinition; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathHandler; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; @@ -42,7 +42,6 @@ import net.sf.saxon.lib.ExtensionFunctionCall; import net.sf.saxon.om.Sequence; import net.sf.saxon.trans.XPathException; import net.sf.saxon.value.BooleanValue; -import net.sf.saxon.value.SequenceType; class SaxonXPathRuleQueryTest { @@ -422,16 +421,16 @@ class SaxonXPathRuleQueryTest { } @NonNull - private static AbstractXPathFunctionDef imageIsFunction() { - return new AbstractXPathFunctionDef("imageIs", DummyLanguageModule.getInstance()) { + private static XPathFunctionDefinition imageIsFunction() { + return new XPathFunctionDefinition("imageIs", DummyLanguageModule.getInstance()) { @Override - public SequenceType[] getArgumentTypes() { - return new SequenceType[] {SequenceType.SINGLE_STRING}; + public Type[] getArgumentTypes() { + return new Type[] {Type.SINGLE_STRING}; } @Override - public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) { - return SequenceType.SINGLE_BOOLEAN; + public Type getResultType(Type[] suppliedArgumentTypes) { + return Type.SINGLE_BOOLEAN; } @Override @@ -439,7 +438,7 @@ class SaxonXPathRuleQueryTest { return new ExtensionFunctionCall() { @Override public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { - Node contextNode = ((AstElementNode) context.getContextItem()).getUnderlyingNode(); + Node contextNode = XPathElementToNodeHelper.itemToNode(context.getContextItem()); return BooleanValue.get(arguments[0].head().getStringValue().equals(contextNode.getImage())); } }; diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseContextNodeTestFun.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseContextNodeTestFun.java index e40914cc75..f44b4618f5 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseContextNodeTestFun.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseContextNodeTestFun.java @@ -18,7 +18,6 @@ import net.sf.saxon.lib.ExtensionFunctionCall; import net.sf.saxon.om.Sequence; import net.sf.saxon.trans.XPathException; import net.sf.saxon.value.BooleanValue; -import net.sf.saxon.value.SequenceType; /** * XPath function {@code pmd-java:typeIs(typeName as xs:string) as xs:boolean} @@ -30,7 +29,7 @@ import net.sf.saxon.value.SequenceType; */ public class BaseContextNodeTestFun extends BaseJavaXPathFunction { - static final SequenceType[] SINGLE_STRING_SEQ = {SequenceType.SINGLE_STRING}; + static final Type[] SINGLE_STRING_SEQ = {Type.SINGLE_STRING}; private final Class klass; private final BiPredicate checker; @@ -45,17 +44,17 @@ public class BaseContextNodeTestFun extends BaseJavaXPathFun } @Override - public SequenceType[] getArgumentTypes() { + public Type[] getArgumentTypes() { return SINGLE_STRING_SEQ; } @Override - public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) { - return SequenceType.SINGLE_BOOLEAN; + public Type getResultType(Type[] suppliedArgumentTypes) { + return Type.SINGLE_BOOLEAN; } @Override - public boolean dependsOnFocus() { + public boolean dependsOnContext() { return true; } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseJavaXPathFunction.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseJavaXPathFunction.java index 450a33013e..e8927bde54 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseJavaXPathFunction.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseJavaXPathFunction.java @@ -5,9 +5,9 @@ package net.sourceforge.pmd.lang.java.rule.xpath.internal; import net.sourceforge.pmd.lang.java.JavaLanguageModule; -import net.sourceforge.pmd.lang.rule.xpath.impl.AbstractXPathFunctionDef; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionDefinition; -abstract class BaseJavaXPathFunction extends AbstractXPathFunctionDef { +abstract class BaseJavaXPathFunction extends XPathFunctionDefinition { protected BaseJavaXPathFunction(String localName) { super(localName, JavaLanguageModule.getInstance()); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseRewrittenFunction.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseRewrittenFunction.java index f2f1e4c768..6607f78038 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseRewrittenFunction.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseRewrittenFunction.java @@ -17,7 +17,6 @@ import net.sf.saxon.lib.ExtensionFunctionCall; import net.sf.saxon.om.Sequence; import net.sf.saxon.trans.XPathException; import net.sf.saxon.value.BooleanValue; -import net.sf.saxon.value.SequenceType; /** @@ -39,17 +38,17 @@ abstract class BaseRewrittenFunction extends BaseJavaXPathFun } @Override - public SequenceType[] getArgumentTypes() { + public Type[] getArgumentTypes() { return SINGLE_STRING_SEQ; } @Override - public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) { - return SequenceType.SINGLE_BOOLEAN; + public Type getResultType(Type[] suppliedArgumentTypes) { + return Type.SINGLE_BOOLEAN; } @Override - public boolean dependsOnFocus() { + public boolean dependsOnContext() { return true; } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetCommentOnFunction.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetCommentOnFunction.java index 8014821ecd..17380d8cc0 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetCommentOnFunction.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetCommentOnFunction.java @@ -15,7 +15,6 @@ import net.sf.saxon.expr.XPathContext; import net.sf.saxon.lib.ExtensionFunctionCall; import net.sf.saxon.om.EmptyAtomicSequence; import net.sf.saxon.om.Sequence; -import net.sf.saxon.value.SequenceType; import net.sf.saxon.value.StringValue; @@ -36,19 +35,13 @@ public class GetCommentOnFunction extends BaseJavaXPathFunction { } @Override - public SequenceType[] getArgumentTypes() { - return new SequenceType[0]; + public Type getResultType(Type[] suppliedArgumentTypes) { + return Type.OPTIONAL_STRING; } @Override - public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) { - return SequenceType.OPTIONAL_STRING; - } - - - @Override - public boolean dependsOnFocus() { + public boolean dependsOnContext() { return true; } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFun.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFun.java index 37fa4cad64..3d97ef8fff 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFun.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFun.java @@ -18,7 +18,6 @@ import net.sf.saxon.lib.ExtensionFunctionCall; import net.sf.saxon.om.Sequence; import net.sf.saxon.value.EmptySequence; import net.sf.saxon.value.SequenceExtent; -import net.sf.saxon.value.SequenceType; import net.sf.saxon.value.StringValue; /** @@ -26,7 +25,6 @@ import net.sf.saxon.value.StringValue; */ public final class GetModifiersFun extends BaseJavaXPathFunction { - private static final SequenceType[] ARGTYPES = {}; private final boolean explicit; public static final GetModifiersFun GET_EFFECTIVE = new GetModifiersFun("modifiers", false); @@ -38,17 +36,12 @@ public final class GetModifiersFun extends BaseJavaXPathFunction { } @Override - public SequenceType[] getArgumentTypes() { - return ARGTYPES; + public Type getResultType(Type[] suppliedArgumentTypes) { + return Type.STRING_SEQUENCE; } @Override - public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) { - return SequenceType.STRING_SEQUENCE; - } - - @Override - public boolean dependsOnFocus() { + public boolean dependsOnContext() { return true; } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MetricFunction.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MetricFunction.java index 93e1448c7c..f586d92432 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MetricFunction.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MetricFunction.java @@ -16,7 +16,6 @@ import net.sf.saxon.om.Sequence; import net.sf.saxon.trans.XPathException; import net.sf.saxon.value.BigDecimalValue; import net.sf.saxon.value.EmptySequence; -import net.sf.saxon.value.SequenceType; /** @@ -38,19 +37,19 @@ public final class MetricFunction extends BaseJavaXPathFunction { } @Override - public SequenceType[] getArgumentTypes() { - return new SequenceType[] {SequenceType.SINGLE_STRING}; + public Type[] getArgumentTypes() { + return new Type[] {Type.SINGLE_STRING}; } @Override - public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) { - return SequenceType.OPTIONAL_DECIMAL; + public Type getResultType(Type[] suppliedArgumentTypes) { + return Type.OPTIONAL_DECIMAL; } @Override - public boolean dependsOnFocus() { + public boolean dependsOnContext() { return true; } diff --git a/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/rule/xpath/internal/BaseKotlinXPathFunction.java b/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/rule/xpath/internal/BaseKotlinXPathFunction.java index e74c632ec2..96459af335 100644 --- a/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/rule/xpath/internal/BaseKotlinXPathFunction.java +++ b/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/rule/xpath/internal/BaseKotlinXPathFunction.java @@ -5,9 +5,9 @@ package net.sourceforge.pmd.lang.kotlin.rule.xpath.internal; import net.sourceforge.pmd.lang.kotlin.KotlinLanguageModule; -import net.sourceforge.pmd.lang.rule.xpath.impl.AbstractXPathFunctionDef; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionDefinition; -abstract class BaseKotlinXPathFunction extends AbstractXPathFunctionDef { +abstract class BaseKotlinXPathFunction extends XPathFunctionDefinition { protected BaseKotlinXPathFunction(String localName) { super(localName, KotlinLanguageModule.getInstance()); diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/SaxonDomXPathQuery.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/SaxonDomXPathQuery.java index 74f70fa3a3..0711cef00e 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/SaxonDomXPathQuery.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/SaxonDomXPathQuery.java @@ -4,6 +4,8 @@ package net.sourceforge.pmd.lang.xml.rule; +import static net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery.convertAbstractXPathFunctionDefinition; + import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -16,6 +18,7 @@ import org.apache.commons.lang3.exception.ContextedRuntimeException; import org.w3c.dom.Document; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionDefinition; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathHandler; import net.sourceforge.pmd.lang.rule.xpath.internal.DomainConversion; import net.sourceforge.pmd.lang.xml.ast.XmlNode; @@ -78,7 +81,8 @@ final class SaxonDomXPathQuery { - for (ExtensionFunctionDefinition fun : xpathHandler.getRegisteredExtensionFunctions()) { + for (XPathFunctionDefinition xpathFun : xpathHandler.getRegisteredExtensionFunctions()) { + ExtensionFunctionDefinition fun = convertAbstractXPathFunctionDefinition(xpathFun); StructuredQName qname = fun.getFunctionQName(); xpathStaticContext.declareNamespace(qname.getPrefix(), qname.getURI()); this.configuration.registerExtensionFunction(fun); From 721661c3f9925fcb0f9979f7dbf20a67fa14bf10 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 25 Jan 2024 12:28:25 +0100 Subject: [PATCH 14/23] [core] XPathHandler: Avoid direct dependency on saxon, Part 2 Define new interface FunctionCall, that replaces the saxon interface ExtensionFunctionCall. --- .../xpath/impl/XPathFunctionDefinition.java | 20 ++- .../xpath/impl/XPathFunctionException.java | 15 ++ .../internal/CoordinateXPathFunction.java | 33 ++--- .../xpath/internal/FileNameXPathFunction.java | 48 +++---- .../xpath/internal/SaxonXPathRuleQuery.java | 133 ++++++++++++------ .../internal/SaxonXPathRuleQueryTest.java | 18 +-- .../internal/BaseContextNodeTestFun.java | 24 +--- .../xpath/internal/BaseRewrittenFunction.java | 49 +++---- .../xpath/internal/GetCommentOnFunction.java | 34 ++--- .../rule/xpath/internal/GetModifiersFun.java | 33 ++--- .../internal/MatchesSignatureFunction.java | 9 +- .../rule/xpath/internal/MetricFunction.java | 32 ++--- .../rule/xpath/internal/NodeIsFunction.java | 9 +- 13 files changed, 211 insertions(+), 246 deletions(-) create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionException.java diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java index 1e637d820b..43ae353aec 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java @@ -7,9 +7,7 @@ package net.sourceforge.pmd.lang.rule.xpath.impl; import javax.xml.namespace.QName; import net.sourceforge.pmd.lang.Language; - -import net.sf.saxon.lib.ExtensionFunctionCall; - +import net.sourceforge.pmd.lang.ast.Node; /** * Base impl for an XPath function definition. @@ -41,7 +39,7 @@ public abstract class XPathFunctionDefinition { return new Type[0]; } - public abstract Type getResultType(Type[] suppliedArgumentTypes); + public abstract Type getResultType(); /** * If the function depends on the context item or the default XPath namespace, then @@ -51,13 +49,23 @@ public abstract class XPathFunctionDefinition { return false; } - public abstract ExtensionFunctionCall makeCallExpression(); + public abstract FunctionCall makeCallExpression(); public enum Type { SINGLE_STRING, SINGLE_BOOLEAN, SINGLE_INTEGER, SINGLE_ELEMENT, - STRING_SEQUENCE, OPTIONAL_STRING, OPTIONAL_DECIMAL, + STRING_SEQUENCE, + OPTIONAL_STRING, + OPTIONAL_DECIMAL, + } + + public interface FunctionCall { + default void staticInit(Object[] arguments) throws XPathFunctionException { + // default implementation does nothing + } + + Object call(Node contextNode, Object[] arguments) throws XPathFunctionException; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionException.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionException.java new file mode 100644 index 0000000000..5bddd4001d --- /dev/null +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionException.java @@ -0,0 +1,15 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.rule.xpath.impl; + +public class XPathFunctionException extends Exception { + public XPathFunctionException(String message) { + super(message); + } + + public XPathFunctionException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/CoordinateXPathFunction.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/CoordinateXPathFunction.java index c9eca24fe0..59a4e83b8e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/CoordinateXPathFunction.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/CoordinateXPathFunction.java @@ -8,12 +8,7 @@ import java.util.function.ToIntFunction; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionDefinition; - -import net.sf.saxon.expr.XPathContext; -import net.sf.saxon.lib.ExtensionFunctionCall; -import net.sf.saxon.om.Sequence; -import net.sf.saxon.trans.XPathException; -import net.sf.saxon.value.Int64Value; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionException; /** * A function that returns the current file name. @@ -46,27 +41,21 @@ public final class CoordinateXPathFunction extends XPathFunctionDefinition { } @Override - public Type getResultType(Type[] suppliedArgumentTypes) { + public Type getResultType() { return Type.SINGLE_INTEGER; } @Override - public ExtensionFunctionCall makeCallExpression() { - return new ExtensionFunctionCall() { - - @Override - public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { - Node node = XPathElementToNodeHelper.itemToNode(arguments[0]); - if (node == null) { - throw new XPathException( - "Cannot call function '" + getQName().getLocalPart() - + "' on argument " + arguments[0] - ); - } - return Int64Value.makeIntegerValue(getter.applyAsInt(node)); + public FunctionCall makeCallExpression() { + return (contextNode, arguments) -> { + Node node = XPathElementToNodeHelper.itemToNode(arguments[0]); + if (node == null) { + throw new XPathFunctionException( + "Cannot call function '" + getQName().getLocalPart() + + "' on argument " + arguments[0] + ); } + return getter.applyAsInt(node); }; } - - } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/FileNameXPathFunction.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/FileNameXPathFunction.java index e356332fd4..1f170aee12 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/FileNameXPathFunction.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/FileNameXPathFunction.java @@ -6,15 +6,9 @@ package net.sourceforge.pmd.lang.rule.xpath.internal; import java.util.Objects; -import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionDefinition; - -import net.sf.saxon.expr.XPathContext; -import net.sf.saxon.lib.ExtensionFunctionCall; -import net.sf.saxon.om.Sequence; -import net.sf.saxon.trans.XPathException; -import net.sf.saxon.value.StringValue; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionException; /** * A function that returns the current file name. @@ -30,31 +24,31 @@ public final class FileNameXPathFunction extends XPathFunctionDefinition { } @Override - public Type getResultType(Type[] suppliedArgumentTypes) { - return Type.STRING_SEQUENCE; + public Type getResultType() { + return Type.SINGLE_STRING; } @Override - public ExtensionFunctionCall makeCallExpression() { - return new ExtensionFunctionCall() { + public boolean dependsOnContext() { + return true; + } - @Override - public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { - Node node = XPathElementToNodeHelper.itemToNode(context.getContextItem()); - if (node == null) { - throw new XPathException( - "Cannot call function '" + getQName().getLocalPart() - + "' with context item " + context.getContextItem() - ); - } - RootNode root = node.getRoot(); - Objects.requireNonNull(root, "No root node in tree?"); - - String fileName = root.getTextDocument().getFileId().getFileName(); - Objects.requireNonNull(fileName, "File name was not set"); - - return new StringValue(fileName); + @Override + public FunctionCall makeCallExpression() { + return (node, arguments) -> { + if (node == null) { + throw new XPathFunctionException( + "Cannot call function '" + getQName().getLocalPart() + + "' without context item" + ); } + RootNode root = node.getRoot(); + Objects.requireNonNull(root, "No root node in tree?"); + + String fileName = root.getTextDocument().getFileId().getFileName(); + Objects.requireNonNull(fileName, "File name was not set"); + + return fileName; }; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java index a99007f67f..b8c5e89011 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java @@ -5,11 +5,13 @@ package net.sourceforge.pmd.lang.rule.xpath.internal; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; import javax.xml.namespace.QName; import org.apache.commons.lang3.exception.ContextedRuntimeException; @@ -22,6 +24,7 @@ import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionDefinition; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionException; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathHandler; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.util.DataMap; @@ -30,15 +33,19 @@ import net.sourceforge.pmd.util.DataMap.SimpleDataKey; import net.sf.saxon.Configuration; import net.sf.saxon.expr.Expression; import net.sf.saxon.expr.LocalVariableReference; +import net.sf.saxon.expr.StaticContext; +import net.sf.saxon.expr.StringLiteral; +import net.sf.saxon.expr.XPathContext; import net.sf.saxon.lib.ExtensionFunctionCall; import net.sf.saxon.lib.ExtensionFunctionDefinition; import net.sf.saxon.lib.NamespaceConstant; import net.sf.saxon.om.AtomicSequence; +import net.sf.saxon.om.EmptyAtomicSequence; import net.sf.saxon.om.Item; import net.sf.saxon.om.NamePool; +import net.sf.saxon.om.Sequence; import net.sf.saxon.om.SequenceIterator; import net.sf.saxon.om.StructuredQName; -import net.sf.saxon.pattern.NameTest; import net.sf.saxon.pattern.NodeKindTest; import net.sf.saxon.sxpath.IndependentContext; import net.sf.saxon.sxpath.XPathDynamicContext; @@ -46,7 +53,13 @@ import net.sf.saxon.sxpath.XPathEvaluator; import net.sf.saxon.sxpath.XPathExpression; import net.sf.saxon.sxpath.XPathVariable; import net.sf.saxon.trans.XPathException; +import net.sf.saxon.value.BigDecimalValue; +import net.sf.saxon.value.BooleanValue; +import net.sf.saxon.value.EmptySequence; +import net.sf.saxon.value.Int64Value; +import net.sf.saxon.value.SequenceExtent; import net.sf.saxon.value.SequenceType; +import net.sf.saxon.value.StringValue; /** @@ -309,38 +322,6 @@ public class SaxonXPathRuleQuery { } } - private XPathFunctionDefinition.Type convertToType(SequenceType sequenceType) { - if (SequenceType.SINGLE_STRING.equals(sequenceType)) { - return XPathFunctionDefinition.Type.SINGLE_STRING; - } - if (SequenceType.SINGLE_BOOLEAN.equals(sequenceType)) { - return XPathFunctionDefinition.Type.SINGLE_BOOLEAN; - } - if (SequenceType.SINGLE_INTEGER.equals(sequenceType)) { - return XPathFunctionDefinition.Type.SINGLE_INTEGER; - } - if (SequenceType.STRING_SEQUENCE.equals(sequenceType)) { - return XPathFunctionDefinition.Type.STRING_SEQUENCE; - } - if (SequenceType.OPTIONAL_STRING.equals(sequenceType)) { - return XPathFunctionDefinition.Type.OPTIONAL_STRING; - } - if (SequenceType.OPTIONAL_DECIMAL.equals(sequenceType)) { - return XPathFunctionDefinition.Type.OPTIONAL_DECIMAL; - } - if (sequenceType.getCardinality() == SINGLE_ELEMENT_SEQUENCE_TYPE.getCardinality() - && sequenceType.getPrimaryType() instanceof NameTest - && ((NameTest) sequenceType.getPrimaryType()).getNodeKind() - == ((NodeKindTest) SINGLE_ELEMENT_SEQUENCE_TYPE.getPrimaryType()).getNodeKind()) { - return XPathFunctionDefinition.Type.SINGLE_ELEMENT; - } - if (SINGLE_ELEMENT_SEQUENCE_TYPE.equals(sequenceType)) { - return XPathFunctionDefinition.Type.SINGLE_ELEMENT; - } - - throw new UnsupportedOperationException("Type " + sequenceType + " is not supported"); - } - private SequenceType[] convertToSequenceTypes(XPathFunctionDefinition.Type[] types) { SequenceType[] result = new SequenceType[types.length]; for (int i = 0; i < types.length; i++) { @@ -349,14 +330,6 @@ public class SaxonXPathRuleQuery { return result; } - private XPathFunctionDefinition.Type[] convertToTypes(SequenceType[] sequenceTypes) { - XPathFunctionDefinition.Type[] result = new XPathFunctionDefinition.Type[sequenceTypes.length]; - for (int i = 0; i < sequenceTypes.length; i++) { - result[i] = convertToType(sequenceTypes[i]); - } - return result; - } - @Override public StructuredQName getFunctionQName() { QName qName = definition.getQName(); @@ -370,7 +343,7 @@ public class SaxonXPathRuleQuery { @Override public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) { - return convertToSequenceType(definition.getResultType(convertToTypes(suppliedArgumentTypes))); + return convertToSequenceType(definition.getResultType()); } @Override @@ -380,7 +353,81 @@ public class SaxonXPathRuleQuery { @Override public ExtensionFunctionCall makeCallExpression() { - return definition.makeCallExpression(); + XPathFunctionDefinition.FunctionCall call = definition.makeCallExpression(); + return new ExtensionFunctionCall() { + @Override + public Expression rewrite(StaticContext context, Expression[] arguments) throws XPathException { + Object[] convertedArguments = new Object[definition.getArgumentTypes().length]; + for (int i = 0; i < convertedArguments.length; i++) { + if (arguments[i] instanceof StringLiteral) { + convertedArguments[i] = ((StringLiteral) arguments[i]).getStringValue(); + } + } + try { + call.staticInit(convertedArguments); + } catch (XPathFunctionException e) { + XPathException xPathException = new XPathException(e); + xPathException.setIsStaticError(true); + throw xPathException; + } + return null; + } + + @Override + public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { + Node contextNode = null; + if (definition.dependsOnContext()) { + contextNode = XPathElementToNodeHelper.itemToNode(context.getContextItem()); + } + Object[] convertedArguments = new Object[definition.getArgumentTypes().length]; + for (int i = 0; i < convertedArguments.length; i++) { + switch (definition.getArgumentTypes()[i]) { + case SINGLE_STRING: + convertedArguments[i] = arguments[i].head().getStringValue(); + break; + case SINGLE_ELEMENT: + convertedArguments[i] = arguments[i].head(); + break; + default: + throw new UnsupportedOperationException("Don't know how to convert argument type " + definition.getArgumentTypes()[i]); + } + } + + + Object result = null; + try { + result = call.call(contextNode, convertedArguments); + } catch (XPathFunctionException e) { + throw new XPathException(e); + } + Sequence convertedResult = null; + switch (definition.getResultType()) { + case SINGLE_BOOLEAN: + convertedResult = BooleanValue.get((Boolean) result); + break; + case SINGLE_INTEGER: + convertedResult = Int64Value.makeIntegerValue((Integer) result); + break; + case SINGLE_STRING: + convertedResult = new StringValue((String) result); + break; + case OPTIONAL_STRING: + convertedResult = result != null ? new StringValue((String) result) : EmptyAtomicSequence.INSTANCE; + break; + case STRING_SEQUENCE: + convertedResult = result != null ? new SequenceExtent(Arrays.stream((String[]) result).map(StringValue::new).collect(Collectors.toList())) + : EmptySequence.getInstance(); + break; + case OPTIONAL_DECIMAL: + convertedResult = result != null && Double.isFinite((Double) result) ? new BigDecimalValue((Double) result) + : EmptySequence.getInstance(); + break; + default: + throw new UnsupportedOperationException("Don't know how to convert result type " + definition.getResultType()); + } + return convertedResult; + } + }; } }; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQueryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQueryTest.java index d0097690e8..99de993087 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQueryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQueryTest.java @@ -18,6 +18,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.NonNull; import org.hamcrest.CoreMatchers; import org.junit.jupiter.api.Test; @@ -37,11 +38,6 @@ import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; import net.sf.saxon.expr.Expression; -import net.sf.saxon.expr.XPathContext; -import net.sf.saxon.lib.ExtensionFunctionCall; -import net.sf.saxon.om.Sequence; -import net.sf.saxon.trans.XPathException; -import net.sf.saxon.value.BooleanValue; class SaxonXPathRuleQueryTest { @@ -429,19 +425,13 @@ class SaxonXPathRuleQueryTest { } @Override - public Type getResultType(Type[] suppliedArgumentTypes) { + public Type getResultType() { return Type.SINGLE_BOOLEAN; } @Override - public ExtensionFunctionCall makeCallExpression() { - return new ExtensionFunctionCall() { - @Override - public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { - Node contextNode = XPathElementToNodeHelper.itemToNode(context.getContextItem()); - return BooleanValue.get(arguments[0].head().getStringValue().equals(contextNode.getImage())); - } - }; + public FunctionCall makeCallExpression() { + return (contextNode, arguments) -> StringUtils.equals(arguments[0].toString(), contextNode.getImage()); } }; } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseContextNodeTestFun.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseContextNodeTestFun.java index f44b4618f5..0bc0267a5a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseContextNodeTestFun.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseContextNodeTestFun.java @@ -6,18 +6,10 @@ package net.sourceforge.pmd.lang.java.rule.xpath.internal; import java.util.function.BiPredicate; -import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.Annotatable; import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.ast.TypeNode; import net.sourceforge.pmd.lang.java.types.TypeTestUtil; -import net.sourceforge.pmd.lang.rule.xpath.internal.AstElementNode; - -import net.sf.saxon.expr.XPathContext; -import net.sf.saxon.lib.ExtensionFunctionCall; -import net.sf.saxon.om.Sequence; -import net.sf.saxon.trans.XPathException; -import net.sf.saxon.value.BooleanValue; /** * XPath function {@code pmd-java:typeIs(typeName as xs:string) as xs:boolean} @@ -49,7 +41,7 @@ public class BaseContextNodeTestFun extends BaseJavaXPathFun } @Override - public Type getResultType(Type[] suppliedArgumentTypes) { + public Type getResultType() { return Type.SINGLE_BOOLEAN; } @@ -59,16 +51,10 @@ public class BaseContextNodeTestFun extends BaseJavaXPathFun } @Override - public ExtensionFunctionCall makeCallExpression() { - return new ExtensionFunctionCall() { - @Override - public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { - Node contextNode = ((AstElementNode) context.getContextItem()).getUnderlyingNode(); - String fullTypeName = arguments[0].head().getStringValue(); - - - return BooleanValue.get(klass.isInstance(contextNode) && checker.test(fullTypeName, (T) contextNode)); - } + public FunctionCall makeCallExpression() { + return (contextNode, arguments) -> { + String fullTypeName = arguments[0].toString(); + return klass.isInstance(contextNode) && checker.test(fullTypeName, (T) contextNode); }; } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseRewrittenFunction.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseRewrittenFunction.java index 6607f78038..0f81232666 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseRewrittenFunction.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseRewrittenFunction.java @@ -7,16 +7,7 @@ package net.sourceforge.pmd.lang.java.rule.xpath.internal; import static net.sourceforge.pmd.lang.java.rule.xpath.internal.BaseContextNodeTestFun.SINGLE_STRING_SEQ; import net.sourceforge.pmd.lang.ast.Node; -import net.sourceforge.pmd.lang.rule.xpath.internal.AstElementNode; - -import net.sf.saxon.expr.Expression; -import net.sf.saxon.expr.StaticContext; -import net.sf.saxon.expr.StringLiteral; -import net.sf.saxon.expr.XPathContext; -import net.sf.saxon.lib.ExtensionFunctionCall; -import net.sf.saxon.om.Sequence; -import net.sf.saxon.trans.XPathException; -import net.sf.saxon.value.BooleanValue; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionException; /** @@ -43,7 +34,7 @@ abstract class BaseRewrittenFunction extends BaseJavaXPathFun } @Override - public Type getResultType(Type[] suppliedArgumentTypes) { + public Type getResultType() { return Type.SINGLE_BOOLEAN; } @@ -58,7 +49,7 @@ abstract class BaseRewrittenFunction extends BaseJavaXPathFun * if the arg is constant, otherwise it's anyway called before {@link #matches(Node, String, Object, boolean)} * is called. */ - protected abstract S parseArgument(String arg) throws XPathException; + protected abstract S parseArgument(String arg) throws XPathFunctionException; /** * Compute the result of the function. @@ -70,48 +61,40 @@ abstract class BaseRewrittenFunction extends BaseJavaXPathFun * * @return Whether the function matches */ - protected abstract boolean matches(N contextNode, String arg, S parsedArg, boolean isConstant) throws XPathException; + protected abstract boolean matches(N contextNode, String arg, S parsedArg, boolean isConstant) throws XPathFunctionException; @Override - public ExtensionFunctionCall makeCallExpression() { - return new ExtensionFunctionCall() { + public FunctionCall makeCallExpression() { + return new FunctionCall() { private S constantState; private boolean isConstant; @Override - public Expression rewrite(StaticContext context, Expression[] arguments) throws XPathException { - // If the argument is a string literal then we can preload - // the class, and check that it's valid at expression build time + public void staticInit(Object[] arguments) throws XPathFunctionException { + if (arguments[0] instanceof String) { + // If the argument was a string literal then we can preload + // the class, and check that it's valid at expression build time - Expression firstArg = arguments[0]; // this expression has been type checked so there is an argument - if (firstArg instanceof StringLiteral) { - String name = ((StringLiteral) firstArg).getStringValue(); - try { - constantState = parseArgument(name); - } catch (XPathException e) { - e.setIsStaticError(true); - throw e; - } + String name = (String) arguments[0]; // this expression has been type checked so there is an argument + constantState = parseArgument(name); isConstant = true; } - return null; } @Override - public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { - Node node = ((AstElementNode) context.getContextItem()).getUnderlyingNode(); + public Boolean call(Node node, Object[] arguments) throws XPathFunctionException { if (!contextNodeType.isInstance(node)) { // we could report that as an error - return BooleanValue.FALSE; + return false; } - String arg = arguments[0].head().getStringValue(); + String arg = arguments[0].toString(); S parsedArg = isConstant ? constantState : parseArgument(arg); - return BooleanValue.get(matches((N) node, arg, parsedArg, isConstant)); + return matches((N) node, arg, parsedArg, isConstant); } }; } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetCommentOnFunction.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetCommentOnFunction.java index 17380d8cc0..e4fff46a7c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetCommentOnFunction.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetCommentOnFunction.java @@ -6,16 +6,8 @@ package net.sourceforge.pmd.lang.java.rule.xpath.internal; import java.util.List; -import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.JavaComment; -import net.sourceforge.pmd.lang.rule.xpath.internal.AstElementNode; - -import net.sf.saxon.expr.XPathContext; -import net.sf.saxon.lib.ExtensionFunctionCall; -import net.sf.saxon.om.EmptyAtomicSequence; -import net.sf.saxon.om.Sequence; -import net.sf.saxon.value.StringValue; /** @@ -35,7 +27,7 @@ public class GetCommentOnFunction extends BaseJavaXPathFunction { } @Override - public Type getResultType(Type[] suppliedArgumentTypes) { + public Type getResultType() { return Type.OPTIONAL_STRING; } @@ -47,24 +39,18 @@ public class GetCommentOnFunction extends BaseJavaXPathFunction { @Override - public ExtensionFunctionCall makeCallExpression() { - return new ExtensionFunctionCall() { - @Override - public Sequence call(XPathContext context, Sequence[] arguments) { - Node contextNode = ((AstElementNode) context.getContextItem()).getUnderlyingNode(); + public FunctionCall makeCallExpression() { + return (contextNode, arguments) -> { + int codeBeginLine = contextNode.getBeginLine(); + int codeEndLine = contextNode.getEndLine(); - int codeBeginLine = contextNode.getBeginLine(); - int codeEndLine = contextNode.getEndLine(); - - List commentList = contextNode.getFirstParentOfType(ASTCompilationUnit.class).getComments(); - for (JavaComment comment : commentList) { - if (comment.getBeginLine() == codeBeginLine || comment.getEndLine() == codeEndLine) { - return new StringValue(comment.getText()); - } + List commentList = contextNode.getFirstParentOfType(ASTCompilationUnit.class).getComments(); + for (JavaComment comment : commentList) { + if (comment.getBeginLine() == codeBeginLine || comment.getEndLine() == codeEndLine) { + return comment.getText().toString(); } - return EmptyAtomicSequence.INSTANCE; } - + return null; }; } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFun.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFun.java index 3d97ef8fff..9a7d01fa2c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFun.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFun.java @@ -6,20 +6,11 @@ package net.sourceforge.pmd.lang.java.rule.xpath.internal; import java.util.Set; -import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTModifierList; import net.sourceforge.pmd.lang.java.ast.AccessNode; import net.sourceforge.pmd.lang.java.ast.JModifier; -import net.sourceforge.pmd.lang.rule.xpath.internal.AstElementNode; import net.sourceforge.pmd.util.CollectionUtil; -import net.sf.saxon.expr.XPathContext; -import net.sf.saxon.lib.ExtensionFunctionCall; -import net.sf.saxon.om.Sequence; -import net.sf.saxon.value.EmptySequence; -import net.sf.saxon.value.SequenceExtent; -import net.sf.saxon.value.StringValue; - /** * The two functions {@code modifiers} and {@code explicitModifiers}. */ @@ -36,7 +27,7 @@ public final class GetModifiersFun extends BaseJavaXPathFunction { } @Override - public Type getResultType(Type[] suppliedArgumentTypes) { + public Type getResultType() { return Type.STRING_SEQUENCE; } @@ -46,21 +37,15 @@ public final class GetModifiersFun extends BaseJavaXPathFunction { } @Override - public ExtensionFunctionCall makeCallExpression() { - return new ExtensionFunctionCall() { - @Override - public Sequence call(XPathContext context, Sequence[] arguments) { - Node contextNode = ((AstElementNode) context.getContextItem()).getUnderlyingNode(); - - if (contextNode instanceof AccessNode) { - ASTModifierList modList = ((AccessNode) contextNode).getModifiers(); - Set mods = explicit ? modList.getExplicitModifiers() - : modList.getEffectiveModifiers(); - return new SequenceExtent(CollectionUtil.map(mods, mod -> new StringValue(mod.getToken()))); - } else { - return EmptySequence.getInstance(); - } + public FunctionCall makeCallExpression() { + return (contextNode, arguments) -> { + if (contextNode instanceof AccessNode) { + ASTModifierList modList = ((AccessNode) contextNode).getModifiers(); + Set mods = explicit ? modList.getExplicitModifiers() + : modList.getEffectiveModifiers(); + return CollectionUtil.map(mods, JModifier::getToken).toArray(new String[0]); } + return null; }; } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MatchesSignatureFunction.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MatchesSignatureFunction.java index 187d100612..7e74e78026 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MatchesSignatureFunction.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MatchesSignatureFunction.java @@ -6,8 +6,7 @@ package net.sourceforge.pmd.lang.java.rule.xpath.internal; import net.sourceforge.pmd.lang.java.ast.InvocationNode; import net.sourceforge.pmd.lang.java.types.InvocationMatcher; - -import net.sf.saxon.trans.XPathException; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionException; public final class MatchesSignatureFunction extends BaseRewrittenFunction { @@ -18,16 +17,16 @@ public final class MatchesSignatureFunction extends BaseRewrittenFunction { + String metricKey = arguments[0].toString(); + return getMetric(contextNode, metricKey); }; } @@ -77,12 +61,12 @@ public final class MetricFunction extends BaseJavaXPathFunction { } - private static double getMetric(Node n, String metricKeyName) throws XPathException { + private static double getMetric(Node n, String metricKeyName) throws XPathFunctionException { LanguageMetricsProvider provider = n.getAstInfo().getLanguageProcessor().services().getLanguageMetricsProvider(); Metric metric = provider.getMetricWithName(metricKeyName); if (metric == null) { - throw new XPathException(badMetricKeyMessage(metricKeyName)); + throw new XPathFunctionException(badMetricKeyMessage(metricKeyName)); } Number computed = Metric.compute(metric, n, MetricOptions.emptyOptions()); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/NodeIsFunction.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/NodeIsFunction.java index 0b30a1f0f1..98dce04f8f 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/NodeIsFunction.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/NodeIsFunction.java @@ -5,8 +5,7 @@ package net.sourceforge.pmd.lang.java.rule.xpath.internal; import net.sourceforge.pmd.lang.java.ast.JavaNode; - -import net.sf.saxon.trans.XPathException; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionException; public final class NodeIsFunction extends BaseRewrittenFunction, JavaNode> { @@ -17,16 +16,16 @@ public final class NodeIsFunction extends BaseRewrittenFunction, JavaNo } @Override - protected Class parseArgument(String arg) throws XPathException { + protected Class parseArgument(String arg) throws XPathFunctionException { try { return Class.forName("net.sourceforge.pmd.lang.java.ast.AST" + arg); } catch (ClassNotFoundException e) { - throw new XPathException("No class named AST" + arg); + throw new XPathFunctionException("No class named AST" + arg, e); } } @Override - protected boolean matches(JavaNode contextNode, String arg, Class parsedArg, boolean isConstant) throws XPathException { + protected boolean matches(JavaNode contextNode, String arg, Class parsedArg, boolean isConstant) { return parsedArg.isInstance(contextNode); } From 304ff2ec256710d0e33ddd19cc4abfcf1b618a08 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 25 Jan 2024 13:57:30 +0100 Subject: [PATCH 15/23] [core] XPathHandler/XPathFunctionDefintion: Refactoring, javadoc --- .../xpath/impl/XPathFunctionDefinition.java | 61 ++++++- .../xpath/impl/XPathFunctionException.java | 4 + ...xonExtensionFunctionDefinitionAdapter.java | 172 ++++++++++++++++++ .../xpath/internal/SaxonXPathRuleQuery.java | 148 +-------------- .../xpath/internal/GetCommentOnFunction.java | 5 +- .../rule/xpath/internal/GetModifiersFun.java | 5 +- .../rule/xpath/internal/MetricFunction.java | 6 +- .../pmd/lang/xml/rule/SaxonDomXPathQuery.java | 5 +- 8 files changed, 247 insertions(+), 159 deletions(-) create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExtensionFunctionDefinitionAdapter.java diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java index 43ae353aec..a684f835bc 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java @@ -6,6 +6,8 @@ package net.sourceforge.pmd.lang.rule.xpath.impl; import javax.xml.namespace.QName; +import org.checkerframework.checker.nullness.qual.Nullable; + import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.ast.Node; @@ -35,37 +37,90 @@ public abstract class XPathFunctionDefinition { return qname; } + /** + * Defines the types of the function arguments. By default, an empty array is returned, indicating + * that the function takes no arguments. + */ public Type[] getArgumentTypes() { return new Type[0]; } + /** + * Defines the return type of the function. + */ public abstract Type getResultType(); /** - * If the function depends on the context item or the default XPath namespace, then + * If the function depends on the context item, then * this method should return {@code true}. + * + *

Note: Only if this is true, the contextNode parameter will be present in the + * {@link FunctionCall#call(Node, Object[])} method. */ public boolean dependsOnContext() { return false; } + /** + * Create a call on this function. This method is called, when a function call + * is found in the XPath expression. + */ public abstract FunctionCall makeCallExpression(); + /** + * Supported types of a custom XPath function. These can be used as {@link #getResultType() result types} + * or {@link #getArgumentTypes() argument types}. + */ public enum Type { + /** Represents {@link String}. */ SINGLE_STRING, + /** Represents {@link Boolean}. */ SINGLE_BOOLEAN, + /** Represents {@link Integer}. */ SINGLE_INTEGER, + /** Represents any node. Usually used as an argument type. */ SINGLE_ELEMENT, + /** Represents a {@link java.util.List} of {@link String}, potentially empty. */ STRING_SEQUENCE, + /** Represents a {@link java.util.Optional} {@link String}. */ OPTIONAL_STRING, + /** Represents a {@link java.util.Optional} {@link Double}. */ OPTIONAL_DECIMAL, } + /** + * Provides the actual implementation of a custom XPath function. + */ public interface FunctionCall { + /** + * This method is called at runtime to evaluate the XPath function expression. + * + * @param contextNode the context node or {@code null}, if this function doesn't depend on the context. + * See {@link XPathFunctionDefinition#dependsOnContext()}. + * @param arguments The arguments converted as the corresponding java types. + * See {@link XPathFunctionDefinition#getArgumentTypes()}. + * @return The result of the function. This should be the corresponding java type of + * {@link XPathFunctionDefinition#getResultType()}. + * @throws XPathFunctionException when any problem during evaluation occurs, like invalid arguments. + */ + Object call(@Nullable Node contextNode, Object[] arguments) throws XPathFunctionException; + + /** + * This is called once before the function is evaluated. It can be used to optimize the + * implementation by doing expensive operations only once and cache the result. + * This is useful, if the argument of the function is of type {@link String} and is provided + * as a String literal in the XPath expression. + * + *

This is an optional step. The default implementation does nothing. + * + * @param arguments The arguments converted as the corresponding java types. + * See {@link XPathFunctionDefinition#getArgumentTypes()}. + * Note: This array might contain {@code null} elements, if the values are + * not known yet because they are dynamic. Only literal values are available. + * @throws XPathFunctionException when any problem during initialization occurs, like invalid arguments. + */ default void staticInit(Object[] arguments) throws XPathFunctionException { // default implementation does nothing } - - Object call(Node contextNode, Object[] arguments) throws XPathFunctionException; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionException.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionException.java index 5bddd4001d..11704594af 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionException.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionException.java @@ -4,6 +4,10 @@ package net.sourceforge.pmd.lang.rule.xpath.impl; +/** + * Indicates a problem during the execution of a custom + * XPath function. + */ public class XPathFunctionException extends Exception { public XPathFunctionException(String message) { super(message); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExtensionFunctionDefinitionAdapter.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExtensionFunctionDefinitionAdapter.java new file mode 100644 index 0000000000..31808f9fab --- /dev/null +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExtensionFunctionDefinitionAdapter.java @@ -0,0 +1,172 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.rule.xpath.internal; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import javax.xml.namespace.QName; + +import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionDefinition; +import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionException; + +import net.sf.saxon.expr.Expression; +import net.sf.saxon.expr.StaticContext; +import net.sf.saxon.expr.StringLiteral; +import net.sf.saxon.expr.XPathContext; +import net.sf.saxon.lib.ExtensionFunctionCall; +import net.sf.saxon.lib.ExtensionFunctionDefinition; +import net.sf.saxon.om.EmptyAtomicSequence; +import net.sf.saxon.om.Sequence; +import net.sf.saxon.om.StructuredQName; +import net.sf.saxon.pattern.NodeKindTest; +import net.sf.saxon.trans.XPathException; +import net.sf.saxon.value.BigDecimalValue; +import net.sf.saxon.value.BooleanValue; +import net.sf.saxon.value.EmptySequence; +import net.sf.saxon.value.Int64Value; +import net.sf.saxon.value.SequenceExtent; +import net.sf.saxon.value.SequenceType; +import net.sf.saxon.value.StringValue; + +/** + * Converts PMD's {@link XPathFunctionDefinition} into Saxon's {@link ExtensionFunctionDefinition}. + */ +public class SaxonExtensionFunctionDefinitionAdapter extends ExtensionFunctionDefinition { + private static final SequenceType SINGLE_ELEMENT_SEQUENCE_TYPE = NodeKindTest.ELEMENT.one(); + + private final XPathFunctionDefinition definition; + + public SaxonExtensionFunctionDefinitionAdapter(XPathFunctionDefinition definition) { + this.definition = definition; + } + + private SequenceType convertToSequenceType(XPathFunctionDefinition.Type type) { + switch (type) { + case SINGLE_STRING: return SequenceType.SINGLE_STRING; + case SINGLE_BOOLEAN: return SequenceType.SINGLE_BOOLEAN; + case SINGLE_ELEMENT: return SINGLE_ELEMENT_SEQUENCE_TYPE; + case SINGLE_INTEGER: return SequenceType.SINGLE_INTEGER; + case STRING_SEQUENCE: return SequenceType.STRING_SEQUENCE; + case OPTIONAL_STRING: return SequenceType.OPTIONAL_STRING; + case OPTIONAL_DECIMAL: return SequenceType.OPTIONAL_DECIMAL; + default: + throw new UnsupportedOperationException("Type " + type + " is not supported"); + } + } + + private SequenceType[] convertToSequenceTypes(XPathFunctionDefinition.Type[] types) { + SequenceType[] result = new SequenceType[types.length]; + for (int i = 0; i < types.length; i++) { + result[i] = convertToSequenceType(types[i]); + } + return result; + } + + @Override + public StructuredQName getFunctionQName() { + QName qName = definition.getQName(); + return new StructuredQName(qName.getPrefix(), qName.getNamespaceURI(), qName.getLocalPart()); + } + + @Override + public SequenceType[] getArgumentTypes() { + return convertToSequenceTypes(definition.getArgumentTypes()); + } + + @Override + public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) { + return convertToSequenceType(definition.getResultType()); + } + + @Override + public boolean dependsOnFocus() { + return definition.dependsOnContext(); + } + + @Override + public ExtensionFunctionCall makeCallExpression() { + XPathFunctionDefinition.FunctionCall call = definition.makeCallExpression(); + return new ExtensionFunctionCall() { + @Override + public Expression rewrite(StaticContext context, Expression[] arguments) throws XPathException { + Object[] convertedArguments = new Object[definition.getArgumentTypes().length]; + for (int i = 0; i < convertedArguments.length; i++) { + if (arguments[i] instanceof StringLiteral) { + convertedArguments[i] = ((StringLiteral) arguments[i]).getStringValue(); + } + } + try { + call.staticInit(convertedArguments); + } catch (XPathFunctionException e) { + XPathException xPathException = new XPathException(e); + xPathException.setIsStaticError(true); + throw xPathException; + } + return null; + } + + @Override + public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { + Node contextNode = null; + if (definition.dependsOnContext()) { + contextNode = XPathElementToNodeHelper.itemToNode(context.getContextItem()); + } + Object[] convertedArguments = new Object[definition.getArgumentTypes().length]; + for (int i = 0; i < convertedArguments.length; i++) { + switch (definition.getArgumentTypes()[i]) { + case SINGLE_STRING: + convertedArguments[i] = arguments[i].head().getStringValue(); + break; + case SINGLE_ELEMENT: + convertedArguments[i] = arguments[i].head(); + break; + default: + throw new UnsupportedOperationException("Don't know how to convert argument type " + definition.getArgumentTypes()[i]); + } + } + + + Object result = null; + try { + result = call.call(contextNode, convertedArguments); + } catch (XPathFunctionException e) { + throw new XPathException(e); + } + Sequence convertedResult = null; + switch (definition.getResultType()) { + case SINGLE_BOOLEAN: + convertedResult = BooleanValue.get((Boolean) result); + break; + case SINGLE_INTEGER: + convertedResult = Int64Value.makeIntegerValue((Integer) result); + break; + case SINGLE_STRING: + convertedResult = new StringValue((String) result); + break; + case OPTIONAL_STRING: + convertedResult = result instanceof Optional && ((Optional) result).isPresent() + ? new StringValue(((Optional) result).get()) + : EmptyAtomicSequence.INSTANCE; + break; + case STRING_SEQUENCE: + convertedResult = result instanceof List + ? new SequenceExtent(((List) result).stream().map(StringValue::new).collect(Collectors.toList())) + : EmptySequence.getInstance(); + break; + case OPTIONAL_DECIMAL: + convertedResult = result instanceof Optional && ((Optional) result).isPresent() + ? new BigDecimalValue(((Optional) result).get()) + : EmptySequence.getInstance(); + break; + default: + throw new UnsupportedOperationException("Don't know how to convert result type " + definition.getResultType()); + } + return convertedResult; + } + }; + } +} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java index b8c5e89011..60945da303 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java @@ -5,14 +5,11 @@ package net.sourceforge.pmd.lang.rule.xpath.internal; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; -import javax.xml.namespace.QName; import org.apache.commons.lang3.exception.ContextedRuntimeException; import org.slf4j.Logger; @@ -24,7 +21,6 @@ import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException; import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase; import net.sourceforge.pmd.lang.rule.xpath.XPathVersion; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionDefinition; -import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionException; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathHandler; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.util.DataMap; @@ -33,33 +29,19 @@ import net.sourceforge.pmd.util.DataMap.SimpleDataKey; import net.sf.saxon.Configuration; import net.sf.saxon.expr.Expression; import net.sf.saxon.expr.LocalVariableReference; -import net.sf.saxon.expr.StaticContext; -import net.sf.saxon.expr.StringLiteral; -import net.sf.saxon.expr.XPathContext; -import net.sf.saxon.lib.ExtensionFunctionCall; import net.sf.saxon.lib.ExtensionFunctionDefinition; import net.sf.saxon.lib.NamespaceConstant; import net.sf.saxon.om.AtomicSequence; -import net.sf.saxon.om.EmptyAtomicSequence; import net.sf.saxon.om.Item; import net.sf.saxon.om.NamePool; -import net.sf.saxon.om.Sequence; import net.sf.saxon.om.SequenceIterator; import net.sf.saxon.om.StructuredQName; -import net.sf.saxon.pattern.NodeKindTest; import net.sf.saxon.sxpath.IndependentContext; import net.sf.saxon.sxpath.XPathDynamicContext; import net.sf.saxon.sxpath.XPathEvaluator; import net.sf.saxon.sxpath.XPathExpression; import net.sf.saxon.sxpath.XPathVariable; import net.sf.saxon.trans.XPathException; -import net.sf.saxon.value.BigDecimalValue; -import net.sf.saxon.value.BooleanValue; -import net.sf.saxon.value.EmptySequence; -import net.sf.saxon.value.Int64Value; -import net.sf.saxon.value.SequenceExtent; -import net.sf.saxon.value.SequenceType; -import net.sf.saxon.value.StringValue; /** @@ -218,7 +200,7 @@ public class SaxonXPathRuleQuery { } for (XPathFunctionDefinition xpathFun : xPathHandler.getRegisteredExtensionFunctions()) { - ExtensionFunctionDefinition fun = convertAbstractXPathFunctionDefinition(xpathFun); + ExtensionFunctionDefinition fun = new SaxonExtensionFunctionDefinitionAdapter(xpathFun); StructuredQName qname = fun.getFunctionQName(); staticCtx.declareNamespace(qname.getPrefix(), qname.getURI()); this.configuration.registerExtensionFunction(fun); @@ -303,132 +285,4 @@ public class SaxonXPathRuleQuery { return local; } } - - public static ExtensionFunctionDefinition convertAbstractXPathFunctionDefinition(XPathFunctionDefinition definition) { - final SequenceType SINGLE_ELEMENT_SEQUENCE_TYPE = NodeKindTest.ELEMENT.one(); - - return new ExtensionFunctionDefinition() { - private SequenceType convertToSequenceType(XPathFunctionDefinition.Type type) { - switch (type) { - case SINGLE_STRING: return SequenceType.SINGLE_STRING; - case SINGLE_BOOLEAN: return SequenceType.SINGLE_BOOLEAN; - case SINGLE_ELEMENT: return SINGLE_ELEMENT_SEQUENCE_TYPE; - case SINGLE_INTEGER: return SequenceType.SINGLE_INTEGER; - case STRING_SEQUENCE: return SequenceType.STRING_SEQUENCE; - case OPTIONAL_STRING: return SequenceType.OPTIONAL_STRING; - case OPTIONAL_DECIMAL: return SequenceType.OPTIONAL_DECIMAL; - default: - throw new UnsupportedOperationException("Type " + type + " is not supported"); - } - } - - private SequenceType[] convertToSequenceTypes(XPathFunctionDefinition.Type[] types) { - SequenceType[] result = new SequenceType[types.length]; - for (int i = 0; i < types.length; i++) { - result[i] = convertToSequenceType(types[i]); - } - return result; - } - - @Override - public StructuredQName getFunctionQName() { - QName qName = definition.getQName(); - return new StructuredQName(qName.getPrefix(), qName.getNamespaceURI(), qName.getLocalPart()); - } - - @Override - public SequenceType[] getArgumentTypes() { - return convertToSequenceTypes(definition.getArgumentTypes()); - } - - @Override - public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) { - return convertToSequenceType(definition.getResultType()); - } - - @Override - public boolean dependsOnFocus() { - return definition.dependsOnContext(); - } - - @Override - public ExtensionFunctionCall makeCallExpression() { - XPathFunctionDefinition.FunctionCall call = definition.makeCallExpression(); - return new ExtensionFunctionCall() { - @Override - public Expression rewrite(StaticContext context, Expression[] arguments) throws XPathException { - Object[] convertedArguments = new Object[definition.getArgumentTypes().length]; - for (int i = 0; i < convertedArguments.length; i++) { - if (arguments[i] instanceof StringLiteral) { - convertedArguments[i] = ((StringLiteral) arguments[i]).getStringValue(); - } - } - try { - call.staticInit(convertedArguments); - } catch (XPathFunctionException e) { - XPathException xPathException = new XPathException(e); - xPathException.setIsStaticError(true); - throw xPathException; - } - return null; - } - - @Override - public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { - Node contextNode = null; - if (definition.dependsOnContext()) { - contextNode = XPathElementToNodeHelper.itemToNode(context.getContextItem()); - } - Object[] convertedArguments = new Object[definition.getArgumentTypes().length]; - for (int i = 0; i < convertedArguments.length; i++) { - switch (definition.getArgumentTypes()[i]) { - case SINGLE_STRING: - convertedArguments[i] = arguments[i].head().getStringValue(); - break; - case SINGLE_ELEMENT: - convertedArguments[i] = arguments[i].head(); - break; - default: - throw new UnsupportedOperationException("Don't know how to convert argument type " + definition.getArgumentTypes()[i]); - } - } - - - Object result = null; - try { - result = call.call(contextNode, convertedArguments); - } catch (XPathFunctionException e) { - throw new XPathException(e); - } - Sequence convertedResult = null; - switch (definition.getResultType()) { - case SINGLE_BOOLEAN: - convertedResult = BooleanValue.get((Boolean) result); - break; - case SINGLE_INTEGER: - convertedResult = Int64Value.makeIntegerValue((Integer) result); - break; - case SINGLE_STRING: - convertedResult = new StringValue((String) result); - break; - case OPTIONAL_STRING: - convertedResult = result != null ? new StringValue((String) result) : EmptyAtomicSequence.INSTANCE; - break; - case STRING_SEQUENCE: - convertedResult = result != null ? new SequenceExtent(Arrays.stream((String[]) result).map(StringValue::new).collect(Collectors.toList())) - : EmptySequence.getInstance(); - break; - case OPTIONAL_DECIMAL: - convertedResult = result != null && Double.isFinite((Double) result) ? new BigDecimalValue((Double) result) - : EmptySequence.getInstance(); - break; - default: - throw new UnsupportedOperationException("Don't know how to convert result type " + definition.getResultType()); - } - return convertedResult; - } - }; - } - }; - } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetCommentOnFunction.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetCommentOnFunction.java index e4fff46a7c..2e01ea5b19 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetCommentOnFunction.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetCommentOnFunction.java @@ -5,6 +5,7 @@ package net.sourceforge.pmd.lang.java.rule.xpath.internal; import java.util.List; +import java.util.Optional; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.JavaComment; @@ -47,10 +48,10 @@ public class GetCommentOnFunction extends BaseJavaXPathFunction { List commentList = contextNode.getFirstParentOfType(ASTCompilationUnit.class).getComments(); for (JavaComment comment : commentList) { if (comment.getBeginLine() == codeBeginLine || comment.getEndLine() == codeEndLine) { - return comment.getText().toString(); + return Optional.of(comment.getText().toString()); } } - return null; + return Optional.empty(); }; } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFun.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFun.java index 9a7d01fa2c..520ea6f23e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFun.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFun.java @@ -4,6 +4,7 @@ package net.sourceforge.pmd.lang.java.rule.xpath.internal; +import java.util.Collections; import java.util.Set; import net.sourceforge.pmd.lang.java.ast.ASTModifierList; @@ -43,9 +44,9 @@ public final class GetModifiersFun extends BaseJavaXPathFunction { ASTModifierList modList = ((AccessNode) contextNode).getModifiers(); Set mods = explicit ? modList.getExplicitModifiers() : modList.getEffectiveModifiers(); - return CollectionUtil.map(mods, JModifier::getToken).toArray(new String[0]); + return CollectionUtil.map(mods, JModifier::getToken); } - return null; + return Collections.emptyList(); }; } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MetricFunction.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MetricFunction.java index bc17bfffaa..19478d42cc 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MetricFunction.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MetricFunction.java @@ -4,6 +4,8 @@ package net.sourceforge.pmd.lang.java.rule.xpath.internal; +import java.util.Optional; + import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.metrics.LanguageMetricsProvider; import net.sourceforge.pmd.lang.metrics.Metric; @@ -61,7 +63,7 @@ public final class MetricFunction extends BaseJavaXPathFunction { } - private static double getMetric(Node n, String metricKeyName) throws XPathFunctionException { + private static Optional getMetric(Node n, String metricKeyName) throws XPathFunctionException { LanguageMetricsProvider provider = n.getAstInfo().getLanguageProcessor().services().getLanguageMetricsProvider(); Metric metric = provider.getMetricWithName(metricKeyName); @@ -70,7 +72,7 @@ public final class MetricFunction extends BaseJavaXPathFunction { } Number computed = Metric.compute(metric, n, MetricOptions.emptyOptions()); - return computed == null ? Double.NaN : computed.doubleValue(); + return computed == null ? Optional.empty() : Optional.of(computed.doubleValue()); } } diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/SaxonDomXPathQuery.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/SaxonDomXPathQuery.java index 0711cef00e..68771d2381 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/SaxonDomXPathQuery.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/SaxonDomXPathQuery.java @@ -4,8 +4,6 @@ package net.sourceforge.pmd.lang.xml.rule; -import static net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery.convertAbstractXPathFunctionDefinition; - import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -21,6 +19,7 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionDefinition; import net.sourceforge.pmd.lang.rule.xpath.impl.XPathHandler; import net.sourceforge.pmd.lang.rule.xpath.internal.DomainConversion; +import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonExtensionFunctionDefinitionAdapter; import net.sourceforge.pmd.lang.xml.ast.XmlNode; import net.sourceforge.pmd.lang.xml.ast.internal.XmlParserImpl.RootXmlNode; import net.sourceforge.pmd.properties.PropertyDescriptor; @@ -82,7 +81,7 @@ final class SaxonDomXPathQuery { for (XPathFunctionDefinition xpathFun : xpathHandler.getRegisteredExtensionFunctions()) { - ExtensionFunctionDefinition fun = convertAbstractXPathFunctionDefinition(xpathFun); + ExtensionFunctionDefinition fun = new SaxonExtensionFunctionDefinitionAdapter(xpathFun); StructuredQName qname = fun.getFunctionQName(); xpathStaticContext.declareNamespace(qname.getPrefix(), qname.getURI()); this.configuration.registerExtensionFunction(fun); From f5c4aaddf28559d743fcf37e3f97c99abc55c89d Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 25 Jan 2024 14:41:39 +0100 Subject: [PATCH 16/23] [doc] Update release notes (#4309) --- docs/pages/release_notes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 4b4f2eb93b..76ffe6f229 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -105,6 +105,7 @@ in the Migration Guide. * [#4723](https://github.com/pmd/pmd/issues/4723): \[cli] Launch fails for "bash pmd" * core * [#1027](https://github.com/pmd/pmd/issues/1027): \[core] Apply the new PropertyDescriptor<Pattern> type where applicable + * [#4309](https://github.com/pmd/pmd/issues/4309): \[core] Cleanups in XPath area * [#4674](https://github.com/pmd/pmd/issues/4674): \[core] WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass * [#4694](https://github.com/pmd/pmd/pull/4694): \[core] Fix line/col numbers in TokenMgrError * [#4717](https://github.com/pmd/pmd/issues/4717): \[core] XSLTRenderer doesn't close report file @@ -583,6 +584,7 @@ See also [Detailed Release Notes for PMD 7]({{ baseurl }}pmd_release_notes_pmd7. * [#4204](https://github.com/pmd/pmd/issues/4204): \[core] Provide a CpdAnalysis class as a programmatic entry point into CPD * [#4301](https://github.com/pmd/pmd/issues/4301): \[core] Remove deprecated property concrete classes * [#4302](https://github.com/pmd/pmd/issues/4302): \[core] Migrate Property Framework API to Java 8 + * [#4309](https://github.com/pmd/pmd/issues/4309): \[core] Cleanups in XPath area * [#4323](https://github.com/pmd/pmd/issues/4323): \[core] Refactor CPD integration * [#4353](https://github.com/pmd/pmd/pull/4353): \[core] Micro optimizations for Node API * [#4365](https://github.com/pmd/pmd/pull/4365): \[core] Improve benchmarking From d9321d70f263ab347a5c269697c8b02771de4625 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 25 Jan 2024 16:26:10 +0100 Subject: [PATCH 17/23] [core] Promote Tree Export API as stable Fixes #3905 --- docs/_data/sidebars/pmd_sidebar.yml | 6 +- .../pmd/devdocs/experimental/ast_dump.md | 119 ----------------- docs/pages/pmd/userdocs/extending/ast_dump.md | 125 ++++++++++++++++++ .../userdocs/extending/writing_rules_intro.md | 2 +- docs/pages/release_notes.md | 8 ++ docs/pages/release_notes_old.md | 2 +- .../commands/internal/TreeExportCommand.java | 2 +- .../pmd/util/treeexport/TextTreeRenderer.java | 4 +- .../treeexport/TreeExportConfiguration.java | 47 ++----- .../pmd/util/treeexport/TreeExporter.java | 11 -- .../pmd/util/treeexport/TreeRenderer.java | 2 - .../treeexport/TreeRendererDescriptor.java | 2 - .../pmd/util/treeexport/TreeRenderers.java | 4 +- .../pmd/util/treeexport/XmlTreeRenderer.java | 3 - 14 files changed, 151 insertions(+), 186 deletions(-) delete mode 100644 docs/pages/pmd/devdocs/experimental/ast_dump.md create mode 100644 docs/pages/pmd/userdocs/extending/ast_dump.md diff --git a/docs/_data/sidebars/pmd_sidebar.yml b/docs/_data/sidebars/pmd_sidebar.yml index eaccf838e4..22741aaf1b 100644 --- a/docs/_data/sidebars/pmd_sidebar.yml +++ b/docs/_data/sidebars/pmd_sidebar.yml @@ -106,6 +106,9 @@ entries: - title: Testing your rules url: /pmd_userdocs_extending_testing.html output: web, pdf + - title: Creating (XML) dump of the AST + url: /pmd_userdocs_extending_ast_dump.html + output: web, pdf - title: null output: web, pdf subfolders: @@ -552,9 +555,6 @@ entries: - title: Experimental features output: web, pdf subfolderitems: - - title: Creating (XML) dump of the AST - url: /pmd_devdocs_experimental_ast_dump.html - output: web, pdf - title: List of experimental Features url: /tag_experimental.html output: web, pdf diff --git a/docs/pages/pmd/devdocs/experimental/ast_dump.md b/docs/pages/pmd/devdocs/experimental/ast_dump.md deleted file mode 100644 index 6f85de5f63..0000000000 --- a/docs/pages/pmd/devdocs/experimental/ast_dump.md +++ /dev/null @@ -1,119 +0,0 @@ ---- -title: Creating XML dump of the AST -tags: [devdocs, experimental] -summary: Creating a XML representation of the AST allows to analyze the AST with other tools. -last_updated: January 17, 2020 (6.21.0) -permalink: pmd_devdocs_experimental_ast_dump.html ---- - -## Command line usage - -```shell -$ pmd ast-dump --help -Usage: pmd ast-dump [-Dhi] [-e=] [-f=] [--file=] - [-l=] [-P=]... -Experimental: dumps the AST of parsing source code - -D, -v, --debug, --verbose - Debug mode. - -e, --encoding= - Specifies the character set encoding of the source - code files - -f, --format= The output format. - Valid values: xml, text - --file= The file to parse and dump. - -h, --help Show this help message and exit. - -i, --read-stdin Read source from standard input. - -l, --language= - The source code language. - Valid values: apex, ecmascript, html, java, jsp, - kotlin, modelica, plsql, pom, scala, swift, vf, vm, - wsdl, xml, xsl - -P= Key-value pair defining a property for the report - format. - Supported values for each report format: - xml: - singleQuoteAttributes - Use single quotes to - delimit attribute values - Default: true - lineSeparator - Line separator to use. The default - is platform-specific. The values 'CR', 'CRLF', - 'LF', '\r', '\r\n' and '\n' can be used to - represent a carriage return, line feed and their - combination more easily. - Default: \n - renderProlog - True to output a prolog - Default: true - renderCommonAttributes - True to render attributes - like BeginLine, EndLine, etc. - Default: false - text: - onlyAsciiChars - Use only ASCII characters in the - structure - Default: false - maxLevel - Max level on which to recurse. Negative - means unbounded - Default: -1 -``` - -## Example - -```shell -$ cat Foo.java -public class Foo { - int a; -} - -$ pmd ast-dump --format xml --language java --file Foo.java > Foo.xml -$ cat Foo.xml - - - - - - - - - - - - - - - - - - - - -$ xmlstarlet select -t -c "//VariableDeclaratorId[@VariableName='a']" Foo.xml - -``` - -This example uses [xmlstarlet](http://xmlstar.sourceforge.net/) to query the xml document for any variables/fields -with the name "a". - - -## Programmatic usage - -Just parse your source code to get the AST and pass it on to the `XmlTreeRenderer`: - -```java -import java.io.IOException; -import java.io.StringReader; - -import net.sourceforge.pmd.lang.LanguageRegistry; -import net.sourceforge.pmd.lang.LanguageVersionHandler; -import net.sourceforge.pmd.lang.Parser; -import net.sourceforge.pmd.lang.ast.Node; -import net.sourceforge.pmd.util.treeexport.XmlTreeRenderer; - -public class TreeExport { - public static void main(String[] args) throws IOException { - LanguageVersionHandler java = LanguageRegistry.getLanguage("Java").getDefaultVersion().getLanguageVersionHandler(); - Parser parser = java.getParser(java.getDefaultParserOptions()); - Node root = parser.parse("foo", new StringReader("class Foo {}")); - - new XmlTreeRenderer().renderSubtree(root, System.out); - } -} -``` diff --git a/docs/pages/pmd/userdocs/extending/ast_dump.md b/docs/pages/pmd/userdocs/extending/ast_dump.md new file mode 100644 index 0000000000..7651f72e0b --- /dev/null +++ b/docs/pages/pmd/userdocs/extending/ast_dump.md @@ -0,0 +1,125 @@ +--- +title: Creating XML dump of the AST +tags: [userdocs] +summary: Creating a XML representation of the AST allows to analyze the AST with other tools. +last_updated: January 2024 (7.0.0) +permalink: pmd_userdocs_extending_ast_dump.html +--- + +## Command line usage + +```shell +$ pmd ast-dump --help +Usage: pmd ast-dump [-Dhi] [-e=] [-f=] [--file=] + [-l=] [-P=]... +Dumps the AST of parsing source code + -D, -v, --debug, --verbose + Debug mode. + -e, --encoding= + Specifies the character set encoding of the source + code files + -f, --format= The output format. + Valid values: xml, text + --file= The file to parse and dump. + -h, --help Show this help message and exit. + -i, --read-stdin Read source from standard input. + -l, --language= + The source code language. + Valid values: apex, ecmascript, html, java, jsp, + kotlin, modelica, plsql, pom, scala, swift, vf, vm, + wsdl, xml, xsl + -P= Key-value pair defining a property for the report + format. + Supported values for each report format: + xml: + singleQuoteAttributes - Use single quotes to + delimit attribute values + Default: true + lineSeparator - Line separator to use. The default + is platform-specific. The values 'CR', 'CRLF', + 'LF', '\r', '\r\n' and '\n' can be used to + represent a carriage return, line feed and their + combination more easily. + Default: \n + renderProlog - True to output a prolog + Default: true + renderCommonAttributes - True to render attributes + like BeginLine, EndLine, etc. + Default: false + text: + onlyAsciiChars - Use only ASCII characters in the + structure + Default: false + maxLevel - Max level on which to recurse. Negative + means unbounded + Default: -1 +``` + +## Example + +```shell +$ cat Foo.java +public class Foo { + int a; +} + +$ pmd ast-dump --format xml --language java --file Foo.java > Foo.xml +$ cat Foo.xml + + + + + + + + + + + + + + + + +$ xmlstarlet select -t -c "//VariableDeclaratorId[@VariableName='a']" Foo.xml + +``` + +This example uses [xmlstarlet](http://xmlstar.sourceforge.net/) to query the xml document for any variables/fields +with the name "a". + + +## Programmatic usage + +Just parse your source code to get the AST and pass it on to the `XmlTreeRenderer`: + +```java +import java.io.IOException; + +import net.sourceforge.pmd.lang.LanguageProcessor; +import net.sourceforge.pmd.lang.LanguageProcessorRegistry; +import net.sourceforge.pmd.lang.LanguageRegistry; +import net.sourceforge.pmd.lang.PmdCapableLanguage; +import net.sourceforge.pmd.lang.ast.Parser; +import net.sourceforge.pmd.lang.ast.RootNode; +import net.sourceforge.pmd.lang.ast.SemanticErrorReporter; +import net.sourceforge.pmd.lang.document.TextDocument; +import net.sourceforge.pmd.util.treeexport.XmlTreeRenderer; + +public class TreeExportTest { + public static void main(String[] args) throws IOException { + PmdCapableLanguage java = (PmdCapableLanguage) LanguageRegistry.PMD.getLanguageById("java"); + LanguageProcessor processor = java.createProcessor(java.newPropertyBundle()); + Parser parser = processor.services().getParser(); + + try (TextDocument textDocument = TextDocument.readOnlyString("class Foo { int a; }", java.getDefaultVersion()); + LanguageProcessorRegistry lpr = LanguageProcessorRegistry.singleton(processor)) { + + Parser.ParserTask task = new Parser.ParserTask(textDocument, SemanticErrorReporter.noop(), lpr); + RootNode root = parser.parse(task); + + new XmlTreeRenderer().renderSubtree(root, System.out); + } + } +} +``` diff --git a/docs/pages/pmd/userdocs/extending/writing_rules_intro.md b/docs/pages/pmd/userdocs/extending/writing_rules_intro.md index 2831e1eb0f..601bb9f301 100644 --- a/docs/pages/pmd/userdocs/extending/writing_rules_intro.md +++ b/docs/pages/pmd/userdocs/extending/writing_rules_intro.md @@ -72,7 +72,7 @@ example, all Java AST nodes extend {% jdoc java::lang.java.ast.JavaNode %}. The structure of the AST can be discovered through * the [Rule Designer](pmd_userdocs_extending_designer_reference.html#ast-inspection) - * the [AST dump feature](pmd_devdocs_experimental_ast_dump.html) + * the [AST dump feature](pmd_userdocs_extending_ast_dump.html) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index cbf09dab12..592ea40f0b 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -105,6 +105,7 @@ in the Migration Guide. * [#4723](https://github.com/pmd/pmd/issues/4723): \[cli] Launch fails for "bash pmd" * core * [#1027](https://github.com/pmd/pmd/issues/1027): \[core] Apply the new PropertyDescriptor<Pattern> type where applicable + * [#3905](https://github.com/pmd/pmd/issues/3905): \[core] Stabilize tree export API * [#4674](https://github.com/pmd/pmd/issues/4674): \[core] WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass * [#4694](https://github.com/pmd/pmd/pull/4694): \[core] Fix line/col numbers in TokenMgrError * [#4717](https://github.com/pmd/pmd/issues/4717): \[core] XSLTRenderer doesn't close report file @@ -152,6 +153,12 @@ in the Migration Guide. #### API Changes +**New API** + +The API around {%jdoc core::util.treeexport.TreeRenderer %} has been declared as stable. It was previously +experimental. It can be used via the CLI subcommand `ast-dump` or programmatically, as described +on [Creating XML dump of the AST]({{ baseurl }}pmd_userdocs_extending_ast_dump.html). + **Removed classes and methods** The following previously deprecated classes have been removed: @@ -565,6 +572,7 @@ See also [Detailed Release Notes for PMD 7]({{ baseurl }}pmd_release_notes_pmd7. * [#3815](https://github.com/pmd/pmd/issues/3815): \[core] Update Saxon HE to 10.7 * [#3893](https://github.com/pmd/pmd/pull/3893): \[core] Text documents * [#3902](https://github.com/pmd/pmd/issues/3902): \[core] Violation decorators + * [#3905](https://github.com/pmd/pmd/issues/3905): \[core] Stabilize tree export API * [#3918](https://github.com/pmd/pmd/issues/3918): \[core] Make LanguageRegistry non static * [#3919](https://github.com/pmd/pmd/issues/3919): \[core] Merge CPD and PMD language * [#3922](https://github.com/pmd/pmd/pull/3922): \[core] Better error reporting for the ruleset parser diff --git a/docs/pages/release_notes_old.md b/docs/pages/release_notes_old.md index 7cd6e5d5c3..478e5781c5 100644 --- a/docs/pages/release_notes_old.md +++ b/docs/pages/release_notes_old.md @@ -6792,7 +6792,7 @@ is of course PMD specific and language dependent. That XML file can be used to e if you don't want to use the [Designer](https://github.com/pmd/pmd-designer). This feature is experimental and might change or even be removed in the future, if it is not -useful. A short description how to use it is available under [Creating XML dump of the AST](pmd_devdocs_experimental_ast_dump.html). +useful. A short description how to use it is available under [Creating XML dump of the AST](pmd_userdocs_extending_ast_dump.html). Any feedback about it, especially about your use cases, is highly appreciated. diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/TreeExportCommand.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/TreeExportCommand.java index c4ddefebf2..0655739e5d 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/TreeExportCommand.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/TreeExportCommand.java @@ -32,7 +32,7 @@ import picocli.CommandLine.Mixin; import picocli.CommandLine.Option; import picocli.CommandLine.ParameterException; -@Command(name = "ast-dump", description = "Experimental: dumps the AST of parsing source code") +@Command(name = "ast-dump", description = "Dumps the AST of parsing source code") public class TreeExportCommand extends AbstractPmdSubcommand { static { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TextTreeRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TextTreeRenderer.java index 8d1e822672..1bf506c475 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TextTreeRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TextTreeRenderer.java @@ -6,7 +6,6 @@ package net.sourceforge.pmd.util.treeexport; import java.io.IOException; -import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.properties.AbstractPropertySource; import net.sourceforge.pmd.properties.PropertyDescriptor; @@ -43,10 +42,9 @@ import net.sourceforge.pmd.properties.PropertySource; * * * - * By default just prints the structure, like shown above. You can + * By default, just prints the structure, like shown above. You can * configure it to render nodes differently by overriding {@link #appendNodeInfoLn(Appendable, Node)}. */ -@Experimental public class TextTreeRenderer implements TreeRenderer { static final TreeRendererDescriptor DESCRIPTOR = new TreeRendererDescriptor() { 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..fb82f82e24 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 @@ -5,7 +5,7 @@ package net.sourceforge.pmd.util.treeexport; import java.nio.file.Path; -import java.nio.file.Paths; +import java.util.List; import java.util.Properties; import org.slf4j.Logger; @@ -18,9 +18,7 @@ import net.sourceforge.pmd.util.log.MessageReporter; import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter; public class TreeExportConfiguration extends AbstractConfiguration { - private static final Logger LOG = LoggerFactory.getLogger(TreeExportConfiguration.class); - protected Path reportFile; private String format = "xml"; private Language language = LanguageRegistry.PMD.getLanguageById("java"); @@ -94,43 +92,18 @@ public class TreeExportConfiguration extends AbstractConfiguration { this.messageReporter = messageReporter; } - /** - * Get the file to which the report should render. - * - * @return The file to which to render. - * @deprecated Use {@link #getReportFilePath()} - */ - @Deprecated - public String getReportFile() { - return reportFile == null ? null : reportFile.toString(); + @Override + public List getRelativizeRoots() { + throw new UnsupportedOperationException(); } - /** - * Get the file to which the report should render. - * - * @return The file to which to render. - */ - public Path getReportFilePath() { - return reportFile; + @Override + public void addRelativizeRoot(Path path) { + throw new UnsupportedOperationException(); } - /** - * Set the file to which the report should render. - * - * @param reportFile the file to set - * @deprecated Use {@link #setReportFile(Path)} - */ - @Deprecated - public void setReportFile(String reportFile) { - this.reportFile = reportFile == null ? null : Paths.get(reportFile); - } - - /** - * Set the file to which the report should render. - * - * @param reportFile the file to set - */ - public void setReportFile(Path reportFile) { - this.reportFile = reportFile; + @Override + public void addRelativizeRoots(List paths) { + throw new UnsupportedOperationException(); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExporter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExporter.java index 4e08605da9..60a7f7a52f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExporter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExporter.java @@ -12,7 +12,6 @@ import java.util.Collections; import java.util.Map.Entry; import java.util.Properties; -import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.LanguageProcessorRegistry; @@ -30,7 +29,6 @@ import net.sourceforge.pmd.lang.rule.xpath.Attribute; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertySource; -@Experimental public class TreeExporter { private final TreeExportConfiguration configuration; @@ -63,8 +61,6 @@ public class TreeExporter { } private void run(LanguageProcessorRegistry langRegistry, final TreeRenderer renderer) throws IOException { - printWarning(); - LanguageVersion langVersion = configuration.getLanguage().getDefaultVersion(); @SuppressWarnings("PMD.CloseResource") LanguageProcessor processor = langRegistry.getProcessor(configuration.getLanguage()); @@ -95,13 +91,6 @@ public class TreeExporter { return new BufferedReader(new InputStreamReader(io.stdin)); } - private void printWarning() { - io.stderr.println("-------------------------------------------------------------------------------"); - io.stderr.println("This command line utility is experimental. It might change at any time without"); - io.stderr.println("prior notice."); - io.stderr.println("-------------------------------------------------------------------------------"); - } - private T parseProperties(T bundle, Properties properties) { for (Entry prop : properties.entrySet()) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRenderer.java index 4a0a358c4d..5f6d2fc109 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRenderer.java @@ -6,7 +6,6 @@ package net.sourceforge.pmd.util.treeexport; import java.io.IOException; -import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.lang.ast.Node; /** @@ -14,7 +13,6 @@ import net.sourceforge.pmd.lang.ast.Node; * * @see XmlTreeRenderer */ -@Experimental public interface TreeRenderer { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRendererDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRendererDescriptor.java index 58a51f08b9..d5960e3af8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRendererDescriptor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRendererDescriptor.java @@ -4,7 +4,6 @@ package net.sourceforge.pmd.util.treeexport; -import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.properties.PropertySource; /** @@ -12,7 +11,6 @@ import net.sourceforge.pmd.properties.PropertySource; * * @see TreeRenderers */ -@Experimental public interface TreeRendererDescriptor { /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRenderers.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRenderers.java index 14eeffdcbf..2b6dc0399c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRenderers.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRenderers.java @@ -13,7 +13,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.xpath.Attribute; import net.sourceforge.pmd.properties.PropertyDescriptor; @@ -23,14 +22,13 @@ import net.sourceforge.pmd.util.treeexport.XmlTreeRenderer.XmlRenderingConfig; /** * Entry point to fetch and register tree renderers. This API is meant - * to be be integrated in tools that operate on tree descriptors generically. + * to be integrated in tools that operate on tree descriptors generically. * For that reason the standard descriptors provided by PMD and their * properties are not public. * * @see #findById(String) * @see #register(TreeRendererDescriptor) */ -@Experimental public final class TreeRenderers { // descriptors are test only diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/XmlTreeRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/XmlTreeRenderer.java index 212a599dec..9d1e1eacd2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/XmlTreeRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/XmlTreeRenderer.java @@ -13,7 +13,6 @@ import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; -import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.xpath.Attribute; @@ -23,7 +22,6 @@ import net.sourceforge.pmd.lang.rule.xpath.Attribute; * allows the same XPath queries to match, in theory (it would depend * on the XPath engine used I believe). */ -@Experimental public final class XmlTreeRenderer implements TreeRenderer { // See https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Name @@ -170,7 +168,6 @@ public final class XmlTreeRenderer implements TreeRenderer { /** * A strategy to parameterize an {@link XmlTreeRenderer}. */ - @Experimental public static class XmlRenderingConfig { private String indentString = " "; From a9c0ee0cd7d64d07f0dbc76d7ed724e3e3ed3b6e Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 9 Feb 2024 14:47:15 +0100 Subject: [PATCH 18/23] [doc] Fix javadoc links after moving Rule --- .../pmd/devdocs/writing_documentation.md | 26 +++++++++---------- .../userdocs/extending/writing_java_rules.md | 8 +++--- docs/pages/release_notes.md | 1 - 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/docs/pages/pmd/devdocs/writing_documentation.md b/docs/pages/pmd/devdocs/writing_documentation.md index 196823239e..53c7be347f 100644 --- a/docs/pages/pmd/devdocs/writing_documentation.md +++ b/docs/pages/pmd/devdocs/writing_documentation.md @@ -66,20 +66,20 @@ We have some additional custom liquid tags that help in writing the documentatio Here's a short overview: -| Liquid | Rendered as | -|:-------|:------------| -| `{% raw %}{% rule "java/codestyle/LinguisticNaming" %}{% endraw %}` | {% rule "java/codestyle/LinguisticNaming" %} | -| `{% raw %}{% jdoc core::Rule %}{% endraw %}` | {% jdoc core::Rule %} | -| `{% raw %}{% jdoc !q!core::Rule %}{% endraw %}` | {% jdoc !q!core::Rule %} | -| `{% raw %}{% jdoc core::Rule#setName(java.lang.String) %}{% endraw %}` | {% jdoc core::Rule#setName(java.lang.String) %} | -| `{% raw %}{% jdoc !c!core::Rule#setName(java.lang.String) %}{% endraw %}` | {% jdoc !c!core::Rule#setName(java.lang.String) %} | -| `{% raw %}{% jdoc !a!core::Rule#setName(java.lang.String) %}{% endraw %}` | {% jdoc !a!core::Rule#setName(java.lang.String) %} | -| `{% raw %}{% jdoc !ac!core::Rule#setName(java.lang.String) %}{% endraw %}` | {% jdoc !ac!core::Rule#setName(java.lang.String) %} | -| `{% raw %}{% jdoc core::properties.PropertyDescriptor %}{% endraw %}` | {% jdoc core::properties.PropertyDescriptor %} | -| `{% raw %}{% jdoc_nspace :jast java::lang.java.ast %}{% jdoc jast::ASTTypeDeclaration %}{% endraw %}` | {% jdoc_nspace :jast java::lang.java.ast %}{% jdoc jast::ASTTypeDeclaration %} | -| `{% raw %}{% jdoc_nspace :jast java::lang.java.ast %}{% jdoc_package :jast %}{% endraw %}` | {% jdoc_nspace :jast java::lang.java.ast %}{% jdoc_package :jast %} | +| Liquid | Rendered as | +|:---------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------| +| `{% raw %}{% rule "java/codestyle/LinguisticNaming" %}{% endraw %}` | {% rule "java/codestyle/LinguisticNaming" %} | +| `{% raw %}{% jdoc core::lang.rule.Rule %}{% endraw %}` | {% jdoc core::lang.rule.Rule %} | +| `{% raw %}{% jdoc !q!core::lang.rule.Rule %}{% endraw %}` | {% jdoc !q!core::lang.rule.Rule %} | +| `{% raw %}{% jdoc core::lang.rule.Rule#setName(java.lang.String) %}{% endraw %}` | {% jdoc core::lang.rule.Rule#setName(java.lang.String) %} | +| `{% raw %}{% jdoc !c!core::lang.rule.Rule#setName(java.lang.String) %}{% endraw %}` | {% jdoc !c!core::lang.rule.Rule#setName(java.lang.String) %} | +| `{% raw %}{% jdoc !a!core::lang.rule.Rule#setName(java.lang.String) %}{% endraw %}` | {% jdoc !a!core::lang.rule.Rule#setName(java.lang.String) %} | +| `{% raw %}{% jdoc !ac!core::lang.rule.Rule#setName(java.lang.String) %}{% endraw %}` | {% jdoc !ac!core::lang.rule.Rule#setName(java.lang.String) %} | +| `{% raw %}{% jdoc core::properties.PropertyDescriptor %}{% endraw %}` | {% jdoc core::properties.PropertyDescriptor %} | +| `{% raw %}{% jdoc_nspace :jast java::lang.java.ast %}{% jdoc jast::ASTTypeDeclaration %}{% endraw %}` | {% jdoc_nspace :jast java::lang.java.ast %}{% jdoc jast::ASTTypeDeclaration %} | +| `{% raw %}{% jdoc_nspace :jast java::lang.java.ast %}{% jdoc_package :jast %}{% endraw %}` | {% jdoc_nspace :jast java::lang.java.ast %}{% jdoc_package :jast %} | | `{% raw %}{% jdoc_nspace :PrD core::properties.PropertyDescriptor %}{% jdoc !ac!:PrD#uiOrder() %}{% endraw %}` | {% jdoc_nspace :PrD core::properties.PropertyDescriptor %}{% jdoc !ac!:PrD#uiOrder() %} | -| `{% raw %}{% jdoc_old core::Rule %}{% endraw %}` | {% jdoc_old core::Rule %} +| `{% raw %}{% jdoc_old core::Rule %}{% endraw %}` | {% jdoc_old core::Rule %} | For the javadoc tags, the standard PMD maven modules are already defined as namespaces, e.g. `core`, `java`, `apex`, .... diff --git a/docs/pages/pmd/userdocs/extending/writing_java_rules.md b/docs/pages/pmd/userdocs/extending/writing_java_rules.md index 6024542609..36942a298e 100644 --- a/docs/pages/pmd/userdocs/extending/writing_java_rules.md +++ b/docs/pages/pmd/userdocs/extending/writing_java_rules.md @@ -32,7 +32,7 @@ very similar for other languages. To write a rule in Java you'll have to: -1. Write a Java class that implements the interface {% jdoc core::Rule %}. Each +1. Write a Java class that implements the interface {% jdoc core::lang.rule.Rule %}. Each language implementation provides a base rule class to ease your pain, e.g. {% jdoc jrule::AbstractJavaRule %}. 2. Compile this class, linking it to PMD APIs (e.g. using PMD as a Maven dependency) @@ -247,11 +247,11 @@ For each thread, a deep copy of the rule is created. Each thread is given a different set of files to analyse. Then, for each such file and for each rule copy: -1. {% jdoc core::Rule#start(core::RuleContext) %} is called once, before parsing -2. {% jdoc core::Rule#apply(core::lang.ast.Node,core::RuleContext) %} is called with the root +1. {% jdoc core::lang.rule.Rule#start(core::RuleContext) %} is called once, before parsing +2. {% jdoc core::lang.rule.Rule#apply(core::lang.ast.Node,core::RuleContext) %} is called with the root of the AST. That method performs the AST traversal that ultimately calls visit methods. It's not called for RuleChain rules. -3. {% jdoc core::Rule#end(core::RuleContext) %} is called when the rule is done processing +3. {% jdoc core::lang.rule.Rule#end(core::RuleContext) %} is called when the rule is done processing the file ## Example projects diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 827edc8cc8..593c686fed 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -242,7 +242,6 @@ in the migration guide for details. * {%jdoc core::lang.rule.RulePriority %} * {%jdoc core::lang.rule.RuleSet %} * {%jdoc core::lang.rule.RuleSetFactory %} - * {%jdoc core::lang.rule.RuleSetFactoryCompatibility %} * {%jdoc core::lang.rule.RuleSetLoader %} * {%jdoc core::lang.rule.RuleSetLoadException %} * {%jdoc core::lang.rule.RuleSetWriter %} From 4bf2c8b980b8ab852d47b17c2d5076265ec4e4ed Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 9 Feb 2024 15:14:55 +0100 Subject: [PATCH 19/23] [compat6] Remove RuleSetFactory - not needed It was used by RuleSetLoader, but this was stripped down to do nothing anymore. See the comments in that file. --- .../net/sourceforge/pmd/RuleSetFactory.java | 754 ------------------ 1 file changed, 754 deletions(-) delete mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetFactory.java diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetFactory.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetFactory.java deleted file mode 100644 index 02f9f19931..0000000000 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSetFactory.java +++ /dev/null @@ -1,754 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -// This class has been taken from 7.0.0-SNAPSHOT -// Before removing RuleSetFactoryCompatibility (#4314) - -package net.sourceforge.pmd; - -import static net.sourceforge.pmd.util.CollectionUtil.setOf; -import static net.sourceforge.pmd.util.internal.xml.SchemaConstants.DESCRIPTION; -import static net.sourceforge.pmd.util.internal.xml.SchemaConstants.EXCLUDE; -import static net.sourceforge.pmd.util.internal.xml.SchemaConstants.EXCLUDE_PATTERN; -import static net.sourceforge.pmd.util.internal.xml.SchemaConstants.INCLUDE_PATTERN; -import static net.sourceforge.pmd.util.internal.xml.SchemaConstants.NAME; -import static net.sourceforge.pmd.util.internal.xml.SchemaConstants.PRIORITY; -import static net.sourceforge.pmd.util.internal.xml.SchemaConstants.REF; -import static net.sourceforge.pmd.util.internal.xml.SchemaConstants.RULE; -import static net.sourceforge.pmd.util.internal.xml.SchemaConstants.RULESET; - -import java.io.IOException; -import java.io.InputStream; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; -import java.util.zip.Adler32; -import java.util.zip.CheckedInputStream; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.commons.lang3.StringUtils; -import org.checkerframework.checker.nullness.qual.NonNull; -import org.checkerframework.checker.nullness.qual.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.event.Level; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; - -import net.sourceforge.pmd.RuleSet.RuleSetBuilder; -import net.sourceforge.pmd.lang.LanguageRegistry; -import net.sourceforge.pmd.lang.rule.RuleReference; -import net.sourceforge.pmd.rules.RuleFactory; -import net.sourceforge.pmd.util.ResourceLoader; -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 com.github.oowekyala.ooxml.DomUtils; -import com.github.oowekyala.ooxml.messages.NiceXmlMessageSpec; -import com.github.oowekyala.ooxml.messages.OoxmlFacade; -import com.github.oowekyala.ooxml.messages.PositionedXmlDoc; -import com.github.oowekyala.ooxml.messages.XmlException; -import com.github.oowekyala.ooxml.messages.XmlMessageHandler; -import com.github.oowekyala.ooxml.messages.XmlMessageReporterBase; -import com.github.oowekyala.ooxml.messages.XmlPosition; -import com.github.oowekyala.ooxml.messages.XmlPositioner; -import com.github.oowekyala.ooxml.messages.XmlSeverity; - -/** - * RuleSetFactory is responsible for creating RuleSet instances from XML - * content. See {@link RuleSetLoader} for configuration options and - * their defaults. - */ -final class RuleSetFactory { - - private static final Logger LOG = LoggerFactory.getLogger(RuleSetFactory.class); - - private final ResourceLoader resourceLoader; - private final LanguageRegistry languageRegistry; - private final RulePriority minimumPriority; - private final boolean warnDeprecated; - private final RuleSetFactoryCompatibility compatibilityFilter; - private final MessageReporter reporter; - private final boolean includeDeprecatedRuleReferences; - - private final Map parsedRulesets = new HashMap<>(); - - RuleSetFactory(ResourceLoader resourceLoader, - LanguageRegistry languageRegistry, - RulePriority minimumPriority, - boolean warnDeprecated, - RuleSetFactoryCompatibility compatFilter, - boolean includeDeprecatedRuleReferences, - MessageReporter reporter) { - this.resourceLoader = resourceLoader; - this.languageRegistry = Objects.requireNonNull(languageRegistry); - this.minimumPriority = minimumPriority; - this.warnDeprecated = warnDeprecated; - this.includeDeprecatedRuleReferences = includeDeprecatedRuleReferences; - - this.compatibilityFilter = compatFilter; - this.reporter = reporter; - } - - - /** - * Create a RuleSet from a RuleSetReferenceId. Priority filtering is ignored - * when loading a single Rule. The currently configured ResourceLoader is used. - * - * @param ruleSetReferenceId The RuleSetReferenceId of the RuleSet to create. - * - * @return A new RuleSet. - */ - @NonNull RuleSet createRuleSet(RuleSetReferenceId ruleSetReferenceId) { - return createRuleSet(ruleSetReferenceId, includeDeprecatedRuleReferences); - } - - private @NonNull RuleSet createRuleSet(RuleSetReferenceId ruleSetReferenceId, boolean withDeprecatedRuleReferences) - throws RuleSetLoadException { - return readDocument(ruleSetReferenceId, withDeprecatedRuleReferences); - } - - /** - * Create a Rule from a RuleSet created from a file name resource. The - * currently configured ResourceLoader is used. - *

- * Any Rules in the RuleSet other than the one being created, are _not_ - * created. Deprecated rules are _not_ ignored, so that they can be - * referenced. - * - * @param ruleSetReferenceId - * The RuleSetReferenceId of the RuleSet with the Rule to create. - * @param withDeprecatedRuleReferences - * Whether RuleReferences that are deprecated should be ignored - * or not - * @return A new Rule. - */ - private Rule createRule(RuleSetReferenceId ruleSetReferenceId, boolean withDeprecatedRuleReferences) { - RuleSetReferenceId parentRuleset = ruleSetReferenceId.getParentRulesetIfThisIsARule(); - if (parentRuleset == null) { - throw new IllegalArgumentException( - "Cannot parse a single Rule from an all Rule RuleSet reference: <" + ruleSetReferenceId + ">."); - } - // can't use computeIfAbsent as creating a ruleset may add more entries to the map. - RuleSet ruleSet = parsedRulesets.get(parentRuleset); - if (ruleSet == null) { - ruleSet = createRuleSet(ruleSetReferenceId, withDeprecatedRuleReferences); - parsedRulesets.put(ruleSetReferenceId, ruleSet); - } - return ruleSet.getRuleByName(ruleSetReferenceId.getRuleName()); - } - - /** - * Parse a ruleset node to construct a RuleSet. - * - * @param ruleSetReferenceId The RuleSetReferenceId of the RuleSet being parsed. - * @param withDeprecatedRuleReferences whether rule references that are deprecated should be ignored - * or not - * - * @return The new RuleSet. - * - * @throws RuleSetLoadException If the ruleset cannot be parsed (eg IO exception, malformed XML, validation errors) - */ - private @NonNull RuleSet readDocument(RuleSetReferenceId ruleSetReferenceId, boolean withDeprecatedRuleReferences) { - - try (CheckedInputStream inputStream = new CheckedInputStream(ruleSetReferenceId.getInputStream(resourceLoader), new Adler32())) { - if (!ruleSetReferenceId.isAbsolute()) { - throw new IllegalArgumentException( - "Cannot parse a RuleSet from a non-external reference: <" + ruleSetReferenceId + ">."); - } - - XmlMessageHandler printer = getXmlMessagePrinter(); - DocumentBuilder builder = createDocumentBuilder(); - InputSource inputSource = new InputSource(inputStream); - inputSource.setSystemId(ruleSetReferenceId.getRuleSetFileName()); - - OoxmlFacade ooxml = new OoxmlFacade() - .withPrinter(printer) - .withAnsiColors(false); - PositionedXmlDoc parsed = ooxml.parse(builder, inputSource); - - @SuppressWarnings("PMD.CloseResource") - PmdXmlReporterImpl err = new PmdXmlReporterImpl(reporter, ooxml, parsed.getPositioner()); - try { - RuleSetBuilder ruleSetBuilder = new RuleSetBuilder(inputStream.getChecksum().getValue()).withFileName(ruleSetReferenceId.getRuleSetFileName()); - - RuleSet ruleSet = parseRulesetNode(ruleSetReferenceId, withDeprecatedRuleReferences, parsed, ruleSetBuilder, err); - if (err.errCount > 0) { - // note this makes us jump to the catch branch - // these might have been non-fatal errors - String message; - if (err.errCount == 1) { - message = "An XML validation error occurred"; - } else { - message = err.errCount + " XML validation errors occurred"; - } - throw new RuleSetLoadException(ruleSetReferenceId, message); - } - return ruleSet; - } catch (Exception | Error e) { - throw e; - } - } catch (ParserConfigurationException | IOException ex) { - throw new RuleSetLoadException(ruleSetReferenceId, ex); - } - } - - - private RuleSet parseRulesetNode(RuleSetReferenceId ruleSetReferenceId, - boolean withDeprecatedRuleReferences, - PositionedXmlDoc parsed, - RuleSetBuilder builder, - PmdXmlReporter err) { - Element ruleSetElement = parsed.getDocument().getDocumentElement(); - - if (ruleSetElement.hasAttribute("name")) { - builder.withName(ruleSetElement.getAttribute("name")); - } else { - err.at(ruleSetElement).warn("RuleSet name is missing. Future versions of PMD will require it."); - builder.withName("Missing RuleSet Name"); - } - - Set rulesetReferences = new HashSet<>(); - - for (Element node : DomUtils.children(ruleSetElement)) { - String text = XmlUtil.parseTextNode(node); - if (DESCRIPTION.matchesElt(node)) { - builder.withDescription(text); - } else if (INCLUDE_PATTERN.matchesElt(node)) { - final Pattern pattern = parseRegex(node, text, err); - if (pattern == null) { - continue; - } - builder.withFileInclusions(pattern); - } else if (EXCLUDE_PATTERN.matchesElt(node)) { - final Pattern pattern = parseRegex(node, text, err); - if (pattern == null) { - continue; - } - builder.withFileExclusions(pattern); - } else if (RULE.matchesElt(node)) { - try { - parseRuleNode(ruleSetReferenceId, builder, node, withDeprecatedRuleReferences, rulesetReferences, err); - } catch (XmlException ignored) { - // already reported (it's an XmlException), error count - // was incremented so parent method will throw RuleSetLoadException. - } - } else { - err.at(node).error(XmlErrorMessages.ERR__UNEXPECTED_ELEMENT_IN, - node.getTagName(), - RULESET); - } - } - - if (!builder.hasDescription()) { - err.at(ruleSetElement).warn("RuleSet description is missing. Future versions of PMD will require it."); - builder.withDescription("Missing description"); - } - - builder.filterRulesByPriority(minimumPriority); - - return builder.build(); - } - - private Pattern parseRegex(Element node, String text, PmdXmlReporter err) { - final Pattern pattern; - try { - pattern = Pattern.compile(text); - } catch (PatternSyntaxException pse) { - err.at(node).error(pse); - return null; - } - return pattern; - } - - - private DocumentBuilder createDocumentBuilder() throws ParserConfigurationException { - final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - - try { - /* - * parser hardening - * https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Prevention_Cheat_Sheet#JAXP_DocumentBuilderFactory.2C_SAXParserFactory_and_DOM4J - */ - // This is the PRIMARY defense. If DTDs (doctypes) are disallowed, almost all XML entity attacks are prevented - // Xerces 2 only - http://xerces.apache.org/xerces2-j/features.html#disallow-doctype-decl - dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - - // If you can't completely disable DTDs, then at least do the following: - // Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-general-entities - // Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-general-entities - // JDK7+ - http://xml.org/sax/features/external-general-entities - dbf.setFeature("http://xml.org/sax/features/external-general-entities", false); - - // Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-parameter-entities - // Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-parameter-entities - // JDK7+ - http://xml.org/sax/features/external-parameter-entities - dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false); - - // Disable external DTDs as well - dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); - - // and these as well, per Timothy Morgan's 2014 paper: "XML Schema, DTD, and Entity Attacks" - dbf.setXIncludeAware(false); - dbf.setExpandEntityReferences(false); - } catch (final ParserConfigurationException e) { - // an unsupported feature... too bad, but won't fail execution due to this - LOG.warn("Ignored unsupported XML Parser Feature for parsing rulesets", e); - } - - return dbf.newDocumentBuilder(); - } - - /** - * Parse a rule node. - * - * @param ruleSetReferenceId The RuleSetReferenceId of the RuleSet being parsed. - * @param ruleSetBuilder The RuleSet being constructed. - * @param ruleNode Must be a rule element node. - * @param withDeprecatedRuleReferences whether rule references that are deprecated should be ignored - * or not - * @param rulesetReferences keeps track of already processed complete ruleset references in order to log - * a warning - */ - private void parseRuleNode(RuleSetReferenceId ruleSetReferenceId, - RuleSetBuilder ruleSetBuilder, - Element ruleNode, - boolean withDeprecatedRuleReferences, - Set rulesetReferences, - PmdXmlReporter err) { - if (REF.hasAttribute(ruleNode)) { - String ref = REF.getAttributeOrThrow(ruleNode, err); - RuleSetReferenceId refId = parseReferenceAndWarn(ref, REF.getAttributeNode(ruleNode), err); - if (refId != null) { - if (refId.isAllRules()) { - parseRuleSetReferenceNode(ruleSetBuilder, ruleNode, ref, refId, rulesetReferences, err); - } else { - parseRuleReferenceNode(ruleSetReferenceId, ruleSetBuilder, ruleNode, ref, refId, withDeprecatedRuleReferences, err); - } - return; - } - } - parseSingleRuleNode(ruleSetReferenceId, ruleSetBuilder, ruleNode, err); - } - - /** - * Parse a rule node as an RuleSetReference for all Rules. Every Rule from - * the referred to RuleSet will be added as a RuleReference except for those - * explicitly excluded, below the minimum priority threshold for this - * RuleSetFactory, or which are deprecated. - * - * @param ruleSetBuilder - * The RuleSet being constructed. - * @param ruleElement - * Must be a rule element node. - * @param ref - * The RuleSet reference. - * @param rulesetReferences keeps track of already processed complete ruleset references in order to log a warning - */ - private void parseRuleSetReferenceNode(RuleSetBuilder ruleSetBuilder, - Element ruleElement, - String ref, - RuleSetReferenceId ruleSetReferenceId, Set rulesetReferences, - PmdXmlReporter err) { - RulePriority priority = null; - Map excludedRulesCheck = new HashMap<>(); - for (Element child : XmlUtil.getElementChildrenList(ruleElement)) { - if (EXCLUDE.matchesElt(child)) { - String excludedRuleName; - try { - excludedRuleName = NAME.getAttributeOrThrow(child, err); - } catch (XmlException ignored) { - // has been reported - continue; - } - excludedRuleName = compatibilityFilter.applyExclude(ref, excludedRuleName, this.warnDeprecated); - if (excludedRuleName != null) { - excludedRulesCheck.put(excludedRuleName, child); - } - } else if (PRIORITY.matchesElt(child)) { - priority = RuleFactory.parsePriority(err, child); - } else { - XmlUtil.reportIgnoredUnexpectedElt(ruleElement, child, setOf(EXCLUDE, PRIORITY), err); - } - } - final RuleSetReference ruleSetReference = new RuleSetReference(ref, true, excludedRulesCheck.keySet()); - - // load the ruleset with minimum priority low, so that we get all rules, to be able to exclude any rule - // minimum priority will be applied again, before constructing the final ruleset - RuleSetFactory ruleSetFactory = toLoader().filterAbovePriority(RulePriority.LOW).warnDeprecated(false).toFactory(); - RuleSet otherRuleSet = ruleSetFactory.createRuleSet(ruleSetReferenceId); - List potentialRules = new ArrayList<>(); - int countDeprecated = 0; - for (Rule rule : otherRuleSet.getRules()) { - excludedRulesCheck.remove(rule.getName()); - if (!ruleSetReference.getExcludes().contains(rule.getName())) { - RuleReference ruleReference = new RuleReference(rule, ruleSetReference); - // override the priority - if (priority != null) { - ruleReference.setPriority(priority); - } - - if (rule.isDeprecated()) { - countDeprecated++; - } - potentialRules.add(ruleReference); - } - } - - boolean rulesetDeprecated = false; - if (!potentialRules.isEmpty() && potentialRules.size() == countDeprecated) { - // all rules in the ruleset have been deprecated - the ruleset itself is considered to be deprecated - rulesetDeprecated = true; - err.at(REF.getAttributeNode(ruleElement)) - .warn("The RuleSet {0} has been deprecated and will be removed in PMD {1}", - ref, PMDVersion.getNextMajorRelease()); - } - - for (RuleReference r : potentialRules) { - if (rulesetDeprecated || !r.getRule().isDeprecated()) { - // add the rule, if either the ruleset itself is deprecated (then we add all rules) - // or if the rule is not deprecated (in that case, the ruleset might contain deprecated as well - // as valid rules) - ruleSetBuilder.addRuleIfNotExists(r); - } - } - - if (!excludedRulesCheck.isEmpty()) { - excludedRulesCheck.forEach( - (name, elt) -> - err.at(elt).warn("Exclude pattern ''{0}'' did not match any rule in ruleset ''{1}''", name, ref)); - } - - if (rulesetReferences.contains(ref)) { - err.at(ruleElement).warn("The ruleset {0} is referenced multiple times in ruleset ''{1}''", ref, ruleSetBuilder.getName()); - } - rulesetReferences.add(ref); - } - - private RuleSetReferenceId parseReferenceAndWarn(String ref, - Node xmlPlace, - PmdXmlReporter err) { - ref = compatibilityFilter.applyRef(ref, this.warnDeprecated); - if (ref == null) { - err.at(xmlPlace).warn("Rule reference references a deleted rule, ignoring"); - return null; // deleted rule - } - List references = RuleSetReferenceId.parse(ref); - if (references.size() > 1 && warnDeprecated) { - err.at(xmlPlace).warn("Using a comma separated list as a ref attribute is deprecated. " - + "All references but the first are ignored."); - } else if (references.isEmpty()) { - err.at(xmlPlace).warn("Empty ref attribute"); - return null; - } - return references.get(0); - } - - /** - * Parse a rule node as a single Rule. The Rule has been fully defined - * within the context of the current RuleSet. - * - * @param ruleSetReferenceId The RuleSetReferenceId of the RuleSet being parsed. - * @param ruleSetBuilder The RuleSet being constructed. - * @param ruleNode Must be a rule element node. - * @param err Error reporter - */ - private void parseSingleRuleNode(RuleSetReferenceId ruleSetReferenceId, - RuleSetBuilder ruleSetBuilder, - Element ruleNode, - PmdXmlReporter err) { - - // Stop if we're looking for a particular Rule, and this element is not - // it. - if (StringUtils.isNotBlank(ruleSetReferenceId.getRuleName()) - && !isRuleName(ruleNode, ruleSetReferenceId.getRuleName())) { - return; - } - Rule rule = new RuleFactory(resourceLoader, languageRegistry).buildRule(ruleNode, err); - rule.setRuleSetName(ruleSetBuilder.getName()); - - if (warnDeprecated && StringUtils.isBlank(ruleNode.getAttribute("language"))) { - err.at(ruleNode).warn( - "Rule {0}/{1} does not mention attribute language='{2}'," - + " please mention it explicitly to be compatible with PMD 7", - ruleSetReferenceId.getRuleSetFileName(), rule.getName(), - rule.getLanguage().getTerseName()); - } - - ruleSetBuilder.addRule(rule); - } - - - /** - * Parse a rule node as a RuleReference. A RuleReference is a single Rule - * which comes from another RuleSet with some of it's attributes potentially - * overridden. - * - * @param ruleSetReferenceId The RuleSetReferenceId of the RuleSet being parsed. - * @param ruleSetBuilder The RuleSet being constructed. - * @param ruleNode Must be a rule element node. - * @param ref A reference to a Rule. - * @param withDeprecatedRuleReferences whether rule references that are deprecated should be ignored - * @param err Error reporter - */ - private void parseRuleReferenceNode(RuleSetReferenceId ruleSetReferenceId, - RuleSetBuilder ruleSetBuilder, - Element ruleNode, - String ref, - RuleSetReferenceId otherRuleSetReferenceId, - boolean withDeprecatedRuleReferences, - PmdXmlReporter err) { - - // Stop if we're looking for a particular Rule, and this element is not - // it. - if (StringUtils.isNotBlank(ruleSetReferenceId.getRuleName()) - && !isRuleName(ruleNode, ruleSetReferenceId.getRuleName())) { - return; - } - - // load the ruleset with minimum priority low, so that we get all rules, to be able to exclude any rule - // minimum priority will be applied again, before constructing the final ruleset - RuleSetFactory ruleSetFactory = toLoader().filterAbovePriority(RulePriority.LOW).warnDeprecated(false).toFactory(); - - boolean isSameRuleSet = false; - if (!otherRuleSetReferenceId.isAbsolute() - && containsRule(ruleSetReferenceId, otherRuleSetReferenceId.getRuleName())) { - otherRuleSetReferenceId = new RuleSetReferenceId(ref, ruleSetReferenceId); - isSameRuleSet = true; - } else if (otherRuleSetReferenceId.isAbsolute() - && otherRuleSetReferenceId.getRuleSetFileName().equals(ruleSetReferenceId.getRuleSetFileName())) { - otherRuleSetReferenceId = new RuleSetReferenceId(otherRuleSetReferenceId.getRuleName(), ruleSetReferenceId); - isSameRuleSet = true; - } - // do not ignore deprecated rule references - Rule referencedRule = ruleSetFactory.createRule(otherRuleSetReferenceId, true); - - if (referencedRule == null) { - throw err.at(ruleNode).error( - "Unable to find referenced rule {0}" - + "; perhaps the rule name is misspelled?", - otherRuleSetReferenceId.getRuleName()); - } - - if (warnDeprecated && referencedRule.isDeprecated()) { - if (referencedRule instanceof RuleReference) { - RuleReference ruleReference = (RuleReference) referencedRule; - err.at(ruleNode).warn( - "Use Rule name {0}/{1} instead of the deprecated Rule name {2}. PMD {3}" - + " will remove support for this deprecated Rule name usage.", - ruleReference.getRuleSetReference().getRuleSetFileName(), - ruleReference.getOriginalName(), otherRuleSetReferenceId, - PMDVersion.getNextMajorRelease()); - } else { - err.at(ruleNode).warn( - "Discontinue using Rule name {0} as it is scheduled for removal from PMD." - + " PMD {1} will remove support for this Rule.", - otherRuleSetReferenceId, PMDVersion.getNextMajorRelease()); - } - } - - RuleSetReference ruleSetReference = new RuleSetReference(otherRuleSetReferenceId.getRuleSetFileName(), false); - - RuleReference ruleReference; - try { - ruleReference = new RuleFactory(resourceLoader, languageRegistry).decorateRule(referencedRule, ruleSetReference, ruleNode, err); - } catch (XmlException e) { - throw err.at(ruleNode).error(e, "Error while parsing rule reference"); - } - - if (warnDeprecated && ruleReference.isDeprecated() && !isSameRuleSet) { - err.at(ruleNode).warn( - "Use Rule name {0}/{1} instead of the deprecated Rule name {2}/{3}. PMD {4}" - + " will remove support for this deprecated Rule name usage.", - ruleReference.getRuleSetReference().getRuleSetFileName(), - ruleReference.getOriginalName(), - ruleSetReferenceId.getRuleSetFileName(), - ruleReference.getName(), - PMDVersion.getNextMajorRelease()); - } - - if (withDeprecatedRuleReferences || !isSameRuleSet || !ruleReference.isDeprecated()) { - Rule existingRule = ruleSetBuilder.getExistingRule(ruleReference); - if (existingRule instanceof RuleReference) { - RuleReference existingRuleReference = (RuleReference) existingRule; - // the only valid use case is: the existing rule does not override anything yet - // which means, it is a plain reference. And the new reference overrides. - // for all other cases, we should log a warning - if (existingRuleReference.hasOverriddenAttributes() || !ruleReference.hasOverriddenAttributes()) { - err.at(ruleNode).warn( - "The rule {0} is referenced multiple times in ruleset ''{1}''. " - + "Only the last rule configuration is used.", - ruleReference.getName(), - ruleSetBuilder.getName()); - } - } - - ruleSetBuilder.addRuleReplaceIfExists(ruleReference); - } - } - - - /** - * Check whether the given ruleName is contained in the given ruleset. - * - * @param ruleSetReferenceId the ruleset to check - * @param ruleName the rule name to search for - * - * @return {@code true} if the ruleName exists - */ - private boolean containsRule(RuleSetReferenceId ruleSetReferenceId, String ruleName) { - // TODO: avoid reloading the ruleset once again - boolean found = false; - try (InputStream ruleSet = ruleSetReferenceId.getInputStream(resourceLoader)) { - DocumentBuilder builder = createDocumentBuilder(); - Document document = builder.parse(ruleSet); - Element ruleSetElement = document.getDocumentElement(); - - NodeList rules = ruleSetElement.getElementsByTagName("rule"); - for (int i = 0; i < rules.getLength(); i++) { - Element rule = (Element) rules.item(i); - if (rule.hasAttribute("name") && rule.getAttribute("name").equals(ruleName)) { - found = true; - break; - } - } - } catch (Exception e) { - throw new RuleSetLoadException(ruleSetReferenceId, e); - } - - return found; - } - - /** - * Determine if the specified rule element will represent a Rule with the - * given name. - * - * @param ruleElement The rule element. - * @param ruleName The Rule name. - * - * @return {@code true} if the Rule would have the given name, {@code false} otherwise. - */ - private boolean isRuleName(Element ruleElement, String ruleName) { - if (ruleElement.hasAttribute("name")) { - return ruleElement.getAttribute("name").equals(ruleName); - } else if (ruleElement.hasAttribute("ref")) { - RuleSetReferenceId ruleSetReferenceId = RuleSetReferenceId.parse(ruleElement.getAttribute("ref")).get(0); - return ruleSetReferenceId.getRuleName() != null && ruleSetReferenceId.getRuleName().equals(ruleName); - } else { - return false; - } - } - - - /** - * Create a new {@link RuleSetLoader} with the same config as this - * factory. This is a transitional API. - */ - public RuleSetLoader toLoader() { - return new RuleSetLoader().loadResourcesWith(resourceLoader) - .filterAbovePriority(minimumPriority) - .warnDeprecated(warnDeprecated) - .enableCompatibility(compatibilityFilter != null) - .includeDeprecatedRuleReferences(includeDeprecatedRuleReferences); - } - - private @NonNull XmlMessageHandler getXmlMessagePrinter() { - return entry -> { - Level level = entry.getSeverity() == XmlSeverity.WARNING ? Level.WARN : Level.ERROR; - String quotedText = StringUtil.quoteMessageFormat(entry.toString()); - reporter.logEx(level, quotedText, new Object[0], entry.getCause()); - }; - } - - private static final class PmdXmlReporterImpl - extends XmlMessageReporterBase - implements PmdXmlReporter { - - private final MessageReporter pmdReporter; - private int errCount; - - PmdXmlReporterImpl(MessageReporter pmdReporter, OoxmlFacade ooxml, XmlPositioner positioner) { - super(ooxml, positioner); - this.pmdReporter = pmdReporter; - } - - @Override - protected MessageReporter create2ndStage(XmlPosition position, XmlPositioner positioner) { - return new MessageReporter() { - @Override - public boolean isLoggable(Level level) { - return pmdReporter.isLoggable(level); - } - - - @Override - public void log(Level level, String message, Object... formatArgs) { - logEx(level, message, formatArgs, null); - } - - @Override - public void logEx(Level level, String message, Object[] formatArgs, @Nullable Throwable error) { - newException(level, error, message, formatArgs); - } - - @Override - public XmlException error(@Nullable Throwable cause, @Nullable String contextMessage, Object... formatArgs) { - return newException(Level.ERROR, cause, contextMessage, formatArgs); - } - - @Override - public XmlException newException(Level level, Throwable cause, String message, Object... formatArgs) { - XmlSeverity severity; - switch (level) { - case WARN: - severity = XmlSeverity.WARNING; - break; - case ERROR: - errCount++; - severity = XmlSeverity.ERROR; - break; - default: - throw new IllegalArgumentException("unexpected level " + level); - } - - if (message == null && formatArgs.length != 0) { - throw new IllegalArgumentException("Cannot pass format arguments for null message"); - } - - String actualMessage = message == null ? cause.getMessage() - : MessageFormat.format(message, formatArgs); - NiceXmlMessageSpec spec = - new NiceXmlMessageSpec(position, actualMessage) - .withSeverity(severity) - .withCause(cause); - String fullMessage = ooxml.getFormatter().formatSpec(ooxml, spec, positioner); - XmlException ex = new XmlException(spec, fullMessage); - ooxml.getPrinter().accept(ex); // spec of newException is also to log. - return ex; - } - - @Override - public int numErrors() { - return pmdReporter.numErrors(); - } - }; - } - } - -} From a2f2720f77155e8f2ba37f1fa008eebc77c8b5cc Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 9 Feb 2024 15:41:36 +0100 Subject: [PATCH 20/23] Fix imports --- .../src/main/java/net/sourceforge/pmd/lang/rule/Rule.java | 1 - .../src/main/java/net/sourceforge/pmd/reporting/Report.java | 1 - .../java/net/sourceforge/pmd/reporting/RuleViolation.java | 1 - .../net/sourceforge/pmd/reporting/ViolationSuppressor.java | 1 - .../net/sourceforge/pmd/renderers/TextColorRendererTest.java | 4 ++-- .../java/net/sourceforge/pmd/reporting/ReportTestUtil.java | 3 --- 6 files changed, 2 insertions(+), 9 deletions(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/Rule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/Rule.java index f1f392acc3..6123fc07bd 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/Rule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/Rule.java @@ -8,7 +8,6 @@ import java.util.List; import java.util.Optional; import java.util.regex.Pattern; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.LanguageVersion; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/Report.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/Report.java index f9610cfc5d..c79d9fd018 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/Report.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/Report.java @@ -16,7 +16,6 @@ import java.util.function.Consumer; import java.util.function.Predicate; import net.sourceforge.pmd.PmdAnalysis; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.annotation.DeprecatedUntil700; import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.annotation.InternalApi; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleViolation.java index 54050b8e2f..df63e96ea6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleViolation.java @@ -7,7 +7,6 @@ package net.sourceforge.pmd.reporting; import java.util.Comparator; import java.util.Map; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.annotation.DeprecatedUntil700; import net.sourceforge.pmd.lang.document.FileId; import net.sourceforge.pmd.lang.document.FileLocation; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationSuppressor.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationSuppressor.java index 7db2eaf755..a30dd01ede 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationSuppressor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationSuppressor.java @@ -12,7 +12,6 @@ import java.util.regex.Pattern; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.ast.AstInfo; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.Rule; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextColorRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextColorRendererTest.java index 362bf196ce..9514bbfc55 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextColorRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextColorRendererTest.java @@ -8,8 +8,8 @@ import java.io.FileNotFoundException; import java.io.Reader; import java.io.StringReader; -import net.sourceforge.pmd.Report.ConfigurationError; -import net.sourceforge.pmd.Report.ProcessingError; +import net.sourceforge.pmd.reporting.Report.ConfigurationError; +import net.sourceforge.pmd.reporting.Report.ProcessingError; class TextColorRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/reporting/ReportTestUtil.java b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/ReportTestUtil.java index b4bcd53358..2c98145a56 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/reporting/ReportTestUtil.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/reporting/ReportTestUtil.java @@ -6,9 +6,6 @@ package net.sourceforge.pmd.reporting; import java.util.function.BiConsumer; -import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleSet; -import net.sourceforge.pmd.RuleSets; import net.sourceforge.pmd.lang.LanguageProcessorRegistry; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; From 8950cec263426cc307522fabc6de76b303dde11f Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 9 Feb 2024 15:49:54 +0100 Subject: [PATCH 21/23] [doc] Fix javadoc links after moving reporting --- docs/pages/pmd/languages/java.md | 10 +++++----- .../pmd/userdocs/extending/writing_java_rules.md | 16 ++++++++-------- docs/pages/pmd/userdocs/migrating_to_pmd7.md | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/pages/pmd/languages/java.md b/docs/pages/pmd/languages/java.md index c59a841c50..6354280cae 100644 --- a/docs/pages/pmd/languages/java.md +++ b/docs/pages/pmd/languages/java.md @@ -167,12 +167,12 @@ The Javadocs are the reference documentation. Violations reported are the same for all languages, but languages can opt in to provide more details. Java does this by adding the following additional information for each reported violation: -* {% jdoc core::RuleViolation#VARIABLE_NAME %} -* {% jdoc core::RuleViolation#METHOD_NAME %} -* {% jdoc core::RuleViolation#CLASS_NAME %} -* {% jdoc core::RuleViolation#PACKAGE_NAME %} +* {% jdoc core::reporting.RuleViolation#VARIABLE_NAME %} +* {% jdoc core::reporting.RuleViolation#METHOD_NAME %} +* {% jdoc core::reporting.RuleViolation#CLASS_NAME %} +* {% jdoc core::reporting.RuleViolation#PACKAGE_NAME %} -You can access these via {% jdoc core::RuleViolation#getAdditionalInfo() %} +You can access these via {% jdoc core::reporting.RuleViolation#getAdditionalInfo() %} ## Dataflow diff --git a/docs/pages/pmd/userdocs/extending/writing_java_rules.md b/docs/pages/pmd/userdocs/extending/writing_java_rules.md index 36942a298e..ee71109161 100644 --- a/docs/pages/pmd/userdocs/extending/writing_java_rules.md +++ b/docs/pages/pmd/userdocs/extending/writing_java_rules.md @@ -172,18 +172,18 @@ to get the condition of an If-statement. ### Reporting violations -In your visit method, you have access to the {% jdoc core::RuleContext %} which is the entry point into +In your visit method, you have access to the {% jdoc core::reporting.RuleContext %} which is the entry point into reporting back during the analysis. -* {% jdoc core::RuleContext#addViolation(core::lang.ast.Node) %} reports a rule violation at +* {% jdoc core::reporting.RuleContext#addViolation(core::lang.ast.Node) %} reports a rule violation at the position of the given node with the message defined in the rule declaration XML element. * The message defined in the rule declaration XML element might contain **placeholder**, such as `{0}`. - In that case, you need to call {% jdoc core::RuleContext#addViolation(core::lang.ast.Node,java.lang.Object...) %} + In that case, you need to call {% jdoc core::reporting.RuleContext#addViolation(core::lang.ast.Node,java.lang.Object...) %} and provide the values for the placeholders. The message is actually processed as a `java.text.MessageFormat`. * Sometimes a rule might want to differentiate between different cases of a violation and use different messages. This is possible by calling the methods - {% jdoc core::RuleContext#addViolationWithMessage(core::lang.ast.Node,java.lang.String) %} or - {% jdoc core::RuleContext#addViolationWithMessage(core::lang.ast.Node,java.lang.String,java.lang.Object...) %}. + {% jdoc core::reporting.RuleContext#addViolationWithMessage(core::lang.ast.Node,java.lang.String) %} or + {% jdoc core::reporting.RuleContext#addViolationWithMessage(core::lang.ast.Node,java.lang.String,java.lang.Object...) %}. Using these methods, the message defined in the rule declaration XML element is _not used_. * Rules can be customized using properties and sometimes you want to include the actual value of a property in the message, e.g. if the rule enforces a specific limit. @@ -247,11 +247,11 @@ For each thread, a deep copy of the rule is created. Each thread is given a different set of files to analyse. Then, for each such file and for each rule copy: -1. {% jdoc core::lang.rule.Rule#start(core::RuleContext) %} is called once, before parsing -2. {% jdoc core::lang.rule.Rule#apply(core::lang.ast.Node,core::RuleContext) %} is called with the root +1. {% jdoc core::lang.rule.Rule#start(core::reporting.RuleContext) %} is called once, before parsing +2. {% jdoc core::lang.rule.Rule#apply(core::lang.ast.Node,core::reporting.RuleContext) %} is called with the root of the AST. That method performs the AST traversal that ultimately calls visit methods. It's not called for RuleChain rules. -3. {% jdoc core::lang.rule.Rule#end(core::RuleContext) %} is called when the rule is done processing +3. {% jdoc core::lang.rule.Rule#end(core::reporting.RuleContext) %} is called when the rule is done processing the file ## Example projects diff --git a/docs/pages/pmd/userdocs/migrating_to_pmd7.md b/docs/pages/pmd/userdocs/migrating_to_pmd7.md index 4ad6fdfd06..1565dadef9 100644 --- a/docs/pages/pmd/userdocs/migrating_to_pmd7.md +++ b/docs/pages/pmd/userdocs/migrating_to_pmd7.md @@ -27,7 +27,7 @@ There are a couple of deprecated things in PMD 6, you might encounter: See also [Defining rule properties](pmd_userdocs_extending_defining_properties.html) * When reporting a violation, you might see a deprecation of the `addViolation` methods. These methods have been moved - to {% jdoc core::RuleContext %}. E.g. instead of `addViolation(data, node, ...)` use `asCtx(data).addViolation(node, ...)`. + to {% jdoc core::reporting.RuleContext %}. E.g. instead of `addViolation(data, node, ...)` use `asCtx(data).addViolation(node, ...)`. * When you are calling PMD from CLI, you need to stop using deprecated CLI params, e.g. * `-no-cache` ➡️ `--no-cache` @@ -161,7 +161,7 @@ Most notable changes are: * A rule violation factory is not needed anymore. For language specific information on rule violations, there is now a {% jdoc core::reporting.ViolationDecorator %} that a language can implement. These ViolationDecorators are called when a violation is reported and they can provide the additional information. This information can be - used by renderers via {% jdoc !!core::RuleViolation#getAdditionalInfo() %}. + used by renderers via {% jdoc !!core::reporting.RuleViolation#getAdditionalInfo() %}. * A parser visitor adapter is not needed anymore. The visitor interface now provides a default implementation. Instead, a base visitor for the language should be created, which extends {% jdoc core::lang.ast.AstVisitorBase %}. * A rule chain visitor is not needed anymore. PMD provides a common implementation that fits all languages. From 7698b6a9947aedcbe091509ac35952b32f0f916a Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 9 Feb 2024 16:12:32 +0100 Subject: [PATCH 22/23] [compat6] Fix compatibility layer This is now an unhealthy mixture of old and new classes. But the integration tests are working. --- .../java/net/sourceforge/pmd/PmdAnalysis.java | 14 +- .../main/java/net/sourceforge/pmd/Rule.java | 1 + .../java/net/sourceforge/pmd/RuleSets.java | 221 ++++++++++++++++++ .../pmd/lang/rule/internal/RuleSets.java | 27 +++ 4 files changed, 257 insertions(+), 6 deletions(-) create mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSets.java create mode 100644 pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSets.java diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/PmdAnalysis.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/PmdAnalysis.java index cf82fb9e0c..5306c9d9c6 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/PmdAnalysis.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/PmdAnalysis.java @@ -44,6 +44,8 @@ import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.LanguageVersionDiscoverer; import net.sourceforge.pmd.lang.document.FileCollector; import net.sourceforge.pmd.lang.document.TextFile; +import net.sourceforge.pmd.lang.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.RuleSetLoader; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.reporting.ConfigurableFileNameRenderer; import net.sourceforge.pmd.reporting.FileAnalysisListener; @@ -189,7 +191,7 @@ public final class PmdAnalysis implements AutoCloseable { } if (!config.getRuleSetPaths().isEmpty()) { - final RuleSetLoader ruleSetLoader = pmd.newRuleSetLoader(); + final net.sourceforge.pmd.lang.rule.RuleSetLoader ruleSetLoader = pmd.newRuleSetLoader(); final List ruleSets = ruleSetLoader.loadRuleSetsWithoutException(config.getRuleSetPaths()); pmd.addRuleSets(ruleSets); } @@ -247,7 +249,7 @@ public final class PmdAnalysis implements AutoCloseable { * } * } */ - public RuleSetLoader newRuleSetLoader() { + public net.sourceforge.pmd.lang.rule.RuleSetLoader newRuleSetLoader() { return RuleSetLoader.fromPmdConfig(configuration); } @@ -375,7 +377,7 @@ public final class PmdAnalysis implements AutoCloseable { } void performAnalysisImpl(List extraListeners, List textFiles) { - RuleSets rulesets = new RuleSets(this.ruleSets); + net.sourceforge.pmd.lang.rule.internal.RuleSets rulesets = new net.sourceforge.pmd.lang.rule.internal.RuleSets(this.ruleSets); GlobalAnalysisListener listener; try { @@ -487,7 +489,7 @@ public final class PmdAnalysis implements AutoCloseable { Objects.requireNonNull(ruleLanguage, "Rule has no language " + rule); if (!languages.contains(ruleLanguage)) { LanguageVersion version = discoverer.getDefaultLanguageVersion(ruleLanguage); - if (RuleSet.applies(rule, version)) { + if (RuleSet.applies((net.sourceforge.pmd.lang.rule.Rule) rule, version)) { configuration.checkLanguageIsRegistered(ruleLanguage); languages.add(ruleLanguage); if (!quiet) { @@ -524,8 +526,8 @@ public final class PmdAnalysis implements AutoCloseable { * Remove and return the misconfigured rules from the rulesets and log them * for good measure. */ - private Set removeBrokenRules(final RuleSets ruleSets) { - final Set brokenRules = new HashSet<>(); + private Set removeBrokenRules(final RuleSets ruleSets) { + final Set brokenRules = new HashSet<>(); ruleSets.removeDysfunctionalRules(brokenRules); for (final Rule rule : brokenRules) { diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java index f81c5a7cfb..29116c858f 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/Rule.java @@ -22,6 +22,7 @@ import net.sourceforge.pmd.lang.rule.RuleTargetSelector; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; import net.sourceforge.pmd.properties.PropertySource; +import net.sourceforge.pmd.reporting.RuleContext; /** * This is the basic Rule interface for PMD rules. diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSets.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSets.java new file mode 100644 index 0000000000..c1f40deda5 --- /dev/null +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/RuleSets.java @@ -0,0 +1,221 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +// This class has been taken from 7.0.0-SNAPSHOT +// And it is kept in the old package. +// The moved class is in net.sourceforge.pmd.lang.rule.internal + +package net.sourceforge.pmd; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import net.sourceforge.pmd.benchmark.TimeTracker; +import net.sourceforge.pmd.benchmark.TimedOperation; +import net.sourceforge.pmd.benchmark.TimedOperationCategory; +import net.sourceforge.pmd.lang.LanguageProcessorRegistry; +import net.sourceforge.pmd.lang.ast.RootNode; +import net.sourceforge.pmd.lang.document.TextFile; +import net.sourceforge.pmd.lang.rule.Rule; +import net.sourceforge.pmd.lang.rule.RuleSet; +import net.sourceforge.pmd.lang.rule.internal.RuleApplicator; +import net.sourceforge.pmd.reporting.FileAnalysisListener; +import net.sourceforge.pmd.util.log.MessageReporter; + +/** + * Grouping of Rules per Language in a RuleSet. + * + * @author pieter_van_raemdonck - Application Engineers NV/SA - www.ae.be + */ +public class RuleSets { + + private final List ruleSets; + + private RuleApplicator ruleApplicator; + + /** + * Copy constructor. Deep copies RuleSets. + * + * @param ruleSets The RuleSets to copy. + */ + public RuleSets(final RuleSets ruleSets) { + List rsets = new ArrayList<>(); + for (final RuleSet rs : ruleSets.ruleSets) { + rsets.add(new RuleSet(rs)); + } + this.ruleSets = Collections.unmodifiableList(rsets); + } + + public RuleSets(Collection ruleSets) { + this.ruleSets = Collections.unmodifiableList(new ArrayList<>(ruleSets)); + } + + /** + * Public constructor. Add the given rule set. + * + * @param ruleSet the RuleSet + */ + public RuleSets(RuleSet ruleSet) { + this.ruleSets = Collections.singletonList(ruleSet); + } + + public void initializeRules(LanguageProcessorRegistry lpReg, MessageReporter reporter) { + // this is abusing the mutability of RuleSet, will go away eventually. + for (RuleSet rset : ruleSets) { + for (Iterator iterator = rset.getRules().iterator(); iterator.hasNext();) { + Rule rule = iterator.next(); + try { + rule.initialize(lpReg.getProcessor(rule.getLanguage())); + } catch (Exception e) { + reporter.errorEx( + "Exception while initializing rule " + rule.getName() + ", the rule will not be run", e); + iterator.remove(); + } + } + } + } + + private RuleApplicator prepareApplicator() { + return RuleApplicator.build(ruleSets.stream().flatMap(it -> it.getRules().stream())::iterator); + } + + /** + * Get all the RuleSets. + * + * @return RuleSet[] + */ + public RuleSet[] getAllRuleSets() { + return ruleSets.toArray(new RuleSet[0]); + } + + // internal + List getRuleSetsInternal() { + return ruleSets; + } + + public Iterator getRuleSetsIterator() { + return ruleSets.iterator(); + } + + /** + * Return all rules from all rulesets. + * + * @return Set + */ + public Set getAllRules() { + Set result = new HashSet<>(); + for (RuleSet r : ruleSets) { + result.addAll(r.getRules()); + } + return result; + } + + /** + * Check if a given source file should be checked by rules in this RuleSets. + * + * @param file + * the source file to check + * @return true if the file should be checked, + * false otherwise + */ + public boolean applies(TextFile file) { + for (RuleSet ruleSet : ruleSets) { + if (ruleSet.applies(file)) { + return true; + } + } + return false; + } + + /** + * Apply all applicable rules to the compilation units. Applicable means the + * language of the rules must match the language of the source (@see + * applies). + * + * @param root the List of compilation units; the type these must have, + * depends on the source language + * @param listener Listener that will handle events while analysing. + */ + public void apply(RootNode root, FileAnalysisListener listener) { + if (ruleApplicator == null) { + // initialize here instead of ctor, because some rules properties + // are set after creating the ruleset, and jaxen xpath queries + // initialize their XPath expressions when calling getRuleChainVisits()... fixme + this.ruleApplicator = prepareApplicator(); + } + + try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.RULE_AST_INDEXATION)) { + ruleApplicator.index(root); + } + + for (RuleSet ruleSet : ruleSets) { + if (ruleSet.applies(root.getTextDocument().getFileId())) { + ruleApplicator.apply(ruleSet.getRules(), listener); + } + } + } + + /** + * Returns the first Rule found with the given name. + * + * Note: Since we support multiple languages, rule names are not expected to + * be unique within any specific ruleset. + * + * @param ruleName + * the exact name of the rule to find + * @return the rule or null if not found + */ + public Rule getRuleByName(String ruleName) { + Rule rule = null; + for (Iterator i = ruleSets.iterator(); i.hasNext() && rule == null;) { + RuleSet ruleSet = i.next(); + rule = ruleSet.getRuleByName(ruleName); + } + return rule; + } + + /** + * Determines the total count of rules that are used in all rule sets. + * + * @return the count + */ + public int ruleCount() { + int count = 0; + for (RuleSet r : ruleSets) { + count += r.getRules().size(); + } + return count; + } + + + /** + * Remove and collect any rules that report problems. + * + * @param collector + */ + public void removeDysfunctionalRules(Collection collector) { + for (RuleSet ruleSet : ruleSets) { + ruleSet.removeDysfunctionalRules(collector); + } + } + + /** + * Retrieves a checksum of the rulesets being used. Any change to any rule + * of any ruleset should trigger a checksum change. + * + * @return The checksum for this ruleset collection. + */ + public long getChecksum() { + long checksum = 1; + for (final RuleSet ruleSet : ruleSets) { + checksum = checksum * 31 + ruleSet.getChecksum(); + } + return checksum; + } +} diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSets.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSets.java new file mode 100644 index 0000000000..dbf505107a --- /dev/null +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSets.java @@ -0,0 +1,27 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.rule.internal; + +import java.util.Collection; + +import net.sourceforge.pmd.lang.rule.RuleSet; + +public class RuleSets extends net.sourceforge.pmd.RuleSets { + public RuleSets(net.sourceforge.pmd.RuleSets ruleSets) { + super(ruleSets); + } + + public RuleSets(net.sourceforge.pmd.lang.rule.internal.RuleSets ruleSets) { + super(ruleSets); + } + + public RuleSets(Collection ruleSets) { + super(ruleSets); + } + + public RuleSets(RuleSet ruleSet) { + super(ruleSet); + } +} From 0c82e97b6a9c0dad4377deaf6eb358b8f6dbb964 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 9 Feb 2024 16:49:13 +0100 Subject: [PATCH 23/23] [compat6] Fix XPathRule compatibility --- .../java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java b/pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java index f8ddce578b..7d5778af9c 100644 --- a/pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java +++ b/pmd-compat6/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java @@ -16,16 +16,16 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.Rule; -import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.lang.rule.RuleTargetSelector; import net.sourceforge.pmd.lang.rule.xpath.internal.DeprecatedAttrLogger; import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.reporting.RuleContext; /**