| <?xml version="1.0"?> |
| <ruleset> |
| <rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki"> |
| <exclude name="MediaWiki.PHPUnit.AssertCount.NotUsed" /> |
| <exclude name="MediaWiki.Usage.StaticClosure.StaticClosure" /> |
| </rule> |
| |
| <!-- The function comment sniff is way to rigorous about way to many details that need |
| exceptions: |
| * It complains about missing documentation on fully self-explanatory function headers |
| with strict type hints. |
| * It complains about missing documentation if there is a proper @see tag. |
| * It complains about duplicate spaces in "@param <type> $<var>", but removing these |
| doesn't make the code easier to read. |
| * It does not understand "@param <type> [$optional,…]. --> |
| <rule ref="MediaWiki.Commenting.FunctionComment"> |
| <severity>0</severity> |
| </rule> |
| <rule ref="MediaWiki.Commenting.PropertyDocumentation"> |
| <severity>0</severity> |
| </rule> |
| |
| <!-- Starting a function's body with an empty line can be helpful after a very large header. |
| The code is not guaranteed to be easier to read if this is disallowed. --> |
| <rule ref="MediaWiki.WhiteSpace.DisallowEmptyLineFunctions"> |
| <severity>0</severity> |
| </rule> |
| |
| <!-- Even if we encourage to use a space in "function ()", we don't think this sniff should |
| block patches from being merged. --> |
| <rule ref="MediaWiki.WhiteSpace.SpaceAfterClosure"> |
| <severity>0</severity> |
| </rule> |
| |
| <!-- Even if we encourage to use spaces in comments, we don't think this sniff should block |
| patches from being merged. --> |
| <rule ref="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment"> |
| <severity>0</severity> |
| </rule> |
| |
| <!-- Disallows any content outside of <?php … ?> tags. --> |
| <rule ref="Generic.Files.InlineHTML" /> |
| |
| <rule ref="MediaWiki.NamingConventions.LowerCamelFunctionsName"> |
| <!-- Exclude test methods like "testGivenInvalidInput_methodThrowsException". --> |
| <exclude-pattern>tests*Test*\.php</exclude-pattern> |
| </rule> |
| <rule ref="Generic.PHP.NoSilencedErrors.Discouraged"> |
| <exclude-pattern>tests/phpunit/*</exclude-pattern> |
| </rule> |
| |
| <!-- NOTE: We can not use the Squiz.Arrays.ArrayBracketSpacing sniff because it conflicts with |
| the MediaWiki style that encourages to use spaces inside brackets, see |
| https://www.mediawiki.org/wiki/Manual:Coding_conventions/JavaScript#Whitespace --> |
| |
| <rule ref="Squiz.Functions.GlobalFunction" /> |
| |
| <!-- NOTE: Do not add the Squiz.Strings.DoubleQuoteUsage sniff. Even if we encourage to prefer |
| single quotes, we don't think double quotes should block patches from being merged. --> |
| |
| <rule ref="MediaWiki.Classes.FullQualifiedClassName"> |
| <severity>5</severity> |
| <properties> |
| <property name="allowFunctions" value="false" /> |
| </properties> |
| </rule> |
| |
| <rule ref="MediaWiki.Commenting.ClassLevelLicense"> |
| <properties> |
| <property name="license" value="GPL-2.0-or-later" /> |
| </properties> |
| </rule> |
| |
| <rule ref="Generic.Files.LineLength"> |
| <properties> |
| <property name="lineLimit" value="140" /> |
| </properties> |
| <exclude-pattern>view/resources/templates\.php</exclude-pattern> |
| </rule> |
| |
| <rule ref="Generic.Classes.DuplicateClassName"> |
| <exclude-pattern>Scribunto_LuaWikibaseLibraryTestCase</exclude-pattern> |
| </rule> |
| <!-- NOTE: We purposely decided against additional Generic.CodeAnalysis.… sniffs, because they |
| all have possible exceptions, and are not meant to block patches from being merged. --> |
| <rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"> |
| <exclude-pattern>WikibaseClient\.example\.php</exclude-pattern> |
| </rule> |
| <rule ref="Generic.Files.OneObjectStructurePerFile"> |
| <exclude-pattern>Scribunto_LuaWikibaseLibraryTestCase</exclude-pattern> |
| </rule> |
| <rule ref="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle"> |
| <exclude-pattern>RepoHooks\.php</exclude-pattern> |
| </rule> |
| <rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses"> |
| <exclude-pattern>Scribunto_LuaWikibaseLibraryTestCase</exclude-pattern> |
| </rule> |
| <rule ref="Squiz.Classes.ValidClassName.NotCamelCaps"> |
| <exclude-pattern>Scribunto_LuaWikibase*</exclude-pattern> |
| </rule> |
| <rule ref="MediaWiki.Commenting.LicenseComment.LicenseTagNonFileComment"> |
| <exclude-pattern>Scribunto_LuaWikibaseLibraryTestCase\.php</exclude-pattern> |
| <exclude-pattern>DispatchingQueryBuilderTest\.php</exclude-pattern> |
| </rule> |
| <rule ref="MediaWiki.Commenting.PhpunitAnnotations.NotClassTrait"> |
| <exclude-pattern>DispatchingQueryBuilderTest\.php</exclude-pattern> |
| </rule> |
| <rule ref="MediaWiki.Usage.ForbiddenFunctions.assert"> |
| <exclude-pattern>ItemChangeTest\.php</exclude-pattern> |
| <exclude-pattern>ChunkCache\.php</exclude-pattern> |
| </rule> |
| <rule ref="MediaWiki.Usage.ForbiddenFunctions.shell_exec"> |
| <exclude-pattern>PidLock\.php</exclude-pattern> |
| </rule> |
| |
| <rule ref="Generic.Metrics.CyclomaticComplexity"> |
| <properties> |
| <property name="complexity" value="16" /> |
| </properties> |
| <exclude-pattern>(RdfWriterFactory|UrlSchemeValidators)</exclude-pattern> |
| </rule> |
| <rule ref="Generic.Metrics.NestingLevel" /> |
| |
| <rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"> |
| <exclude name="SlevomatCodingStandard.Files.TypeNameMatchesFileName.NoMatchBetweenTypeNameAndFileName" /> |
| <properties> |
| <property name="spacesCountBeforeColon" value="0" /> |
| </properties> |
| </rule> |
| |
| <rule ref="repo/rest-api/ruleset.xml"> |
| <include-pattern>repo/rest-api</include-pattern> |
| </rule> |
| |
| <file>.</file> |
| <arg name="extensions" value="php" /> |
| <arg name="encoding" value="UTF-8" /> |
| <arg name="bootstrap" value="./vendor/mediawiki/mediawiki-codesniffer/utils/bootstrap-ci.php"/> |
| <exclude-pattern>.phan/stubs</exclude-pattern> |
| <exclude-pattern>repo/tests/browser</exclude-pattern> |
| <exclude-pattern>view/lib/wikibase-api/WikibaseJavaScriptApi.php</exclude-pattern> |
| <exclude-pattern>node_modules/*</exclude-pattern> |
| <exclude-pattern type="relative">^extensions/</exclude-pattern> |
| </ruleset> |