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