Skip to content

Commit 9793c0d

Browse files
committed
refactor(ci): align phpmd ruleset with Magento core static tests
Replace the broad all-rulesets config with the specific rules Magento select in dev/tests/static/testsuite/Magento/Test/Php/_files/phpmd/ruleset.xml. Removed: - cleancode.xml entirely (Magento don't use it; contained ElseExpression) - Full naming.xml (replaced with 3 targeted rules; LongVariable not included) - Full design.xml (replaced with NumberOfChildren, DepthOfInheritance, CouplingBetweenObjects) - Full codesize.xml (replaced with 7 specific rules matching Magento's selection) Added: - unusedcode.xml excluding UnusedFormalParameter (Magento use a custom version of this rule that understands plugin signatures, enforced by the Magento instance's own static test suite) - ExcessiveClassComplexity with maximum=100 (Magento's threshold) - DepthOfInheritance with minimum=8 (accommodates Magento's inheritance depth) Result: 0 violations, aligned with Magento's own enforcement standard.
1 parent d5657d6 commit 9793c0d

File tree

1 file changed

+46
-10
lines changed

1 file changed

+46
-10
lines changed

phpmd.xml

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,55 @@
11
<?xml version="1.0"?>
2+
<!--
3+
PHPMD ruleset for magento2-configurator.
4+
5+
Mirrors the ruleset Magento use in their own core static tests:
6+
dev/tests/static/testsuite/Magento/Test/Php/_files/phpmd/ruleset.xml
7+
8+
Only the specific rules Magento select from each built-in ruleset are
9+
included — entire rulesets (e.g. cleancode, full naming) are intentionally
10+
avoided, matching Magento's own choices.
11+
12+
Magento-specific custom rules (AllPurposeAction, CookieAndSessionMisuse,
13+
UnusedFormalParameter) require the Magento framework class-path and are
14+
enforced by the installed Magento instance's own static test suite rather
15+
than here.
16+
-->
217
<ruleset name="CtiDigital Configurator PHPMD Rules"
318
xmlns="http://pmd.sf.net/ruleset/1.0.0"
419
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
520
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
621
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
722
>
8-
<description>
9-
PHPMD ruleset for magento2-configurator.
10-
Enforces the same rulesets used in the initial technical lead review
11-
(all violations resolved before this config was committed).
12-
</description>
23+
<!-- Code Size Rules (selected, matching Magento core) -->
24+
<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>
25+
<rule ref="rulesets/codesize.xml/NPathComplexity"/>
26+
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>
27+
<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>
28+
<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>
29+
<rule ref="rulesets/codesize.xml/TooManyFields"/>
30+
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity">
31+
<properties>
32+
<property name="maximum" value="100"/>
33+
</properties>
34+
</rule>
35+
36+
<!-- Unused Code Rules (full set, minus UnusedFormalParameter — Magento
37+
use a custom version of this rule that understands plugin signatures) -->
38+
<rule ref="rulesets/unusedcode.xml">
39+
<exclude name="UnusedFormalParameter"/>
40+
</rule>
41+
42+
<!-- Design Rules (selected, matching Magento core) -->
43+
<rule ref="rulesets/design.xml/NumberOfChildren"/>
44+
<rule ref="rulesets/design.xml/DepthOfInheritance">
45+
<properties>
46+
<property name="minimum" value="8"/>
47+
</properties>
48+
</rule>
49+
<rule ref="rulesets/design.xml/CouplingBetweenObjects"/>
1350

14-
<rule ref="rulesets/cleancode.xml"/>
15-
<rule ref="rulesets/codesize.xml"/>
16-
<rule ref="rulesets/design.xml"/>
17-
<rule ref="rulesets/naming.xml"/>
18-
<rule ref="rulesets/unusedcode.xml"/>
51+
<!-- Naming Rules (selected, matching Magento core) -->
52+
<rule ref="rulesets/naming.xml/ShortMethodName"/>
53+
<rule ref="rulesets/naming.xml/ConstantNamingConventions"/>
54+
<rule ref="rulesets/naming.xml/BooleanGetMethodName"/>
1955
</ruleset>

0 commit comments

Comments
 (0)