|
3 | 3 | /**
|
4 | 4 | * Copyright Youwe. All rights reserved.
|
5 | 5 | * https://www.youweagency.com
|
| 6 | + * |
| 7 | + * TODO:: Create a separate ruleset for phtml files, since a lot of exceptions need to be made just for adding phtml to code sniffer. |
6 | 8 | */
|
7 | 9 | -->
|
8 | 10 | <ruleset name="YouweMagento2">
|
9 | 11 | <description>Youwe coding standards for Magento2 websites and modules</description>
|
10 |
| - |
11 |
| - <arg name="colors" /> |
12 |
| - <arg name="extensions" value="php/PHP,phtml/PHP,js/JS,css/CSS" /> |
| 12 | + <!-- TODO:: Check if these values are correct. Did not see anything about how to configure this in documentation --> |
| 13 | + <arg name="extensions" value="php/PHP,phtml/PHP,js/JS,css/CSS,xml/XML,less/CSS" /> |
13 | 14 |
|
14 | 15 | <!-- Base rules on Youwe -->
|
15 | 16 | <rule ref="Youwe">
|
| 17 | + <!-- Magento 2 does not use return types everywhere in the code base yet. So we cannot make this mandatory. --> |
16 | 18 | <exclude name="GlobalCommon.Php7.ReturnType" />
|
17 |
| - <exclude name="PSR2.Methods.MethodDeclaration.Underscore" /> |
| 19 | + <!-- Magento 2 still uses $_ to tell if it's protected, so we cannot mandate this. --> |
| 20 | + <exclude name="GlobalCommon.NamingConventions.ValidVariableName" /> |
| 21 | + <!-- TODO:: Check if this rule still needs to be excluded. Seems logical that all classes should start with camelcase --> |
18 | 22 | <exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
|
| 23 | + <!--TODO:: Check if this should not be excluded. Seems logical to add throws in function comment. --> |
19 | 24 | <exclude name="Squiz.Commenting.FunctionComment.EmptyThrows" />
|
| 25 | + <!-- Magento 2 still does not strict type arguments of functions. This is why this rule is excluded. --> |
20 | 26 | <exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing" />
|
| 27 | + <!-- Magento 2 still does not strict type arguments of functions. This is why this rule is excluded. --> |
21 | 28 | <exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing" />
|
22 | 29 | </rule>
|
23 | 30 |
|
24 | 31 | <!-- Import most rules from official Magento2 coding standard -->
|
25 | 32 | <rule ref="Magento2">
|
| 33 | + <!-- Excluded because short descriptions are not mandatory in Youwe for a method. --> |
26 | 34 | <exclude name="Magento2.Annotation" />
|
| 35 | + <!-- |
| 36 | + Excluded because in PHP 8.1 it's already possible to declare what type it is. |
| 37 | + Also most class properties are self-explanatory. |
| 38 | + --> |
27 | 39 | <exclude name="Magento2.Commenting.ClassPropertyPHPDocFormatting" />
|
28 | 40 | </rule>
|
29 | 41 |
|
30 |
| - <rule ref="Generic.Files.LineLength.TooLong"> |
31 |
| - <exclude-pattern>*.phtml,*.xml</exclude-pattern> |
| 42 | + <!-- Detects function that use a for-loops call in their function. --> |
| 43 | + <rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed"> |
| 44 | + <exclude-pattern>*.phtml</exclude-pattern> |
32 | 45 | </rule>
|
33 | 46 |
|
34 |
| - <rule ref="Squiz.ControlStructures.ControlSignature"> |
| 47 | + <rule ref="Generic.Commenting.DocComment"> |
| 48 | + <!-- default Magento 2 templates also not cohere to this. --> |
35 | 49 | <exclude-pattern>*.phtml</exclude-pattern>
|
36 | 50 | </rule>
|
37 | 51 |
|
38 |
| - <rule ref="Squiz.WhiteSpace.ScopeClosingBrace"> |
| 52 | + <rule ref="Generic.ControlStructures.InlineControlStructure.NotAllowed"> |
| 53 | + <!-- Magento 2 templates do not cohere to this rule. --> |
39 | 54 | <exclude-pattern>*.phtml</exclude-pattern>
|
40 | 55 | </rule>
|
41 | 56 |
|
42 |
| - <rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed"> |
| 57 | + <rule ref="Generic.Files.LineLength.TooLong"> |
| 58 | + <!-- Magento 2 phtml & xml both have long lines think of checkout_index_index.xml --> |
| 59 | + <exclude-pattern>*.phtml</exclude-pattern> |
| 60 | + <exclude-pattern>*.xml</exclude-pattern> |
| 61 | + </rule> |
| 62 | + |
| 63 | + <rule ref="PEAR.Functions.FunctionCallSignature"> |
| 64 | + <!-- default Magento 2 templates also not cohere to this. --> |
43 | 65 | <exclude-pattern>*.phtml</exclude-pattern>
|
44 | 66 | </rule>
|
45 | 67 |
|
46 | 68 | <rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
|
| 69 | + <!-- In some cases Magento 2 still uses underscores for their properties. --> |
| 70 | + <exclude-pattern>*.phtml</exclude-pattern> |
| 71 | + </rule> |
| 72 | + |
| 73 | + <rule ref="PSR2.ControlStructures.ControlStructureSpacing"> |
| 74 | + <!-- default Magento 2 templates also not cohere to this. --> |
| 75 | + <exclude-pattern>*.phtml</exclude-pattern> |
| 76 | + </rule> |
| 77 | + |
| 78 | + <rule ref="PSR12.ControlStructures.ControlStructureSpacing"> |
| 79 | + <!-- default Magento 2 templates also not cohere to this. --> |
| 80 | + <exclude-pattern>*.phtml</exclude-pattern> |
| 81 | + </rule> |
| 82 | + |
| 83 | + <rule ref="PSR12.Files.FileHeader.SpacingAfterBlock"> |
| 84 | + <!-- default Magento 2 templates also not cohere to this. --> |
| 85 | + <exclude-pattern>*.phtml</exclude-pattern> |
| 86 | + </rule> |
| 87 | + |
| 88 | + <rule ref="PSR12.Operators.OperatorSpacing"> |
| 89 | + <!-- default Magento 2 templates also not cohere to this. --> |
| 90 | + <exclude-pattern>*.phtml</exclude-pattern> |
| 91 | + </rule> |
| 92 | + |
| 93 | + <rule ref="Squiz.ControlStructures.ControlSignature"> |
| 94 | + <!-- Magento 2 uses a different notation for patterns like do { / if { for phtml that's why this was excluded. --> |
| 95 | + <exclude-pattern>*.phtml</exclude-pattern> |
| 96 | + </rule> |
| 97 | + |
| 98 | + <rule ref="Squiz.WhiteSpace.ControlStructureSpacing"> |
| 99 | + <!-- default Magento 2 templates also not cohere to this. --> |
47 | 100 | <exclude-pattern>*.phtml</exclude-pattern>
|
48 | 101 | </rule>
|
49 | 102 |
|
|
53 | 106 | </properties>
|
54 | 107 | </rule>
|
55 | 108 |
|
56 |
| - <rule ref="PSR12.Functions.ReturnTypeDeclaration" /> |
| 109 | + <rule ref="Squiz.WhiteSpace.ScopeClosingBrace"> |
| 110 | + <!-- Magento 2 phptml files end differently and use endif; for example. --> |
| 111 | + <exclude-pattern>*.phtml</exclude-pattern> |
| 112 | + </rule> |
57 | 113 | </ruleset>
|
0 commit comments