Skip to content
Closed
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.0.3]
### Changed
- Magento phpmd.xml loosened some rules to be more inline with what is 'normal' in Magento.

## [3.0.2]
### Changed
- Constraint for `bitexpert/phpstan-magento` from '~0.30' to '>=0.30' to allow for installing newer PHPStan versions when needed.
Expand Down
31 changes: 25 additions & 6 deletions config/magento2/phpmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,40 @@
<exclude name="BooleanArgumentFlag"/>
</rule>

<rule ref="rulesets/codesize.xml" />
<rule ref="rulesets/codesize.xml">
<!-- Number of parameters often exceed 10 due to the dependency injection system -->
<exclude name="ExcessiveParameterList" />
</rule>

<rule ref="rulesets/design.xml" />
<rule ref="rulesets/unusedcode.xml" />
<rule ref="rulesets/naming.xml" />
<rule ref="rulesets/unusedcode.xml">
<!-- In Magento unused parameters are common, for example in plugins, $subject is required, but often not used. -->
<exclude name="UnusedLocalVariable" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to me that excluding UnusedFormalParameter only is enough and that UnusedLocalVariable actually is undesired behaviour

image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @youwe-petervanderwal , you are absolutely right. I will change it.

This PR will be closed, all changes are included in the next PR:
#66

<exclude name="UnusedFormalParameter" />

</rule>
<rule ref="rulesets/naming.xml">
<!-- For these rules we have exceptions configured below -->
<exclude name="LongVariable" />
<exclude name="ShortVariable" />
</rule>

<rule ref="rulesets/naming.xml/LongVariable">
<properties>
<!-- 20 limit is hard to make descriptive, plus has historically been 30 so also for better backwards compatibility support -->
<property name="maximum" value="30"/>
</properties>
</rule>

<!-- $id is a very common (and accepted) ShortVariable -->
<rule ref="rulesets/naming.xml/ShortVariable">
<properties>
<property name="exceptions" value="id" />
</properties>
</rule>
<!-- End of global ruleset -->

<!-- Increase maximum amount of coupling, because magento constructor injection can become quite extreme and is mostly an adobe issue to fix -->
<!-- Increase maximum amount of coupling, because Magento constructor injection can become quite extreme and is mostly an adobe issue to fix -->
<rule ref="rulesets/design.xml">
<exclude name="CouplingBetweenObjects"/>
</rule>
Expand All @@ -41,5 +61,4 @@
<property name="maximum" value="20"/>
</properties>
</rule>

</ruleset>
</ruleset>