Skip to content

Commit 5b11497

Browse files
Ashoka de WitKlaas Sangers
Ashoka de Wit
authored and
Klaas Sangers
committed
Merged in feature/POLICY-3 (pull request #1)
Create ruleset Approved-by: Klaas Sangers
2 parents 35e3300 + ea0efeb commit 5b11497

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Introduction
2+
3+
This is the MediaCT coding standard for Magento 2 projects. It is a mix of the
4+
default MediaCT coding standard and the Magento marketplace standard.
5+
6+
Some tests have been removed from both of the standards to create a workable
7+
and fast standard.
8+
9+
# Installation
10+
11+
Use composer to require the standard in a project.
12+
13+
```shell
14+
$ composer require --dev mediact/coding-standard-magento2
15+
```
16+
17+
To let PHPCS know that this standard should be used add a phpcs.xml file in the
18+
root of the project.
19+
20+
```xml
21+
<?xml version="1.0"?>
22+
<ruleset>
23+
<rule ref="./vendor/mediact/coding-standard-magento2/src/MediactMagento2"/>
24+
</ruleset>
25+
```
26+
27+
# Integration with PHPStorm
28+
29+
When the phpcs.xml file exists it will be automatically configured by
30+
`media/coding-standard-phpstorm`. This is triggered by the composer command.
31+
32+
```shell
33+
$ composer install
34+
```
35+
36+
# Contribution guidelines
37+
38+
Contributions are welcome. Please create pull requests which add or remove
39+
tests.

src/MediactMagento2/ruleset.xml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright MediaCT. All rights reserved.
5+
* https://www.mediact.nl
6+
*/
7+
-->
8+
<ruleset name="Mediact/Magento1">
9+
<description>MediaCT coding standards for Magento1.</description>
10+
<arg name="colors" />
11+
<arg name="extensions" value="php/PHP,phtml/PHP,js/JS,css/CSS" />
12+
13+
<!-- Base rules on MediaCT -->
14+
<rule ref="../../../coding-standard/src/MediactCommon">
15+
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
16+
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing" />
17+
<exclude name="MediactCommon.Php7.ReturnType" />
18+
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing" />
19+
<exclude name="PSR2.Methods.MethodDeclaration.Underscore" />
20+
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore" />
21+
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows" />
22+
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning" />
23+
<exclude name="Generic.Commenting.DocComment.TagValueIndent" />
24+
<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamType" />
25+
<exclude name="Generic.PHP.Syntax"/>
26+
</rule>
27+
28+
<!-- Base rules on Magento Marketplace -->
29+
<rule ref="../../../../magento/marketplace-eqp/MEQP1">
30+
<exclude name="MEQP1.Classes"/>
31+
<exclude name="MEQP1.PHP.PrivateClassMember"/>
32+
<exclude name="MEQP1.Exceptions.DirectThrow"/>
33+
<exclude name="MEQP1.PHP.Syntax"/>
34+
<exclude name="MEQP1.Security.Acl"/>
35+
<exclude name="MEQP1.Security.Superglobal"/>
36+
<exclude name="MEQP1.Classes.ObjectInstantiation"/>
37+
<exclude name="MEQP1.Templates.XssTemplate"/>
38+
<exclude name="MEQP1.Stdlib.DateTime"/>
39+
<exclude name="MEQP1.SQL.MissedIndexes"/>
40+
<exclude name="MEQP1.SQL.SlowQuery"/>
41+
<exclude name="MEQP1.Security.DiscouragedFunction" />
42+
<exclude name="MEQP1.Performance.Loop" />
43+
<exclude name="Generic.Functions.OpeningFunctionBraceBsdAllman" />
44+
<exclude name="Zend.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>
45+
</rule>
46+
<rule ref="../../../../magento/marketplace-eqp/MEQP2">
47+
<exclude name="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket"/>
48+
<exclude name="MEQP2.PHP.Syntax"/>
49+
<exclude name="Generic.Arrays.DisallowShortArraySyntax" />
50+
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.Found"/>
51+
</rule>
52+
53+
<rule ref="Squiz.PHP.CommentedOutCode">
54+
<properties>
55+
<property name="maxPercentage" value="80"/>
56+
</properties>
57+
</rule>
58+
<rule ref="Generic.Files.LineLength.TooLong">
59+
<exclude-pattern>*.phtml</exclude-pattern>
60+
</rule>
61+
<rule ref="Squiz.ControlStructures.ControlSignature">
62+
<exclude-pattern>*.phtml</exclude-pattern>
63+
</rule>
64+
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace">
65+
<exclude-pattern>*.phtml</exclude-pattern>
66+
</rule>
67+
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing">
68+
<exclude-pattern>*.phtml</exclude-pattern>
69+
</rule>
70+
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed">
71+
<exclude-pattern>*.phtml</exclude-pattern>
72+
</rule>
73+
</ruleset>

0 commit comments

Comments
 (0)