MD_QA/rules/md_phpcs_rules.xml

222 lines
7.8 KiB
XML

<?xml version="1.0"?>
<ruleset name="museumdigital">
<description>Coding standard for museum-digital.
Based on Zend with some additions.</description>
<!-- Handle commenting -->
<!-- <rule ref='Generic.Commenting'/> -->
<rule ref='PEAR.Commenting.FunctionComment'/>
<!-- <rule ref='Generic.Commenting.DocComment' /> -->
<rule ref='Squiz.Commenting.DocCommentAlignment'/>
<rule ref='Squiz.Commenting.FunctionComment'/>
<rule ref='Squiz.Commenting.ClassComment'/>
<!--
<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'/>
<!--
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.
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="24" />
<property name="absoluteComplexity" value="36" />
</properties>
</rule>
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="nestingLevel" value="24" />
<property name="absoluteNestingLevel" value="30" />
</properties>
</rule>
-->
<rule ref='PEAR.NamingConventions.ValidVariableName' />
<rule ref='Generic.PHP.DeprecatedFunctions' />
<rule ref='Generic.PHP.CharacterBeforePHPOpeningTag' />
<rule ref='Generic.PHP.DisallowShortOpenTag' />
<!--
<rule ref='Generic.Classes.OpeningBraceSameLine' />
-->
<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' />
<!--<rule ref='Generic.Files.InlineHTML' />-->
<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'/>
<rule ref='Squiz.PHP.Eval'/>
<rule ref='Squiz.PHP.DisallowBooleanStatement'/>
<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>