| 1 |
<?xml version="1.0"?> |
| 2 |
<ruleset name="Seravo"> |
| 3 |
<description> |
| 4 |
Seravo coding standards definition. Mostly WordPress coding standards, but relaxed a bit to be |
| 5 |
easier on developers. |
| 6 |
</description> |
| 7 |
|
| 8 |
<!-- Show sniff progress --> |
| 9 |
<arg value="p"/> |
| 10 |
|
| 11 |
<!-- All files should be UTF-8 encoded. --> |
| 12 |
<arg name="encoding" value="utf-8"/> |
| 13 |
|
| 14 |
<!-- check current and all subfolders if no file parameter given. --> |
| 15 |
<file>.</file> |
| 16 |
|
| 17 |
<!-- Don't check composer dependencies and extras --> |
| 18 |
<exclude-pattern>/vendor/</exclude-pattern> |
| 19 |
<exclude-pattern>/tests/</exclude-pattern> |
| 20 |
|
| 21 |
<!-- Extend the exclude patterns to match your .gitignore --> |
| 22 |
|
| 23 |
|
| 24 |
<!-- |
| 25 |
Include WordPress Coding Standards with some exclusions. WordPress-Extra contains an extended |
| 26 |
ruleset for recommended best practices, see |
| 27 |
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards#rulesets for details |
| 28 |
about different WordPress subsets. |
| 29 |
--> |
| 30 |
<rule ref="WordPress-Extra"> |
| 31 |
|
| 32 |
<!-- Allow text-domain from variable --> |
| 33 |
<exclude name="WordPress.WP.I18n.NonSingularStringLiteralDomain" /> |
| 34 |
|
| 35 |
<!-- Allow spaces in indentation --> |
| 36 |
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed" /> |
| 37 |
|
| 38 |
<!-- Don't use precision alignment --> |
| 39 |
<exclude name="WordPress.WhiteSpace.PrecisionAlignment" /> |
| 40 |
|
| 41 |
<!-- |
| 42 |
The generic exact whitespace sniff does not work very well with inline HTML, so ignore it. |
| 43 |
--> |
| 44 |
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact" /> |
| 45 |
|
| 46 |
<!-- |
| 47 |
Exclude WordPress array indent as it causes false positivies, is not very customizable |
| 48 |
and we already use Generic.Arrays.ArrayIndent. |
| 49 |
--> |
| 50 |
<exclude name="WordPress.Arrays.ArrayIndentation.ItemNotAligned" /> |
| 51 |
|
| 52 |
|
| 53 |
<!-- |
| 54 |
Causes false errors "Multi-line array item not aligned correctly" when indenting with |
| 55 |
2 spaces instead of 4. |
| 56 |
--> |
| 57 |
<exclude name="WordPress.Arrays.ArrayIndentation.MultiLineArrayItemNotAligned" /> |
| 58 |
|
| 59 |
<!-- There is no need to align equals signs or array keys --> |
| 60 |
<exclude name="Generic.Formatting.MultipleStatementAlignment" /> |
| 61 |
<exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned" /> |
| 62 |
|
| 63 |
<!-- |
| 64 |
Don't enforce the usage of excessive amounts of whitespace around opening/closing |
| 65 |
brackets and around variables as array keys. |
| 66 |
--> |
| 67 |
<exclude name="WordPress.WhiteSpace.CastStructureSpacing.NoSpaceBeforeOpenParenthesis" /> |
| 68 |
<exclude name="WordPress.WhiteSpace.OperatorSpacing.NoSpaceBefore" /> |
| 69 |
<exclude name="WordPress.Arrays.ArrayKeySpacingRestrictions" /> |
| 70 |
|
| 71 |
<!-- Yoda Condition checks reduce code readability with very little benefit --> |
| 72 |
<exclude name="WordPress.PHP.YodaConditions.NotYoda" /> |
| 73 |
|
| 74 |
<!-- Don't enforce the usage of class files with name "class-*.php". --> |
| 75 |
<exclude name="WordPress.Files.FileName.InvalidClassFileName" /> |
| 76 |
|
| 77 |
<!-- We need to use PHP system calls to provide graphical wrappers for CLI commands. --> |
| 78 |
<exclude name="WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec" /> |
| 79 |
|
| 80 |
<!-- |
| 81 |
Don't enforce the usage of escaped output in every situation, the security risks should be |
| 82 |
assessed separately. Also we can't always use nonces e.g. for APIs... |
| 83 |
--> |
| 84 |
<exclude name="WordPress.Security.EscapeOutput.UnsafePrintingFunction" /> |
| 85 |
<exclude name="WordPress.Security.EscapeOutput.OutputNotEscaped" /> |
| 86 |
<exclude name="WordPress.CSRF.NonceVerification.NoNonceVerification" /> |
| 87 |
<exclude name="WordPress.Security.NonceVerification" /> |
| 88 |
</rule> |
| 89 |
|
| 90 |
|
| 91 |
<!-- Include Security sniffs --> |
| 92 |
<rule ref="Security"> |
| 93 |
<!-- |
| 94 |
Ignore the ErrMiscIncludeMismatchNoExt sniff because it causes |
| 95 |
unnecessary errors on dynamically reated require paths, e.g. |
| 96 |
>>> require_once 'something-' . $somevar . '.php'; |
| 97 |
--> |
| 98 |
<exclude name="PHPCS_Security.Misc.IncludeMismatch.ErrMiscIncludeMismatchNoExt" /> |
| 99 |
</rule> |
| 100 |
|
| 101 |
|
| 102 |
<!-- Include PHP compatibility sniffs --> |
| 103 |
<rule ref="PHPCompatibility" /> |
| 104 |
|
| 105 |
<!-- Set minimum supporter PHP version --> |
| 106 |
<config name="testVersion" value="7.1-"/> |
| 107 |
|
| 108 |
|
| 109 |
<!-- |
| 110 |
Add some custom sniff rules in this section below. See |
| 111 |
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties and |
| 112 |
https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties |
| 113 |
for available sniffs and their properties. |
| 114 |
--> |
| 115 |
|
| 116 |
<!-- Set 2 spaces indentation for function call signature --> |
| 117 |
<rule ref="PEAR.Functions.FunctionCallSignature"> |
| 118 |
<properties> |
| 119 |
<property name="indent" value="2" /> |
| 120 |
<property name="requiredSpacesAfterOpen" value="0"/> |
| 121 |
<property name="requiredSpacesBeforeClose" value="0"/> |
| 122 |
<property name="allowMultipleArguments" value="false"/> |
| 123 |
</properties> |
| 124 |
</rule> |
| 125 |
|
| 126 |
<!-- |
| 127 |
Indent using two (2) spaces instead of tabs. Otherwise, use the same settings as WP Core |
| 128 |
sniffs use. |
| 129 |
--> |
| 130 |
<rule ref="Generic.WhiteSpace.ScopeIndent"> |
| 131 |
<properties> |
| 132 |
<property name="exact" value="false"/> |
| 133 |
<property name="indent" value="2"/> |
| 134 |
<property name="tabIndent" value="false"/> |
| 135 |
<property name="ignoreIndentationTokens" type="array"> |
| 136 |
<element value="T_HEREDOC"/> |
| 137 |
<element value="T_NOWDOC"/> |
| 138 |
<element value="T_INLINE_HTML"/> |
| 139 |
</property> |
| 140 |
</properties> |
| 141 |
</rule> |
| 142 |
|
| 143 |
<!-- |
| 144 |
The soft limit on line length is 100 characters. However, do not trigger errors if the limit |
| 145 |
is exceeded. |
| 146 |
--> |
| 147 |
<rule ref="Generic.Files.LineLength"> |
| 148 |
<properties> |
| 149 |
<property name="lineLimit" value="100"/> |
| 150 |
<property name="absoluteLineLimit" value="0"/> |
| 151 |
</properties> |
| 152 |
</rule> |
| 153 |
|
| 154 |
<!-- Set 2 spaces indentation for switch terminating case statement --> |
| 155 |
<rule ref="PSR2.ControlStructures.SwitchDeclaration"> |
| 156 |
<properties> |
| 157 |
<property name="indent" value="2" /> |
| 158 |
</properties> |
| 159 |
</rule> |
| 160 |
|
| 161 |
<!-- Enforce that multiline arrays are indented with two spaces --> |
| 162 |
<rule ref="Generic.Arrays.ArrayIndent"> |
| 163 |
<properties> |
| 164 |
<property name="tabIndent" value="false" /> |
| 165 |
<property name="indent" value="2" /> |
| 166 |
</properties> |
| 167 |
</rule> |
| 168 |
|
| 169 |
<!-- Explicitly forbid tabs --> |
| 170 |
<rule ref="Generic.WhiteSpace.DisallowTabIndent" /> |
| 171 |
|
| 172 |
<!-- Don't use spaces in arbitrary parentheses --> |
| 173 |
<rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing"> |
| 174 |
<properties> |
| 175 |
<property name="ignoreNewlines" value="true" /> |
| 176 |
<property name="spacing" value="0" /> |
| 177 |
</properties> |
| 178 |
</rule> |
| 179 |
|
| 180 |
</ruleset> |
| 181 |
|