Skip to content
Open
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ 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.
- Added exclude patterns for *.phtml
- Added exclude for UnusedFormalParameter to allow unused parameters in a function
- Added exception for short variable name for $id
- PHPCS Excluded Magento2.Annotation.MethodAnnotationStructure.MethodAnnotation
### Fixed
- Updated property for LongVariable did not work.

## [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
4 changes: 3 additions & 1 deletion config/default/phpmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<!-- Boolean flags are sometimes needed to preserve e.g. backwards compatibility. We don't want to enforce this in a blanket
statement / default rule but if projects want to enforce this they are free to do so. -->
<exclude name="BooleanArgumentFlag"/>

<exclude name="LongVariable"/>
</rule>

<rule ref="rulesets/codesize.xml" />
Expand All @@ -30,4 +32,4 @@
</properties>
</rule>
<!-- End of global ruleset -->
</ruleset>
</ruleset>
26 changes: 18 additions & 8 deletions config/magento2/phpmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,38 @@
<exclude name="BooleanArgumentFlag"/>
</rule>

<rule ref="rulesets/codesize.xml" />
<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="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>
<!-- 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 -->
<rule ref="rulesets/design.xml">
<exclude name="CouplingBetweenObjects"/>
<!-- $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 -->
<rule ref="rulesets/design.xml/CouplingBetweenObjects">
<properties>
<property name="maximum" value="20"/>
</properties>
</rule>

</ruleset>
</ruleset>
8 changes: 8 additions & 0 deletions config/magento2/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
<ruleset name="Youwe/Magento2">
<description>Youwe coding standard extensions for sniffing code in Magento 2 projects.</description>

<exclude-pattern>*.phtml</exclude-pattern>
<exclude-pattern>./app/etc/config.php</exclude-pattern>
<exclude-pattern>/.ddev/*</exclude-pattern>
<exclude-pattern>./env-dev.php</exclude-pattern>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should remove the ./env-dev.php as it is not a magento 2 standard
Also we store it inside the .dddev folder these days
We should pick one standard to exclude imho ;)

<exclude-pattern>./tests/*</exclude-pattern>

<!-- Use default Youwe coding standards for PHP projects. -->
<rule ref="../default" />
<!-- Magento coding standards -->
<rule ref="Magento2" >
<!-- Not all functions require doc blocks -->
<exclude name="Magento2.Annotation.MethodAnnotationStructure.NoCommentBlock"/>
<!-- Not all functions require a short description (Missing short description) -->
<exclude name="Magento2.Annotation.MethodAnnotationStructure.MethodAnnotation" />
<!-- Not all class properties require doc blocks -->
<exclude name="Magento2.Commenting.ClassPropertyPHPDocFormatting.Missing"/>
<!--
Expand Down
2 changes: 1 addition & 1 deletion templates/files/default/phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>PHPCS</description>
<rule ref="./vendor/youwe/testing-suite/config/default"/>
<rule ref="./vendor/youwe/testing-suite/config/default" />
<!-- Append arg -s to phpcs to display the name of failed sniffs -->
<arg value="s"/>

Expand Down
4 changes: 2 additions & 2 deletions templates/files/drupal/phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>PHPCS</description>
<rule ref="./vendor/youwe/testing-suite/config/drupal"/>
<rule ref="./vendor/youwe/testing-suite/config/drupal" />
<!-- Append arg -s to phpcs to display the name of failed sniffs -->
<arg value="s"/>

<!--<exclude-pattern>path/to/exclude/*</exclude-pattern>-->
</ruleset>
</ruleset>
9 changes: 1 addition & 8 deletions templates/files/magento2/phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>PHPCS</description>
<rule ref="./vendor/youwe/testing-suite/config/magento2"/>
<rule ref="./vendor/youwe/testing-suite/config/magento2" />
<!-- Append arg -s to phpcs to display the name of failed sniffs -->
<arg value="s"/>

<!-- Magento specific file exclusions -->
<exclude-pattern>app/etc/config.php</exclude-pattern>
<exclude-pattern>env-dev.php</exclude-pattern>
<exclude-pattern>deploy.php</exclude-pattern>
<exclude-pattern>pub/errors/*</exclude-pattern>
<exclude-pattern>.ddev</exclude-pattern>
</ruleset>