From 9a37ab4962f6b18deecaad1dd53b1132e0806cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= <clement.fournier76@gmail.com> Date: Sat, 18 Apr 2020 01:27:57 +0200 Subject: [PATCH 1/7] Deprecate parser options in some places There is no way to introduce the new API in a binary compatible change, so LVHandler::getDefaultParserOptions, LVHandler::getParser and Parser::parse will remain like this until 7.0 and be broken. --- .../java/net/sourceforge/pmd/lang/apex/ApexParserOptions.java | 1 + pmd-core/src/main/java/net/sourceforge/pmd/Rule.java | 4 ++++ pmd-core/src/main/java/net/sourceforge/pmd/lang/Parser.java | 4 ++++ .../main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java | 1 + 4 files changed, 10 insertions(+) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexParserOptions.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexParserOptions.java index a660af6eef..7f66baf62e 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexParserOptions.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexParserOptions.java @@ -6,6 +6,7 @@ package net.sourceforge.pmd.lang.apex; import net.sourceforge.pmd.lang.ParserOptions; +@Deprecated public class ApexParserOptions extends ParserOptions { // empty class for now, since we don't have extra options for Apex diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java b/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java index 00eb948d7a..feab69e2fe 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java @@ -255,7 +255,11 @@ public interface Rule extends PropertySource { * should return a new instance on each call. * * @return the parser options + * + * @deprecated This was never implemented and will never be. PMD + * cannot parse files once per rule. */ + @Deprecated ParserOptions getParserOptions(); /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/Parser.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/Parser.java index 7ece070e1a..3156d3561b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/Parser.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/Parser.java @@ -16,9 +16,13 @@ import net.sourceforge.pmd.lang.ast.ParseException; * @author Pieter_Van_Raemdonck - Application Engineers NV/SA - www.ae.be */ public interface Parser { + /** * Get the ParserOptions used by this Parser. + * + * @deprecated Parser options should be a parameter to {@link #parse(String, Reader)} */ + @Deprecated ParserOptions getParserOptions(); /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java index b8aa8c7e05..463ac61b3c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java @@ -229,6 +229,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul * @see Rule#setPriority(RulePriority) */ @Override + @Deprecated public ParserOptions getParserOptions() { return new ParserOptions(); } From 190addc1a9b3652ce016d91b50ee6b05d3389f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= <clement.fournier76@gmail.com> Date: Tue, 28 Apr 2020 20:40:31 +0200 Subject: [PATCH 2/7] Replace usages of ApexXPathRule --- .../main/resources/category/apex/bestpractices.xml | 2 +- .../src/main/resources/category/apex/codestyle.xml | 10 +++++----- .../main/resources/category/apex/errorprone.xml | 14 +++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pmd-apex/src/main/resources/category/apex/bestpractices.xml b/pmd-apex/src/main/resources/category/apex/bestpractices.xml index f91fa5095a..44c49dda6b 100644 --- a/pmd-apex/src/main/resources/category/apex/bestpractices.xml +++ b/pmd-apex/src/main/resources/category/apex/bestpractices.xml @@ -173,7 +173,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.apex.rule.ApexXPathRule" + class="net.sourceforge.pmd.lang.rule.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. diff --git a/pmd-apex/src/main/resources/category/apex/codestyle.xml b/pmd-apex/src/main/resources/category/apex/codestyle.xml index 0c0ea51a4a..0343db5512 100644 --- a/pmd-apex/src/main/resources/category/apex/codestyle.xml +++ b/pmd-apex/src/main/resources/category/apex/codestyle.xml @@ -36,7 +36,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.apex.rule.ApexXPathRule" + class="net.sourceforge.pmd.lang.rule.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.apex.rule.ApexXPathRule" + class="net.sourceforge.pmd.lang.rule.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.apex.rule.ApexXPathRule" + class="net.sourceforge.pmd.lang.rule.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 @@ -267,7 +267,7 @@ public class Foo { <rule name="OneDeclarationPerLine" since="6.7.0" message="Use one statement for each line, it enhances code readability." - class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule" + class="net.sourceforge.pmd.lang.rule.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 @@ -364,7 +364,7 @@ public class Foo { language="apex" since="5.6.0" message="Avoid using 'while' statements without curly braces" - class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule" + class="net.sourceforge.pmd.lang.rule.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 diff --git a/pmd-apex/src/main/resources/category/apex/errorprone.xml b/pmd-apex/src/main/resources/category/apex/errorprone.xml index ecea64c472..7ede809e3b 100644 --- a/pmd-apex/src/main/resources/category/apex/errorprone.xml +++ b/pmd-apex/src/main/resources/category/apex/errorprone.xml @@ -52,7 +52,7 @@ public class Foo { <rule name="AvoidDirectAccessTriggerMap" since="6.0.0" message="Avoid directly accessing Trigger.old and Trigger.new" - class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule" + class="net.sourceforge.pmd.lang.rule.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. @@ -112,7 +112,7 @@ public without sharing class Foo { language="apex" since="6.0.0" message="Avoid empty catch blocks" - class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule" + class="net.sourceforge.pmd.lang.rule.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. @@ -148,7 +148,7 @@ public void doSomething() { language="apex" since="6.0.0" message="Avoid empty 'if' statements" - class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule" + class="net.sourceforge.pmd.lang.rule.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. @@ -182,7 +182,7 @@ public class Foo { language="apex" since="6.0.0" message="Avoid empty block statements." - class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule" + class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#emptystatementblock"> <description> Empty block statements serve no purpose and should be removed. @@ -218,7 +218,7 @@ public class Foo { language="apex" since="6.0.0" message="Avoid empty try or finally blocks" - class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule" + class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#emptytryorfinallyblock"> <description> Avoid empty try or finally blocks - what's the point? @@ -263,7 +263,7 @@ public class Foo { language="apex" since="6.0.0" message="Avoid empty 'while' statements" - class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule" + class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#emptywhilestmt"> <description> Empty While Statement finds all instances where a while statement does nothing. @@ -338,7 +338,7 @@ public class MyClass { <rule name="TestMethodsMustBeInTestClasses" since="6.22.0" message="Test methods must be in test classes" - class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule" + class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#testmethodsmustbeintestclasses"> <description> Test methods marked as a testMethod or annotated with @IsTest, From 151a56cfa06d02430bab0ff00d720b749b5a3ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= <clement.fournier76@gmail.com> Date: Tue, 28 Apr 2020 20:41:49 +0200 Subject: [PATCH 3/7] Deprecate other custom XPath rules --- .../pmd/lang/ecmascript/rule/EcmascriptXPathRule.java | 5 ++++- .../java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRule.java | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/EcmascriptXPathRule.java b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/EcmascriptXPathRule.java index 4b5ea7f839..86bac22a3f 100644 --- a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/EcmascriptXPathRule.java +++ b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/EcmascriptXPathRule.java @@ -12,7 +12,10 @@ import net.sourceforge.pmd.lang.ecmascript.EcmascriptParserOptions.Version; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.properties.PropertyDescriptor; - +/** + * @deprecated Parser options are deprecated, use {@link XPathRule} directly + */ +@Deprecated public class EcmascriptXPathRule extends XPathRule { private static final PropertyDescriptor<Boolean> RECORDING_COMMENTS_DESCRIPTOR = EcmascriptParserOptions.RECORDING_COMMENTS_DESCRIPTOR; diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRule.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRule.java index e833025a7d..ff9eb847ad 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRule.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRule.java @@ -11,6 +11,10 @@ import net.sourceforge.pmd.lang.xml.XmlLanguageModule; import net.sourceforge.pmd.lang.xml.XmlParserOptions; import net.sourceforge.pmd.properties.BooleanProperty; +/** + * @deprecated Parser options are deprecated, use {@link XPathRule} directly + */ +@Deprecated public class XmlXPathRule extends XPathRule { public static final BooleanProperty COALESCING_DESCRIPTOR = XmlParserOptions.COALESCING_DESCRIPTOR; From 25d59beb378987de895fd239b0ff4c6a1ddefbef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= <clement.fournier76@gmail.com> Date: Tue, 28 Apr 2020 20:45:34 +0200 Subject: [PATCH 4/7] Revert changes to apex rules Someone may be using those properties, this would be a breaking change --- .../pmd/lang/apex/ApexParserOptions.java | 3 +++ .../main/resources/category/apex/bestpractices.xml | 2 +- .../src/main/resources/category/apex/codestyle.xml | 10 +++++----- .../main/resources/category/apex/errorprone.xml | 14 +++++++------- .../lang/ecmascript/EcmascriptParserOptions.java | 5 ++++- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexParserOptions.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexParserOptions.java index 7f66baf62e..8d41b5d1ba 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexParserOptions.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexParserOptions.java @@ -6,6 +6,9 @@ package net.sourceforge.pmd.lang.apex; import net.sourceforge.pmd.lang.ParserOptions; +/** + * @deprecated Not useful + */ @Deprecated public class ApexParserOptions extends ParserOptions { diff --git a/pmd-apex/src/main/resources/category/apex/bestpractices.xml b/pmd-apex/src/main/resources/category/apex/bestpractices.xml index 44c49dda6b..f91fa5095a 100644 --- a/pmd-apex/src/main/resources/category/apex/bestpractices.xml +++ b/pmd-apex/src/main/resources/category/apex/bestpractices.xml @@ -173,7 +173,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.apex.rule.ApexXPathRule" 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. diff --git a/pmd-apex/src/main/resources/category/apex/codestyle.xml b/pmd-apex/src/main/resources/category/apex/codestyle.xml index 0343db5512..0c0ea51a4a 100644 --- a/pmd-apex/src/main/resources/category/apex/codestyle.xml +++ b/pmd-apex/src/main/resources/category/apex/codestyle.xml @@ -36,7 +36,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.apex.rule.ApexXPathRule" 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.apex.rule.ApexXPathRule" 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.apex.rule.ApexXPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_codestyle.html#forloopsmustusebraces"> <description> Avoid using 'for' statements without using surrounding braces. If the code formatting or @@ -267,7 +267,7 @@ public class Foo { <rule name="OneDeclarationPerLine" 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.apex.rule.ApexXPathRule" 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 @@ -364,7 +364,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.apex.rule.ApexXPathRule" 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 diff --git a/pmd-apex/src/main/resources/category/apex/errorprone.xml b/pmd-apex/src/main/resources/category/apex/errorprone.xml index 7ede809e3b..ecea64c472 100644 --- a/pmd-apex/src/main/resources/category/apex/errorprone.xml +++ b/pmd-apex/src/main/resources/category/apex/errorprone.xml @@ -52,7 +52,7 @@ public class Foo { <rule name="AvoidDirectAccessTriggerMap" 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.apex.rule.ApexXPathRule" 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. @@ -112,7 +112,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.apex.rule.ApexXPathRule" 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. @@ -148,7 +148,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.apex.rule.ApexXPathRule" 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. @@ -182,7 +182,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.apex.rule.ApexXPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#emptystatementblock"> <description> Empty block statements serve no purpose and should be removed. @@ -218,7 +218,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.apex.rule.ApexXPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#emptytryorfinallyblock"> <description> Avoid empty try or finally blocks - what's the point? @@ -263,7 +263,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.apex.rule.ApexXPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#emptywhilestmt"> <description> Empty While Statement finds all instances where a while statement does nothing. @@ -338,7 +338,7 @@ public class MyClass { <rule name="TestMethodsMustBeInTestClasses" since="6.22.0" message="Test methods must be in test classes" - class="net.sourceforge.pmd.lang.rule.XPathRule" + class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#testmethodsmustbeintestclasses"> <description> Test methods marked as a testMethod or annotated with @IsTest, diff --git a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptions.java b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptions.java index 981ce19fb5..602813e010 100644 --- a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptions.java +++ b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptions.java @@ -13,7 +13,10 @@ import net.sourceforge.pmd.lang.ParserOptions; import net.sourceforge.pmd.properties.BooleanProperty; import net.sourceforge.pmd.properties.EnumeratedProperty; - +/** + * @deprecated Will be removed in 7.0 TODO refactor this into language versions? + */ +@Deprecated public class EcmascriptParserOptions extends ParserOptions { public enum Version { From 8fe29dfee7228f68daf7ef7123ff075b74da073c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= <clement.fournier76@gmail.com> Date: Tue, 28 Apr 2020 20:49:37 +0200 Subject: [PATCH 5/7] Deprecations in XML module --- pmd-core/src/main/java/net/sourceforge/pmd/Rule.java | 3 ++- .../net/sourceforge/pmd/lang/xml/XmlParserOptions.java | 5 +++++ .../net/sourceforge/pmd/lang/xml/rule/AbstractXmlRule.java | 7 +++++++ .../net/sourceforge/pmd/lang/xml/rule/XmlXPathRule.java | 7 +++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java b/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java index feab69e2fe..ae1b811752 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java @@ -257,7 +257,8 @@ public interface Rule extends PropertySource { * @return the parser options * * @deprecated This was never implemented and will never be. PMD - * cannot parse files once per rule. + * cannot parse files once per rule. Let this method assume + * its default by not overriding it. */ @Deprecated ParserOptions getParserOptions(); diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlParserOptions.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlParserOptions.java index 078105bdac..14441bcbc5 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlParserOptions.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlParserOptions.java @@ -16,6 +16,11 @@ import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.ParserOptions; import net.sourceforge.pmd.properties.BooleanProperty; +/** + * @deprecated Parser options will be removed with 7.0, these options + * will assume their default values then. + */ +@Deprecated public class XmlParserOptions extends ParserOptions { // Note: The UI order values are chosen to be larger than those built into diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/AbstractXmlRule.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/AbstractXmlRule.java index c144118c6d..ec76a99611 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/AbstractXmlRule.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/AbstractXmlRule.java @@ -25,12 +25,19 @@ import net.sourceforge.pmd.properties.BooleanProperty; */ public class AbstractXmlRule extends AbstractRule implements ImmutableLanguage { + @Deprecated public static final BooleanProperty COALESCING_DESCRIPTOR = XmlParserOptions.COALESCING_DESCRIPTOR; + @Deprecated public static final BooleanProperty EXPAND_ENTITY_REFERENCES_DESCRIPTOR = XmlParserOptions.EXPAND_ENTITY_REFERENCES_DESCRIPTOR; + @Deprecated public static final BooleanProperty IGNORING_COMMENTS_DESCRIPTOR = XmlParserOptions.IGNORING_COMMENTS_DESCRIPTOR; + @Deprecated public static final BooleanProperty IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR = XmlParserOptions.IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR; + @Deprecated public static final BooleanProperty NAMESPACE_AWARE_DESCRIPTOR = XmlParserOptions.NAMESPACE_AWARE_DESCRIPTOR; + @Deprecated public static final BooleanProperty VALIDATING_DESCRIPTOR = XmlParserOptions.VALIDATING_DESCRIPTOR; + @Deprecated public static final BooleanProperty XINCLUDE_AWARE_DESCRIPTOR = XmlParserOptions.XINCLUDE_AWARE_DESCRIPTOR; public AbstractXmlRule() { diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRule.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRule.java index ff9eb847ad..11baa84e60 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRule.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/rule/XmlXPathRule.java @@ -17,12 +17,19 @@ import net.sourceforge.pmd.properties.BooleanProperty; @Deprecated public class XmlXPathRule extends XPathRule { + @Deprecated public static final BooleanProperty COALESCING_DESCRIPTOR = XmlParserOptions.COALESCING_DESCRIPTOR; + @Deprecated public static final BooleanProperty EXPAND_ENTITY_REFERENCES_DESCRIPTOR = XmlParserOptions.EXPAND_ENTITY_REFERENCES_DESCRIPTOR; + @Deprecated public static final BooleanProperty IGNORING_COMMENTS_DESCRIPTOR = XmlParserOptions.IGNORING_COMMENTS_DESCRIPTOR; + @Deprecated public static final BooleanProperty IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR = XmlParserOptions.IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR; + @Deprecated public static final BooleanProperty NAMESPACE_AWARE_DESCRIPTOR = XmlParserOptions.NAMESPACE_AWARE_DESCRIPTOR; + @Deprecated public static final BooleanProperty VALIDATING_DESCRIPTOR = XmlParserOptions.VALIDATING_DESCRIPTOR; + @Deprecated public static final BooleanProperty XINCLUDE_AWARE_DESCRIPTOR = XmlParserOptions.XINCLUDE_AWARE_DESCRIPTOR; public XmlXPathRule() { From 0609aac9d3f972a1cecdb218d94575c725944760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= <clement.fournier76@gmail.com> Date: Tue, 28 Jul 2020 14:35:20 +0200 Subject: [PATCH 6/7] Deprecate AbstractParser --- docs/pages/release_notes.md | 11 +++++++++++ .../net/sourceforge/pmd/lang/AbstractParser.java | 3 +++ .../pmd/lang/xml/XmlParserOptions.java | 16 ++++++++-------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index b8f8783555..a9f58d3787 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -18,6 +18,17 @@ This is a {{ site.pmd.release_type }} release. ### API Changes +#### Deprecated API + +- {% jdoc !!core::Rule#getParserOptions() %} +- {% jdoc !!core::lang.Parser#getParserOptions() %} +- {% jdoc !!core::lang.AbstractParser %} +- {% jdoc apex::lang.apex.ApexParserOptions %} +- {% jdoc xml::lang.xml.XmlParserOptions %} +- {% jdoc xml::lang.xml.rule.XmlXpathRule %} +- Properties of {% jdoc xml::lang.xml.rule.AbstractXmlRule %} +- {% jdoc javascript::lang.ecmascript.EcmascriptParserOptions %} + ### External Contributions {% endtocmaker %} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractParser.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractParser.java index 870fb72440..edd6552f81 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractParser.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractParser.java @@ -10,7 +10,10 @@ import java.io.Reader; * This is a generic implementation of the Parser interface. * * @see Parser + * + * @deprecated This will become useless in PMD 7. Implement or use {@link Parser} directly */ +@Deprecated public abstract class AbstractParser implements Parser { protected final ParserOptions parserOptions; diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlParserOptions.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlParserOptions.java index 14441bcbc5..ad811f87f5 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlParserOptions.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlParserOptions.java @@ -26,26 +26,26 @@ public class XmlParserOptions extends ParserOptions { // Note: The UI order values are chosen to be larger than those built into // XPathRule. public static final BooleanProperty COALESCING_DESCRIPTOR = new BooleanProperty("coalescing", - "Specifies that the XML parser convert CDATA nodes to Text nodes and append it to the adjacent (if any) text node.", + "deprecated!Specifies that the XML parser convert CDATA nodes to Text nodes and append it to the adjacent (if any) text node.", Boolean.FALSE, 3.0f); public static final BooleanProperty EXPAND_ENTITY_REFERENCES_DESCRIPTOR = new BooleanProperty( - "expandEntityReferences", "Specifies that the XML parser expand entity reference nodes.", Boolean.TRUE, + "expandEntityReferences", "deprecated!Specifies that the XML parser expand entity reference nodes.", Boolean.TRUE, 4.0f); public static final BooleanProperty IGNORING_COMMENTS_DESCRIPTOR = new BooleanProperty("ignoringComments", - "Specifies that the XML parser ignore comments.", Boolean.FALSE, 5.0f); + "deprecated!Specifies that the XML parser ignore comments.", Boolean.FALSE, 5.0f); public static final BooleanProperty IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR = new BooleanProperty( "ignoringElementContentWhitespace", - "Specifies that the XML parser eliminate whitespace in element content. Setting this to 'true' will force validating.", + "deprecated!Specifies that the XML parser eliminate whitespace in element content. Setting this to 'true' will force validating.", Boolean.FALSE, 6.0f); public static final BooleanProperty NAMESPACE_AWARE_DESCRIPTOR = new BooleanProperty("namespaceAware", - "Specifies that the XML parser will provide support for XML namespaces.", Boolean.TRUE, 7.0f); + "deprecated!Specifies that the XML parser will provide support for XML namespaces.", Boolean.TRUE, 7.0f); public static final BooleanProperty VALIDATING_DESCRIPTOR = new BooleanProperty("validating", - "Specifies that the XML parser will validate documents as they are parsed. This only works for DTDs.", + "deprecated!Specifies that the XML parser will validate documents as they are parsed. This only works for DTDs.", Boolean.FALSE, 8.0f); public static final BooleanProperty XINCLUDE_AWARE_DESCRIPTOR = new BooleanProperty("xincludeAware", - "Specifies that the XML parser will process XInclude markup.", Boolean.FALSE, 9.0f); + "deprecated!Specifies that the XML parser will process XInclude markup.", Boolean.FALSE, 9.0f); public static final BooleanProperty LOOKUP_DESCRIPTOR_DTD = new BooleanProperty("xincludeAware", - "Specifies whether XML parser will attempt to lookup the DTD.", Boolean.FALSE, 10.0f); + "deprecated!Specifies whether XML parser will attempt to lookup the DTD.", Boolean.FALSE, 10.0f); public static final EntityResolver SILENT_ENTITY_RESOLVER = new EntityResolver() { @Override From eb219916dcf669add24912a82a0965a395956e04 Mon Sep 17 00:00:00 2001 From: Andreas Dangel <andreas.dangel@pmd-code.org> Date: Sun, 2 Aug 2020 16:50:04 +0200 Subject: [PATCH 7/7] [doc] Update release notes --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index a9f58d3787..4d80a38837 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -28,6 +28,7 @@ This is a {{ site.pmd.release_type }} release. - {% jdoc xml::lang.xml.rule.XmlXpathRule %} - Properties of {% jdoc xml::lang.xml.rule.AbstractXmlRule %} - {% jdoc javascript::lang.ecmascript.EcmascriptParserOptions %} +- {% jdoc javascript::lang.ecmascript.rule.EcmascriptXPathRule %} ### External Contributions