[core] Move XPathRule into subpackage lang.rule.xpath (#4309)

This commit is contained in:
Andreas Dangel
2024-01-19 12:52:51 +01:00
parent 83522e96ef
commit 7c29f16eac
64 changed files with 269 additions and 263 deletions

View File

@ -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:
<rule name="MyXPathRule"
language="java"
message="Violation!"
class="net.sourceforge.pmd.lang.rule.XPathRule">
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<description>
Description
</description>

View File

@ -127,7 +127,7 @@ copy-paste into your ruleset XML. The resulting element looks like so:
<rule name="DontCallBossShort"
language="java"
message="Boss wants to talk to you."
class="net.sourceforge.pmd.lang.rule.XPathRule">
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<description>
TODO
</description>

View File

@ -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).

View File

@ -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:

View File

@ -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">
<description>
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">
<description>
The first parameter of System.debug, when using the signature with two parameters, is a LoggingLevel enum.

View File

@ -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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
Avoid using 'while' statements without using braces to surround the code block. If the code

View File

@ -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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
Test methods marked as a testMethod or annotated with @IsTest,

View File

@ -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">
<description>
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">
<description>
This rule finds `DescribeSObjectResult`s which could have been loaded eagerly via `SObjectType.getDescribe()`.

View File

@ -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

View File

@ -7,7 +7,7 @@
</description>
<rule name="ReportAllRootNodes" language="dummy" since="1.0" message="Violation from ReportAllRootNodes"
class="net.sourceforge.pmd.lang.rule.XPathRule"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/rules/test/TestRuleset3.xml#Ruleset3Rule1">
<description>Just for test</description>
<priority>3</priority>

View File

@ -2,7 +2,7 @@
<description/>
<rule name="ExceptionThrowingRule"
language="java"
class="net.sourceforge.pmd.lang.rule.XPathRule">
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<description>Use this rule to produce a processing error.</description>
<priority>3</priority>
<properties>

View File

@ -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

View File

@ -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)}
*/

View File

@ -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

View File

@ -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;

View File

@ -241,7 +241,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase {
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<ruleset name=\"test\">\n"
+ " <description>ruleset desc</description>\n"
+ " <rule deprecated=\"true\" ref=\"NewName\" name=\"OldName\"/>"
+ " <rule name=\"NewName\" message=\"m\" class=\"net.sourceforge.pmd.lang.rule.XPathRule\" language=\"dummy\">"
+ " <rule name=\"NewName\" message=\"m\" class=\"net.sourceforge.pmd.lang.rule.xpath.XPathRule\" language=\"dummy\">"
+ " <description>d</description>\n" + " <priority>2</priority>\n" + " </rule>"
+ "</ruleset>");
assertEquals(1, rs.getRules().size());
@ -269,7 +269,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase {
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<ruleset name=\"test\">\n"
+ " <description>ruleset desc</description>\n"
+ " <rule deprecated=\"true\" ref=\"NewName\" name=\"OldName\"/>"
+ " <rule name=\"NewName\" message=\"m\" class=\"net.sourceforge.pmd.lang.rule.XPathRule\" language=\"dummy\">"
+ " <rule name=\"NewName\" message=\"m\" class=\"net.sourceforge.pmd.lang.rule.xpath.XPathRule\" language=\"dummy\">"
+ " <description>d</description>\n"
+ " <priority>2</priority>\n"
+ " </rule>"

View File

@ -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;
/**

View File

@ -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;

View File

@ -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 {

View File

@ -33,7 +33,7 @@ Just for test
<rule name="MockRule3" deprecated="true" ref="net/sourceforge/pmd/TestRuleset2.xml/TestRule"/>
<rule name="MockRule4" language="dummy" since="1.0" message="Test Rule"
class="net.sourceforge.pmd.lang.rule.XPathRule"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/rules/test/TestRuleset1.xml#MockRule">
<description>
Just for test

View File

@ -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">
<description>
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">
<description>
@ -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">
<description>
@ -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">
<description>
@ -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">
<description>
@ -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">
<description>
@ -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">
<description><![CDATA[
Web applications should not call System.exit(), since only the web container or the
@ -306,7 +306,7 @@ public class Foo {
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}/rules/j2ee.html#StaticEJBFieldShouldBeFinal">
<description>
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">
<description>

View File

@ -23,7 +23,7 @@ Just for test
<!-- variant 2 of a renamed rule. This explicitly mentions the new ruleset which happens to be this (the same) ruleset. -->
<rule deprecated="true" name="OldNameOfDummyBasicMockRule2" ref="rulesets/dummy/basic.xml/DummyBasicMockRule"/>
<rule name="SampleXPathRule" language="dummy" since="1.1" message="Test Rule 2" class="net.sourceforge.pmd.lang.rule.XPathRule"
<rule name="SampleXPathRule" language="dummy" since="1.1" message="Test Rule 2" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/rules/dummy/basic.xml#SampleXPathRule">
<description>Test</description>
<priority>3</priority>
@ -38,7 +38,7 @@ Just for test
</properties>
</rule>
<rule name="DeprecatedRule" deprecated="true" language="dummy" since="1.0" message="Test Rule 3" class="net.sourceforge.pmd.lang.rule.XPathRule"
<rule name="DeprecatedRule" deprecated="true" language="dummy" since="1.0" message="Test Rule 3" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/rules/dummy/basic.xml#deprecatedrule">
<description>Test Deprecated rule</description>
<priority>3</priority>

View File

@ -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 {

View File

@ -16,7 +16,7 @@ Here might be &lt;script&gt;alert('XSS');&lt;/script&gt; as well. And "quotes".
language="java"
since="0.1"
message="Tests that &lt;script&gt;alert('XSS');&lt;/script&gt; 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">
<description>
&lt;script&gt;alert('XSS at the beginning');&lt;/script&gt; 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">
<description>
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">
<description>

View File

@ -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">
<description>
Avoid jumbled loop incrementers - its usually a mistake, and is confusing even if intentional.

View File

@ -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">
<description>
Don't mix content and style. Use separate CSS-files for the style and introduce classes.

View File

@ -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 {

View File

@ -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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description><![CDATA[
Reports JUnit 5 test classes and methods that are not package-private.
@ -1117,7 +1117,7 @@ public class SecureSystem {
<rule name="OneDeclarationPerLine"
language="java"
since="5.0"
class="net.sourceforge.pmd.lang.rule.XPathRule"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
message="Use one line for each declaration, it enhances code readability."
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#onedeclarationperline">
<description>
@ -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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
Java 5 introduced the varargs parameter declaration for methods and constructors. This syntactic
@ -1825,7 +1825,7 @@ public class Foo {
</rule>
<rule name="WhileLoopWithLiteralBoolean"
class="net.sourceforge.pmd.lang.rule.XPathRule"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
language="java"
since="6.13.0"
message="The loop can be simplified."

View File

@ -37,7 +37,7 @@ public class Foo {
language="java"
since="1.5"
message="Avoid using dollar signs in variable/method/class/interface 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#avoiddollarsigns">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
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
<rule name="EmptyMethodInAbstractClassShouldBeAbstract"
language="java"
since="4.1"
class="net.sourceforge.pmd.lang.rule.XPathRule"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
message="An empty method in an abstract class should be abstract instead"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#emptymethodinabstractclassshouldbeabstract">
<description>
@ -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">
<description>No need to explicitly extend Object.</description>
<priority>4</priority>
@ -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">
<description>
@ -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">
<description>
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">
<description>
Names for references to generic values should be limited to a single uppercase letter.
@ -841,7 +841,7 @@ public class LinguisticNaming {
<rule 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}/pmd_rules_java_codestyle.html#localhomenamingconvention">
<description>
@ -873,7 +873,7 @@ public interface MissingProperSuffix extends javax.ejb.EJBLocalHome {} // non-s
<rule 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}/pmd_rules_java_codestyle.html#localinterfacesessionnamingconvention">
<description>
@ -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">
<description>
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 {
<rule 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}/pmd_rules_java_codestyle.html#mdbandsessionbeannamingconvention">
<description>
@ -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">
<description>
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">
<description>
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">
<description>
Detects when a package definition contains uppercase characters.
@ -1261,7 +1261,7 @@ public int getLength(String[] strings) {
<rule 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}/pmd_rules_java_codestyle.html#remoteinterfacenamingconvention">
<description>
@ -1298,7 +1298,7 @@ public interface BadSuffixBean extends javax.ejb.EJBObject {}
<rule 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}/pmd_rules_java_codestyle.html#remotesessioninterfacenamingconvention">
<description>
@ -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">
<description>
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">
<description>
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">
<description>
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 {
<rule name="TooManyStaticImports"
language="java"
since="4.1"
class="net.sourceforge.pmd.lang.rule.XPathRule"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
message="Too many static imports may lead to messy code"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#toomanystaticimports">
<description>
@ -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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
<![CDATA[

View File

@ -12,7 +12,7 @@ Rules that help you discover design issues.
<rule name="AbstractClassWithoutAnyMethod"
language="java"
since="4.2"
class="net.sourceforge.pmd.lang.rule.XPathRule"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
message="No abstract method which means that the keyword is most likely used to prevent instantiation. Use a private or protected constructor instead."
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#abstractclasswithoutanymethod">
<description>
@ -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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description>
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">
<description><![CDATA[
Reports nested 'if' statements that can be merged together by joining their
@ -579,7 +579,7 @@ public class DataClass {
language="java"
since="4.0"
message="Exceptions should not extend java.lang.Error"
class="net.sourceforge.pmd.lang.rule.XPathRule"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#donotextendjavalangerror">
<description>
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">
<description>
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 {
<rule name="LogicInversion"
language="java"
since="5.0"
class="net.sourceforge.pmd.lang.rule.XPathRule"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
message="Use opposite operator instead of the logic complement operator."
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#logicinversion">
<description>
@ -1197,7 +1197,7 @@ public void foo() throws Exception {
language="java"
since="5.4.0"
message="This conditional expression can be simplified with || or &amp;&amp;"
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">
<description>
<![CDATA[
@ -1253,7 +1253,7 @@ public class Foo {
language="java"
since="1.05"
message="Avoid unnecessary comparisons in boolean expressions"
class="net.sourceforge.pmd.lang.rule.XPathRule"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#simplifybooleanexpressions">
<description>
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">
<description>
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
<rule name="TooManyMethods"
language="java"
since="4.2"
class="net.sourceforge.pmd.lang.rule.XPathRule"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
message="This class has too many methods, consider refactoring it."
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#toomanymethods">
<description>
@ -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">
<description>
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">
<description>
Non-private static fields should be made constants (or immutable references) by

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