Skip to content

Commit

Permalink
Split out temporary code style excludes
Browse files Browse the repository at this point in the history
Splitting them out allows for plugins to use _test/phpcs.xml as the
basis for their own linting without having an overly permissive coding
standard.
Also, this makes it more obvious and painful that these are just
intended as temporary exceptions and should be actually fixed.

The rule `Generic.ControlStructures.InlineControlStructure.NotAllowed`
has been moved to the section with the temporary excludes and had its
comment removed as it is in fact in PSR-2 (and -12) and can also be
auto-fixed by phpcbf. See squizlabs/PHP_CodeSniffer#2744

The rule `PSR1.Classes.ClassDeclaration.MissingNamespace` has to remain
in the DokuWiki coding standard as the plugin base classes can currently
not reasonably be in namespaces.
  • Loading branch information
micgro42 committed Jan 21, 2020
1 parent b5f2c10 commit f16368f
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpCS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
run: wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar

- name: run PHP codesniffer
run: php phpcs.phar -v --standard=_test/phpcs.xml
run: php phpcs.phar -v --standard=_test/phpcs_MigrationAdjustments.xml
101 changes: 1 addition & 100 deletions _test/phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,88 +34,10 @@
<exclude-pattern>*/inc/cli.php</exclude-pattern>
<exclude-pattern>*/inc/parser/*</exclude-pattern>

<!-- rules on top of PSR-2 -->
<!-- rules on top of PSR-12 -->
<rule ref="PSR12">
<!-- the following rule is not in PSR-2 and breaks the guardian pattern -->
<exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed"/>

<!-- 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.Formatting.DisallowMultipleStatements.SameLine"/>
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma"/>
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma"/>
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma"/>
<exclude name="Generic.PHP.LowerCaseKeyword.Found"/>
<exclude name="Generic.PHP.LowerCaseConstant.Found"/>
<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.Classes.PropertyDeclaration.StaticBeforeVisibility"/>
<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"/>

<exclude name="PSR12.Classes.ClassInstantiation.MissingParentheses"/>
<exclude name="PSR12.ControlStructures.BooleanOperatorPlacement.FoundMixed"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.FirstExpressionLine"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.CloseParenthesisLine"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.LineIndent"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.SpaceBeforeCloseBrace"/>
<exclude name="PSR12.Files.FileHeader.SpacingAfterBlock"/>
<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceBefore"/>
<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceAfter"/>

<exclude name="PSR12.Properties.ConstantVisibility.NotFound"/>
</rule>

<!-- disable some rules for certain paths, for legacy support -->
Expand Down Expand Up @@ -152,25 +74,4 @@
<exclude-pattern>*/inc/Extension/PluginInterface.php</exclude-pattern>
<exclude-pattern>*/inc/Extension/PluginTrait.php</exclude-pattern>
</rule>

<!-- for now we mix declarations and execution here (mostly for defines) -->
<rule ref="PSR1.Files.SideEffects">
<exclude-pattern>*/index.php</exclude-pattern>
<exclude-pattern>*/inc/parserutils.php</exclude-pattern>
<exclude-pattern>*/inc/mail.php</exclude-pattern>
<exclude-pattern>*/inc/init.php</exclude-pattern>
<exclude-pattern>*/inc/farm.php</exclude-pattern>
<exclude-pattern>*/inc/fulltext.php</exclude-pattern>
<exclude-pattern>*/inc/pluginutils.php</exclude-pattern>
<exclude-pattern>*/inc/indexer.php</exclude-pattern>
<exclude-pattern>*/inc/Mailer.class.php</exclude-pattern>
<exclude-pattern>*/doku.php</exclude-pattern>
<exclude-pattern>*/install.php</exclude-pattern>
<exclude-pattern>*/inc/utf8.php</exclude-pattern>
<exclude-pattern>*/feed.php</exclude-pattern>
<exclude-pattern>*/inc/load.php</exclude-pattern>
<exclude-pattern>*/bin/*.php</exclude-pattern>
<exclude-pattern>*/lib/exe/*.php</exclude-pattern>
</rule>

</ruleset>
104 changes: 104 additions & 0 deletions _test/phpcs_MigrationAdjustments.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0"?>
<ruleset name="Migration Adjustments for the DokuWiki Coding Standard Standard" namespace="DokuWiki\CS\Standard">
<description>These are exceptions to the Coding Standard used for DokuWiki that are intended to be removed over time.</description>

<!-- rules on top of PSR-12 -->
<rule ref="./phpcs.xml">
<!-- Rules with automatic fixes that we want to adhere to, but currently don't -->
<exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed"/>
<exclude name="Generic.Formatting.DisallowMultipleStatements.SameLine"/>
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma"/>
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma"/>
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma"/>
<exclude name="Generic.PHP.LowerCaseKeyword.Found"/>
<exclude name="Generic.PHP.LowerCaseConstant.Found"/>
<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.Classes.PropertyDeclaration.StaticBeforeVisibility"/>
<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"/>

<exclude name="PSR12.Classes.ClassInstantiation.MissingParentheses"/>
<exclude name="PSR12.ControlStructures.BooleanOperatorPlacement.FoundMixed"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.FirstExpressionLine"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.CloseParenthesisLine"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.LineIndent"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.SpaceBeforeCloseBrace"/>
<exclude name="PSR12.Files.FileHeader.SpacingAfterBlock"/>
<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceBefore"/>
<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceAfter"/>

<exclude name="PSR12.Properties.ConstantVisibility.NotFound"/>
</rule>

<!-- for now we mix declarations and execution here (mostly for defines) -->
<rule ref="PSR1.Files.SideEffects">
<exclude-pattern>*/index.php</exclude-pattern>
<exclude-pattern>*/inc/parserutils.php</exclude-pattern>
<exclude-pattern>*/inc/mail.php</exclude-pattern>
<exclude-pattern>*/inc/init.php</exclude-pattern>
<exclude-pattern>*/inc/farm.php</exclude-pattern>
<exclude-pattern>*/inc/fulltext.php</exclude-pattern>
<exclude-pattern>*/inc/pluginutils.php</exclude-pattern>
<exclude-pattern>*/inc/indexer.php</exclude-pattern>
<exclude-pattern>*/inc/Mailer.class.php</exclude-pattern>
<exclude-pattern>*/doku.php</exclude-pattern>
<exclude-pattern>*/install.php</exclude-pattern>
<exclude-pattern>*/inc/utf8.php</exclude-pattern>
<exclude-pattern>*/feed.php</exclude-pattern>
<exclude-pattern>*/inc/load.php</exclude-pattern>
<exclude-pattern>*/bin/*.php</exclude-pattern>
<exclude-pattern>*/lib/exe/*.php</exclude-pattern>
</rule>

</ruleset>

0 comments on commit f16368f

Please sign in to comment.