MD_QA/rules/md_phpcs_rules.xml

299 lines
11 KiB
XML
Raw Normal View History

2020-10-10 21:28:18 +02:00
<?xml version="1.0"?>
<ruleset name="museumdigital">
<description>Coding standard for museum-digital.
Based on Zend with some additions.</description>
2021-09-15 14:42:04 +02:00
<arg name="tab-width" value="4"/>
2020-10-10 21:28:18 +02:00
<!-- Handle commenting -->
<rule ref='PEAR.Commenting.FunctionComment'/>
2021-09-15 14:42:04 +02:00
<!-- <rule ref='Generic.Commenting'/> -->
2020-10-10 21:28:18 +02:00
<!-- <rule ref='Generic.Commenting.DocComment' /> -->
2021-09-15 14:42:04 +02:00
<rule ref='Squiz.Commenting.DocCommentAlignment'/>
2020-10-10 21:28:18 +02:00
<rule ref='Squiz.Commenting.FunctionComment'/>
<rule ref='Squiz.Commenting.ClassComment'/>
2021-09-15 14:42:04 +02:00
<rule ref='SlevomatCodingStandard.PHP.UselessParentheses'/>
<rule ref='SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking'/>
<!-- <rule ref='SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable'/> -->
<rule ref='SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable'/>
<!-- <rule ref='SlevomatCodingStandard.Variables.UnusedVariable'/> -->
<!-- <rule ref='SlevomatCodingStandard.Variables.UselessVariable'/> -->
<rule ref='SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace'/>
<rule ref='SlevomatCodingStandard.Classes.ConstantSpacing'/>
<rule ref='SlevomatCodingStandard.PHP.TypeCast'/>
<!-- <rule ref='SlevomatCodingStandard.Classes.ClassConstantVisibility'/> -->
<rule ref='SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing'/>
<rule ref='SlevomatCodingStandard.TypeHints.PropertyTypeHintSpacing'/>
<rule ref="SlevomatCodingStandard.Classes.ClassStructure">
<properties>
<property name="groups" type="array">
<element value="uses"/>
<!-- Public constants are first but you don't care about the order of protected or private constants -->
<element value="public constants"/>
<element value="constants"/>
<!-- You don't care about the order among the properties. The same can be done with "properties" shortcut -->
<element value="public static properties, protected static properties, private static properties"/>
<element value="public properties, protected properties, private properties"/>
<element value="methods"/>
<element value="magic methods"/>
<element value="constructor"/>
<element value="destructor"/>
</property>
</properties>
</rule>
2020-10-10 21:28:18 +02:00
<!--
<rule ref='PEAR.ControlStructures.ControlSignature'>
<properties>
<property name="spacing" value="5" />
</properties>
</rule>
-->
<rule ref='PEAR.ControlStructures.MultiLineCondition'/>
<rule ref='Squiz.ControlStructures.ElseIfDeclaration'/>
<rule ref='Squiz.ControlStructures.ForEachLoopDeclaration'/>
<rule ref='Squiz.ControlStructures.ForLoopDeclaration'/>
<!--
Warn about lines longer than 100 chars,
and error for lines longer than 135 chars.
-> This is currently disabled, as HTML lines easily go beyond any reasonable limits if they include links.
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="130" />
<property name="absoluteLineLimit" value="140" />
</properties>
</rule>
-->
<!-- Don't check function braces, but check closure braces. -->
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie">
<properties>
<property name="checkFunctions" value="false" />
<property name="checkClosures" value="true" />
</properties>
</rule>
<rule ref="Generic.Debug.ClosureLinter">
<properties>
<property name="errorCodes" type="array" value="0210"/>
<property name="ignoreCodes" type="array" value="0001,0110,0240"/>
</properties>
</rule>
<rule ref='Generic.CodeAnalysis.UnconditionalIfStatement'/>
<rule ref='Generic.CodeAnalysis.UnusedFunctionParameter'/>
<rule ref='PEAR.Files'/>
<rule ref='PEAR.Formatting'/>
<rule ref='Generic.Functions.OpeningFunctionBraceKernighanRitchie'/>
<rule ref='Generic.Functions.FunctionCallArgumentSpacing'/>
<!--
<rule ref='PEAR.Functions.FunctionCallSignature'/>
<rule ref='PEAR.Functions.FunctionDeclaration'/>
-->
<rule ref='Squiz.Functions.FunctionDeclaration'/>
<rule ref='PEAR.Functions.ValidDefaultValue'/>
<rule ref='PEAR.NamingConventions.ValidClassName'/>
2021-09-15 14:42:04 +02:00
<!-- <rule ref="Squiz.Classes.ValidClassName"/>-->
2020-10-10 21:28:18 +02:00
<!--
Have code block comments look like // end foreach() etc.
<rule ref="Squiz.Commenting.LongConditionClosingComment">
<properties>
<property name="commentFormat" value="// end" />
</properties>
</rule>
-->
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1" />
</properties>
</rule>
<rule ref='Zend.Files.ClosingTag'/>
<!--
<rule ref='PEAR.NamingConventions.ValidFunctionName'/>
<rule ref='Zend.NamingConventions.ValidVariableName' />
We may enforce these at some point in time. We don't at the moment.
2021-09-15 14:42:04 +02:00
2020-10-10 21:28:18 +02:00
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="24" />
<property name="absoluteComplexity" value="36" />
</properties>
</rule>
2021-09-15 14:42:04 +02:00
-->
2020-10-10 21:28:18 +02:00
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="nestingLevel" value="24" />
<property name="absoluteNestingLevel" value="30" />
</properties>
</rule>
<rule ref='PEAR.NamingConventions.ValidVariableName' />
2021-09-15 14:42:04 +02:00
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<rule ref="Generic.Files.ByteOrderMark"/>
2020-10-10 21:28:18 +02:00
<rule ref='Generic.PHP.DeprecatedFunctions' />
<rule ref='Generic.PHP.CharacterBeforePHPOpeningTag' />
2021-09-15 14:42:04 +02:00
<rule ref="Generic.PHP.DisallowAlternativePHPTags"/>
2020-10-10 21:28:18 +02:00
<rule ref='Generic.PHP.DisallowShortOpenTag' />
<!--
-->
2021-09-15 14:42:04 +02:00
<rule ref='Generic.Classes.OpeningBraceSameLine' />
2020-10-10 21:28:18 +02:00
<rule ref='Generic.PHP.NoSilencedErrors' />
<rule ref='Generic.PHP.SAPIUsage' />
<rule ref='Generic.PHP.Syntax' />
<rule ref='Generic.Arrays.DisallowLongArraySyntax' />
<rule ref='Generic.Files.LineEndings' />
2021-09-15 14:42:04 +02:00
<rule ref='Generic.Files.InlineHTML' />
2020-10-10 21:28:18 +02:00
<rule ref='Generic.Functions.OpeningFunctionBraceKernighanRitchie' />
<!--
Forbidden functinos.
Using this sniff, it is established that count is preferred over sizeof() etc.
Notably, we use the OOP style for mysqli function calls.
-->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<!-- Starting phpcs 3.3 we should use this
<property name="forbiddenFunctions" type="array">
<element key="delete" value="unset"/>
<element key="print" value="echo"/>
<element key="create_function" value="null"/>
<element key="system" value="null"/>
<element key="sizeof" value="count"/>
</property>
-->
<property name="forbiddenFunctions" type="array" value="delete=>unset,print=>echo,create_function=>null,system=>null,sizeof=>count,mysql_query=>mysqli_query,mysqli_query=>null,mysql_num_rows=>mysqli_num_rows,mysqli_num_rows=>null,mysql_error=>mysqli_error,mysqli_stmt_init=>null,mysqli_stmt_close=>null,mysqli_real_escape_string=>null,mysqli_fetch_array=>mysqli_fetch_assoc,mysqli_fetch_assoc=>null,session_id=>null,print_r=>null,var_dump=>null" />
</properties>
</rule>
<rule ref="Internal.NoCodeFound">
</rule>
<!--
<rule ref="Squiz.PHP.DiscouragedFunctions">
<properties>
<property name="error" value="true" />
</properties>
</rule>
-->
<rule ref='Squiz.PHP.DisallowSizeFunctionsInLoops'/>
<rule ref='Squiz.Strings.EchoedStrings'/>
<rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="1" />
</properties>
</rule>
<rule ref='PEAR.WhiteSpace'/>
<rule ref='Generic.WhiteSpace.DisallowTabIndent'/>
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<properties>
<property name="allowMultiline" value="true" />
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true" />
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- <property name="ignoreBlankLines" value="true" /> -->
</properties>
</rule>
<!-- Ensure 1 blank line before and after functions, except at the top and bottom. -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0" />
<property name="spacingAfterLast" value="0" />
</properties>
</rule>
<rule ref='Squiz.WhiteSpace.SemicolonSpacing'/>
<rule ref='Squiz.WhiteSpace.ScopeKeywordSpacing'/>
<rule ref='Squiz.WhiteSpace.ScopeClosingBrace'/>
<rule ref='Squiz.WhiteSpace.CastSpacing'/>
<rule ref='Squiz.WhiteSpace.FunctionClosingBraceSpace'/>
2021-09-15 14:42:04 +02:00
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<!-- PHP keywords MUST be in lower case. -->
<rule ref="Generic.PHP.LowerCaseKeyword"/>
<!-- The PHP constants true, false, and null MUST be in lower case. -->
<rule ref="Generic.PHP.LowerCaseConstant"/>
<rule ref="PSR2.Classes.PropertyDeclaration.SpacingAfterType" />
<!-- 4.3 Methods -->
<!-- Visibility MUST be declared on all methods. -->
<rule ref="Squiz.Scope.MethodScope"/>
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>
<rule ref="Squiz.Functions.LowercaseFunctionKeywords"/>
<!-- <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen"/> -->
<!-- <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose"/> -->
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/>
<!-- <rule ref="Squiz.ControlStructures.ControlSignature"/> -->
<!-- <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/> -->
<rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
<rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingAfterOpen">
<severity>0</severity>
</rule>
<rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingBeforeClose">
| <severity>0</severity>
</rule>
<rule ref="Squiz.ControlStructures.LowercaseDeclaration"/>
<!-- <rule ref="Generic.ControlStructures.InlineControlStructure"/> -->
2020-10-10 21:28:18 +02:00
<rule ref='Squiz.PHP.Eval'/>
<rule ref='Squiz.PHP.DisallowBooleanStatement'/>
2021-09-15 14:42:04 +02:00
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
2020-10-10 21:28:18 +02:00
<rule ref='Squiz.Arrays.ArrayBracketSpacing'/>
<!--
<rule ref='Squiz.Operators.ComparisonOperatorUsage'/>
CSS
-->
<!-- Include some CSS rules I want to enforce
-->
<rule ref='Squiz.CSS.DuplicateStyleDefinition'/>
<rule ref='Squiz.CSS.ClassDefinitionNameSpacing'/>
<rule ref='Squiz.CSS.ColonSpacing'/>
<rule ref='Squiz.CSS.EmptyClassDefinition'/>
<!-- <rule ref='Squiz.CSS.ColourDefinition'/> -->
<rule ref='Squiz.CSS.SemicolonSpacing'/>
<!--
Javascript
-->
<rule ref='Generic.Debug.JSHint'/>
<rule ref='Squiz.Debug.JSLint'/>
</ruleset>