Use phpcs.xml for all rules

This commit is contained in:
QWp6t
2015-12-28 15:28:21 -08:00
committed by Ben Word
parent c5f3724efd
commit 246955c59a
4 changed files with 45 additions and 48 deletions

View File

@@ -44,5 +44,4 @@ install:
script:
- npm run build
- phpcs --report=summary
- phpcs --report=summary --standard=phpcs-templates.xml -n
- phpmd src text cleancode,codesize,controversial,design,naming,unusedcode

View File

@@ -1,43 +0,0 @@
<?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>

View File

@@ -3,8 +3,9 @@
<description>Roots Coding Standards</description>
<!-- Scan these files -->
<file>functions.php</file>
<file>src</file>
<file>templates</file>
<file>functions.php</file>
<file>src</file>
<!-- Show colors in console -->
<arg value="-colors"/>
@@ -14,7 +15,47 @@
<!-- Use PSR-2 as a base -->
<rule ref="PSR2">
<!-- Allow braces on same line for procedural functions -->
<!-- Allow braces on same line for named functions -->
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine"/>
</rule>
<!-- Allow closing braces to be on the same line -->
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace">
<exclude-pattern>templates</exclude-pattern>
</rule>
<!-- Disable newline after opening brace -->
<rule ref="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace">
<exclude-pattern>templates</exclude-pattern>
</rule>
<!-- Allow multiple PHP statements in the same line -->
<rule ref="Generic.Formatting.DisallowMultipleStatements.SameLine">
<exclude-pattern>templates</exclude-pattern>
</rule>
<!-- Disable PSR-2 indentation rules that are buggy with 2 spaces -->
<rule ref="PSR2.ControlStructures.SwitchDeclaration.BreakIndent">
<exclude-pattern>templates</exclude-pattern>
</rule>
<!-- Don't require a blank line after the last `use` -->
<rule ref="PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse">
<exclude-pattern>templates</exclude-pattern>
</rule>
<!-- Allow long lines -->
<rule ref="Generic.Files.LineLength.TooLong">
<exclude-pattern>templates</exclude-pattern>
</rule>
<!-- Ignore indentation rules -->
<rule ref="Generic.WhiteSpace.ScopeIndent">
<exclude-pattern>templates</exclude-pattern>
</rule>
<!-- Allow PHP closing tags -->
<rule ref="PSR2.Files.ClosingTag.NotAllowed">
<exclude-pattern>templates</exclude-pattern>
</rule>
</ruleset>

View File

@@ -8,7 +8,7 @@ use Roots\Sage\Template\Wrapper;
* @link https://codex.wordpress.org/Conditional_Tags
*/
add_filter('sage/display_sidebar', function ($display) {
// The sidebar will NOT be displayed if ANY of the following return true
// The sidebar will NOT be displayed if ANY of the following return true
return $display ? !in_array(true, [
is_404(),
is_front_page(),