Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"phpcs": "./vendor/bin/phpcs --standard=phpcs.xml",
"phpcs:fix": "./vendor/bin/phpcbf --standard=phpcs.xml",
"phpcs:output": "./vendor/bin/phpcs --standard=phpcs.xml --report=json lib/ 2>/dev/null | tail -1 > phpcs-output.json",
"phpmd": "if [ -f vendor/bin/phpmd ]; then ./vendor/bin/phpmd lib text phpmd.xml --baseline-file phpmd.baseline.xml; else echo 'PHPMD not installed, skipping...'; fi",
"phpmd": "./vendor/bin/phpmd lib text phpmd.xml --baseline-file phpmd.baseline.xml",
"phpmetrics": "./vendor/bin/phpmetrics --report-html=phpmetrics lib/",
"phpmetrics:violations": "./vendor/bin/phpmetrics --violations-xml=phpmetrics/violations.xml lib/",
"psalm": "if [ -f vendor/bin/psalm ]; then ./vendor/bin/psalm --threads=1 --no-cache; else echo 'Psalm not installed, skipping...'; fi",
Expand Down
27 changes: 26 additions & 1 deletion phpmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,32 @@
<rule ref="rulesets/design.xml/NumberOfChildren"/>
<rule ref="rulesets/design.xml/DepthOfInheritance"/>
<rule ref="rulesets/design.xml/CouplingBetweenObjects"/>
<rule ref="rulesets/design.xml/DevelopmentCodeFragment"/>
<!-- DevelopmentCodeFragment MUST carry ignore-namespaces=true, or it is dead
code in this ruleset. See ConductionNL/openregister#2286.

PDepend resolves an unqualified call inside a namespaced file to the
CURRENT-NAMESPACE-qualified image, so `var_dump($x)` in
`namespace OCA\MyApp\Service;` reaches the rule as
`OCA\MyApp\Service\var_dump`, which never matches the
`unwanted-functions` list. All of our production PHP is namespaced, so
with the default (false) the rule catches nothing anywhere.

Measured on phpmd 2.15.0 / PHP 8.3.32: byte-identical probe class,
namespaced -> exit 0, non-namespaced -> exit 2. With
ignore-namespaces=true the rule strips the enclosing namespace before
matching, the namespaced probe is reported (exit 2), and a clean
namespaced file stays exit 0.

Note: hydra gate 2 (forbidden-patterns) independently greps lib/ for
var_dump / die / error_log / print_r / dd / dump and is the broader
control - it also catches calls outside methods, which this rule (a
MethodAware/FunctionAware rule) cannot see. This rule is the
`composer check:strict` half of the same guard; keep both. -->
<rule ref="rulesets/design.xml/DevelopmentCodeFragment">
<properties>
<property name="ignore-namespaces" value="true"/>
</properties>
</rule>
<rule ref="rulesets/design.xml/EmptyCatchBlock"/>
<rule ref="rulesets/design.xml/CountInLoopExpression"/>

Expand Down
Loading