Create new phpcs rules

This commit is contained in:
QWp6t
2015-12-27 23:13:05 -08:00
committed by Ben Word
parent 1df3fee010
commit 2d02544173
4 changed files with 62 additions and 47 deletions

View File

@@ -43,5 +43,6 @@ install:
script: script:
- npm run build - npm run build
- phpcs --standard=ruleset.xml --extensions=php --ignore=node_modules,bower_components,vendor -n -s . - phpcs --report=summary
- phpcs --report=summary --standard=phpcs-templates.xml -n
- phpmd src text cleancode,codesize,controversial,design,naming,unusedcode - phpmd src text cleancode,codesize,controversial,design,naming,unusedcode

43
phpcs-templates.xml Normal file
View File

@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<ruleset name="Roots">
<description>Roots Templates Coding Standards</description>
<!-- Scan these files by default -->
<file>templates</file>
<!-- Show colors in console -->
<arg value="-colors"/>
<!-- Show sniff codes in all reports -->
<arg value="s"/>
<!-- Use PSR-2 as a base -->
<rule ref="PSR2">
<!-- Allow closing braces to be on the same line -->
<exclude name="Squiz.WhiteSpace.ScopeClosingBrace"/>
<!-- Disable newline after opening brace -->
<exclude name="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"/>
<!-- Allow multiple PHP statements in the same line -->
<exclude name="Generic.Formatting.DisallowMultipleStatements.SameLine"/>
<!-- Disable PSR-2 indentation rules that are buggy with 2 spaces -->
<exclude name="PSR2.ControlStructures.SwitchDeclaration.BreakIndent"/>
<exclude name="PSR2.Methods.FunctionCallSignature.Indent"/>
<!-- Don't require a blank line after the last `use` -->
<exclude name="PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse"/>
<!-- Allow PHP closing tags -->
<exclude name="PSR2.Files.ClosingTag.NotAllowed"/>
</rule>
<!-- Force 2 spaces indentation -->
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="2"/>
<property name="tabIndent" value="false"/>
</properties>
</rule>
</ruleset>

17
phpcs.xml Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<ruleset name="Roots">
<description>Roots Coding Standards</description>
<!-- Use PSR-2 as a base -->
<rule ref="PSR2"/>
<!-- Show colors in console -->
<arg value="-colors"/>
<!-- Show sniff codes in all reports -->
<arg value="s"/>
<!-- Scan these files -->
<file>functions.php</file>
<file>src</file>
</ruleset>

View File

@@ -1,46 +0,0 @@
<?xml version="1.0"?>
<ruleset name="Roots">
<description>Roots Coding Standards</description>
<!-- Use PSR-2 as a base -->
<rule ref="PSR2">
<!-- Allow opening and closing braces for functions and classes to be on the same line -->
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine"/>
<exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine"/>
<exclude name="Squiz.WhiteSpace.ScopeClosingBrace"/>
<!-- Disable newline after opening brace -->
<exclude name="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"/>
<!-- Allow multiple PHP statements in the same line (usually in template files) -->
<exclude name="Generic.Formatting.DisallowMultipleStatements.SameLine"/>
<!-- Disable PSR-2 indentation rules that are buggy with 2 spaces -->
<exclude name="PSR2.ControlStructures.SwitchDeclaration.BreakIndent"/>
<exclude name="PSR2.Methods.FunctionCallSignature.Indent"/>
</rule>
<!-- Don't require a blank line after the last `use` in templates/ directory -->
<rule ref="PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse">
<exclude-pattern>templates/*</exclude-pattern>
</rule>
<!-- Allow PHP closing tags on templates -->
<rule ref="PSR2.Files.ClosingTag.NotAllowed">
<exclude-pattern>templates/*</exclude-pattern>
</rule>
<!-- Force 2 spaces indentation -->
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="2"/>
<property name="tabIndent" value="false"/>
</properties>
</rule>
<!-- Verify that operators have valid spacing surrounding them -->
<rule ref="Squiz.WhiteSpace.OperatorSpacing"/>
<!-- Force braces to be on the same lines in function declarations -->
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
</ruleset>