Affects PMD Version: 7.5.0
Description:
When you have a ruleset, that references a rule and changes the (default) value of a property, as described in https://docs.pmd-code.org/latest/pmd_userdocs_configuring_rules.html#rule-properties,
then the RuleSetWriter exports in invalid ruleset: The exported ruleset contains a property definition, rather then just sets the value.
Originally reported in m2e-code-quality/m2e-code-quality#364
Example ruleset:
<?xml version="1.0" encoding="UTF-8"?> <ruleset name="Minimal Custom PMD Ruleset" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.net/ruleset_2_0_0.xsd"> <description>Minimal Custom PMD Rulese</description> <!-- Customized as documented here: https://pmd.github.io/pmd/pmd_rules_java_codestyle.html#shortvariable --> <!-- Attempt to override default value 3 with 1 --> <rule ref="category/java/codestyle.xml/ShortVariable"> <properties> <property name="minimum" value="1" /> </properties> </rule> </ruleset>
Actual output from RuleSetWriter:
<?xml version="1.0" encoding="UTF-8"?> <ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="M2Eclipse PMD RuleSet" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd"> <description>M2Eclipse PMD RuleSet</description> <rule ref="category/java/codestyle.xml/ShortVariable"> <properties> <property description="Number of characters that are required as a minimum for a variable name." max="100" min="1" name="minimum" type="Integer"> <value>3</value> </property> </properties> </rule> </ruleset>
Note: value is 3, but expected is 1.
Expected output:
<?xml version="1.0" encoding="UTF-8"?> <ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="M2Eclipse PMD RuleSet" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd"> <description>M2Eclipse PMD RuleSet</description> <!-- Maybe some pattern definitions here --> <rule ref="category/java/codestyle.xml/ShortVariable"> <properties> <property name="minimum" value="1" /> </properties> </rule> </ruleset>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4