Skip to content

Commit

Permalink
Check our code style for every PR
Browse files Browse the repository at this point in the history
This includes the currently failing checks with automatic fixes, as they
are out of scope of this commit. The current goal is automatically
reject pull requests that don't me the standards that the rest of our
code base already follows.
  • Loading branch information
micgro42 committed Dec 28, 2019
1 parent 9ec1015 commit 0e5ea85
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/phpCS.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: PHP Code Style

on: [push]

jobs:
phpcs:
name: PHP CodeSniffer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Setup PHP
uses: nanasess/setup-php@master
with:
php-version: 7.3

- name: Download PHPCS
run: wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar

- name: run PHP codesniffer
run: php phpcs.phar -v --standard=_test/phpcs.xml .
60 changes: 60 additions & 0 deletions _test/phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,66 @@

<!-- we have lots of legacy classes without name spaces -->
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>

<!-- Rules with automatic fixes that we want to adhere to, but currently don't -->
<exclude name="Generic.PHP.LowerCaseKeyword.Found"/>
<exclude name="Generic.PHP.LowerCaseConstant.Found"/>
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma"/>
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma"/>
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma"/>
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact"/>
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect"/>
<exclude name="Generic.WhiteSpace.IncrementDecrementSpacing.SpaceAfterDecrement"/>
<exclude name="Generic.WhiteSpace.IncrementDecrementSpacing.SpaceAfterIncrement"/>

<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis"/>
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword"/>
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace"/>
<exclude name="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"/>
<exclude name="Squiz.ControlStructures.ForEachLoopDeclaration.NoSpaceBeforeArrow"/>
<exclude name="Squiz.ControlStructures.ForEachLoopDeclaration.NoSpaceAfterArrow"/>
<exclude name="Squiz.ControlStructures.ForEachLoopDeclaration.SpacingBeforeAs"/>
<exclude name="Squiz.ControlStructures.ForLoopDeclaration.SpacingAfterSecond"/>
<exclude name="Squiz.ControlStructures.ForLoopDeclaration.NoSpaceAfterSecond"/>
<exclude name="Squiz.ControlStructures.ForLoopDeclaration.NoSpaceAfterFirst"/>
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.NoSpaceBeforeArg"/>
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceAfterEquals"/>
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterReference"/>
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBeforeClose"/>
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceBeforeEquals"/>
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine"/>
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.NewlineBeforeOpenBrace"/>
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.CloseBracketLine"/>
<exclude name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen"/>
<exclude name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose"/>
<exclude name="Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore"/>
<exclude name="Squiz.WhiteSpace.ScopeClosingBrace.Indent"/>
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EndLine"/>

<exclude name="PSR2.Classes.ClassDeclaration.CloseBraceAfterBody"/>
<exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine"/>
<exclude name="PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace"/>
<exclude name="PSR2.ControlStructures.ControlStructureSpacing.SpaceBeforeCloseBrace"/>
<exclude name="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed"/>
<exclude name="PSR2.ControlStructures.SwitchDeclaration.BreakIndent"/>
<exclude name="PSR2.ControlStructures.SwitchDeclaration.BreakNotNewLine"/>
<exclude name="PSR2.ControlStructures.SwitchDeclaration.BodyOnNextLineCASE"/>
<exclude name="PSR2.ControlStructures.SwitchDeclaration.SpaceBeforeColonDEFAULT"/>
<exclude name="PSR2.ControlStructures.SwitchDeclaration.SpaceBeforeColonCASE"/>
<exclude name="PSR2.Files.EndFileNewline.TooMany"/>
<exclude name="PSR2.Files.EndFileNewline.NoneFound"/>
<exclude name="PSR2.Methods.FunctionCallSignature.Indent"/>
<exclude name="PSR2.Methods.FunctionCallSignature.EmptyLine"/>
<exclude name="PSR2.Methods.FunctionCallSignature.ContentAfterOpenBracket"/>
<exclude name="PSR2.Methods.FunctionCallSignature.SpaceBeforeOpenBracket"/>
<exclude name="PSR2.Methods.FunctionCallSignature.CloseBracketLine"/>
<exclude name="PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket"/>
<exclude name="PSR2.Methods.FunctionCallSignature.SpaceAfterOpenBracket"/>
<exclude name="PSR2.Methods.FunctionCallSignature.MultipleArguments"/>
<exclude name="PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose"/>
<exclude name="PSR2.Methods.MethodDeclaration.StaticBeforeVisibility"/>
<exclude name="PSR2.Namespaces.NamespaceDeclaration.BlankLineAfter"/>
<exclude name="PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse"/>
</rule>

<!-- disable some rules for certain paths, for legacy support -->
Expand Down

0 comments on commit 0e5ea85

Please sign in to comment.