Skip to content

Commit

Permalink
Merged in feature/POLICY-3 (pull request #1)
Browse files Browse the repository at this point in the history
Create ruleset

Approved-by: Klaas Sangers
  • Loading branch information
Ashoka de Wit authored and Klaas Sangers committed Mar 14, 2017
2 parents e83d50b + bdc4bb4 commit 68cbcca
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 0 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Introduction

This is the MediaCT coding standard for Magento 1 projects. It is a mix of the
default MediaCT coding standard and the Magento marketplace standard.

Some tests have been removed from both of the standards to create a workable
and fast standard.

# Installation

Use composer to require the standard in a project.

```shell
$ composer require --dev mediact/coding-standard-magento1
```

To let PHPCS know that this standard should be used add a phpcs.xml file in the
root of the project.

```xml
<?xml version="1.0"?>
<ruleset>
<rule ref="./vendor/mediact/coding-standard-magento1/src/MediactMagento1"/>
</ruleset>
```

# Integration with PHPStorm

When the phpcs.xml file exists it will be automatically configured by
`media/coding-standard-phpstorm`. This is triggered by the composer command.

```shell
$ composer install
```

# Contribution guidelines

Contributions are welcome. Please create pull requests which add or remove
tests.
83 changes: 83 additions & 0 deletions src/MediactMagento1/ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0"?>
<!--
/**
* Copyright MediaCT. All rights reserved.
* https://www.mediact.nl
*/
-->
<ruleset name="Mediact/Magento1">
<description>MediaCT coding standards for Magento1.</description>
<arg name="colors" />
<arg name="extensions" value="php/PHP,phtml/PHP,js/JS,css/CSS" />

<!-- Base rules on MediaCT -->
<rule ref="../../../coding-standard/src/MediactCommon">
<exclude name="PSR1.Classes.ClassDeclaration"/>
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing" />
<exclude name="MediactCommon.Php7.ReturnType" />
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing" />
<exclude name="PSR2.Methods.MethodDeclaration.Underscore" />
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore" />
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows" />
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning" />
<exclude name="Generic.Commenting.DocComment.TagValueIndent" />
<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamType" />
<exclude name="Generic.PHP.Syntax"/>
</rule>

<!-- Base rules on Magento Marketplace -->
<rule ref="../../../../magento/marketplace-eqp/MEQP1">
<exclude name="PSR1.Classes.ClassDeclaration" />
<exclude name="Zend.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>
<exclude name="Generic.Arrays.DisallowShortArraySyntax" />
<exclude name="MEQP1.PHP.PrivateClassMember" />
<exclude name="MEQP1.Performance.EmptyCheck.FoundCount" />
<exclude name="MEQP1.Security.DiscouragedFunction" />
<exclude name="MEQP1.Performance.Loop" />
<exclude name="MEQP1.SQL.SlowQuery" />
<exclude name="MEQP1.Performance.InefficientMethods"/>
<exclude name="Generic.Functions.OpeningFunctionBraceBsdAllman" />
<exclude name="MEQP1.Performance.CollectionCount"/>
<exclude name="MEQP1.Templates.XssTemplate"/>
<exclude name="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket"/>
<exclude name="MEQP1.PHP.Syntax"/>
<exclude name="MEQP1.Stdlib.DateTime"/>
</rule>

<rule ref="MEQP1.Classes.ResourceModel.OutsideOfResourceModel">
<exclude-pattern>Model/Resource</exclude-pattern>
</rule>
<rule ref="MediactCommon.NamingConventions.ValidVariableName">
<properties>
<property name="allowedNames" type="array" value="_eventPrefix,_eventObject,_cacheTag,_addButtonLabel,_backButtonLabel,_blockGroup,_GET,_POST,_COOKIE,_FILES,_REQUEST,_SERVER,_SESSION"/>
</properties>
<exclude-pattern>*.phtml</exclude-pattern>
</rule>
<rule ref="Squiz.PHP.CommentedOutCode">
<properties>
<property name="maxPercentage" value="80"/>
</properties>
</rule>
<rule ref="Zend.NamingConventions.ValidVariableName.NotCamelCaps">
<exclude-pattern>*.phtml</exclude-pattern>
</rule>
<rule ref="Generic.Files.LineLength.TooLong">
<exclude-pattern>*.phtml</exclude-pattern>
</rule>
<rule ref="Squiz.ControlStructures.ControlSignature">
<exclude-pattern>*.phtml</exclude-pattern>
</rule>
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace">
<exclude-pattern>*.phtml</exclude-pattern>
</rule>
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace.Line">
<exclude-pattern>*.phtml</exclude-pattern>
</rule>
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing">
<exclude-pattern>*.phtml</exclude-pattern>
</rule>
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed">
<exclude-pattern>*.phtml</exclude-pattern>
</rule>
</ruleset>

0 comments on commit 68cbcca

Please sign in to comment.