2 <ruleset name="MediaWiki">
3 <rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
4 <exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate" />
5 <exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
6 <exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
7 <exclude name="MediaWiki.Commenting.FunctionComment.WrongStyle" />
8 <exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPrivate" />
9 <exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationProtected" />
10 <exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPublic" />
11 <exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingVar" />
12 <exclude name="MediaWiki.Commenting.PropertyDocumentation.SpacingAfter" />
13 <exclude name="MediaWiki.Commenting.PropertyDocumentation.WrongStyle" />
14 <exclude name="MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures" />
15 <exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName" />
16 <exclude name="MediaWiki.Usage.DbrQueryUsage.DbrQueryFound" />
17 <exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle" />
18 <exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgVersion" />
19 <exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage" />
20 <exclude name="MediaWiki.Usage.ForbiddenFunctions.passthru" />
21 <exclude name="MediaWiki.Usage.SuperGlobalsUsage.SuperGlobals" />
22 <exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
23 <exclude name="PSR2.Classes.PropertyDeclaration.Multiple" />
25 <rule ref="MediaWiki.NamingConventions.PrefixedGlobalFunctions">
28 maintenance/language/transstat.php
33 maintenance/storage/moveToExternal.php
35 maintenance/storage/resolveStubs.php
38 tests/phpunit/includes/HooksTest.php
41 tests/qunit/data/styleTest.css.php
44 <property name="ignoreList" type="array" value="cssfilter,mccGetHelp,mccShowUsage,moveToExternal,NothingFunction,NothingFunctionData,resolveStub,resolveStubs,showUsage" />
47 <rule ref="MediaWiki.NamingConventions.ValidGlobalName">
49 <property name="ignoreList" type="array" value="$IP" />
52 <rule ref="MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix">
53 <exclude-pattern>*/maintenance/doMaintenance\.php</exclude-pattern>
54 <exclude-pattern>*/maintenance/mergeMessageFileList\.php</exclude-pattern>
55 <exclude-pattern>*/maintenance/CommandLineInc\.php</exclude-pattern>
56 <exclude-pattern>*/tests/phpunit/MediaWikiIntegrationTestCase\.php</exclude-pattern>
58 <rule ref="Generic.Classes.DuplicateClassName.Found">
59 <exclude-pattern>*/includes/libs/rdbms/dbal/MWPostgreSqlPlatformCompat\.php</exclude-pattern>
61 <rule ref="Generic.Files.LineLength">
62 <exclude-pattern>*/languages/messages/*</exclude-pattern>
63 <exclude-pattern>*/tests/*</exclude-pattern>
65 <rule ref="MediaWiki.Files.ClassMatchesFilename.NotMatch">
67 Continue to allow existing violations, but enable the sniff to prevent
70 <exclude-pattern>*/includes/specials/SpecialMostimages\.php</exclude-pattern>
71 <exclude-pattern>*/includes/specials/SpecialMovepage\.php</exclude-pattern>
72 <exclude-pattern>*/includes/specials/SpecialUserrights\.php</exclude-pattern>
73 <exclude-pattern>*/includes/specials/SpecialWantedfiles\.php</exclude-pattern>
74 <exclude-pattern>*/includes/specials/SpecialWantedpages\.php</exclude-pattern>
75 <exclude-pattern>*/maintenance/benchmarks/bench_HTTP_HTTPS\.php</exclude-pattern>
76 <exclude-pattern>*/maintenance/benchmarks/bench_Wikimedia_base_convert\.php</exclude-pattern>
77 <exclude-pattern>*/maintenance/benchmarks/bench_delete_truncate\.php</exclude-pattern>
78 <exclude-pattern>*/maintenance/benchmarks/bench_if_switch\.php</exclude-pattern>
79 <exclude-pattern>*/maintenance/benchmarks/bench_utf8_title_check\.php</exclude-pattern>
80 <exclude-pattern>*/maintenance/cleanupTitles\.php</exclude-pattern>
81 <exclude-pattern>*/maintenance/edit\.php</exclude-pattern>
82 <exclude-pattern>*/maintenance/findDeprecated\.php</exclude-pattern>
83 <exclude-pattern>*/maintenance/getText\.php</exclude-pattern>
84 <exclude-pattern>*/maintenance/importDump\.php</exclude-pattern>
85 <exclude-pattern>*/maintenance/install\.php</exclude-pattern>
86 <exclude-pattern>*/maintenance/jsparse\.php</exclude-pattern>
87 <exclude-pattern>*/maintenance/lag\.php</exclude-pattern>
88 <exclude-pattern>*/maintenance/language/StatOutputs\.php</exclude-pattern>
89 <exclude-pattern>*/maintenance/language/date-formats\.php</exclude-pattern>
90 <exclude-pattern>*/maintenance/mysql\.php</exclude-pattern>
91 <exclude-pattern>*/maintenance/parse\.php</exclude-pattern>
92 <exclude-pattern>*/maintenance/preprocessorFuzzTest\.php</exclude-pattern>
93 <exclude-pattern>*/maintenance/rebuildImages\.php</exclude-pattern>
94 <exclude-pattern>*/maintenance/renderDump\.php</exclude-pattern>
95 <exclude-pattern>*/maintenance/shell\.php</exclude-pattern>
96 <exclude-pattern>*/maintenance/sql\.php</exclude-pattern>
97 <exclude-pattern>*/maintenance/update\.php</exclude-pattern>
98 <exclude-pattern>*/maintenance/userOptions\.php</exclude-pattern>
99 <exclude-pattern>*/maintenance/view\.php</exclude-pattern>
100 <!-- Language converters use the pattern of 2 classes in one file -->
101 <exclude-pattern>*/languages/*</exclude-pattern>
102 <!-- Skip violations in some tests for now -->
103 <exclude-pattern>*/tests/parser/*</exclude-pattern>
104 <exclude-pattern>*/tests/phpunit/maintenance/*</exclude-pattern>
105 <exclude-pattern>*/tests/phpunit/bootstrap\.php</exclude-pattern>
106 <exclude-pattern>*/tests/phpunit/phpunit\.php</exclude-pattern>
108 <rule ref="MediaWiki.Files.ClassMatchesFilename.WrongCase">
110 Continue to allow existing violations, but enable the sniff to prevent
113 <exclude-pattern>*/maintenance/language/alltrans\.php</exclude-pattern>
114 <exclude-pattern>*/maintenance/language/digit2html\.php</exclude-pattern>
115 <exclude-pattern>*/maintenance/language/langmemusage\.php</exclude-pattern>
116 <exclude-pattern>*/maintenance/mctest\.php</exclude-pattern>
117 <exclude-pattern>*/maintenance/mergeMessageFileList\.php</exclude-pattern>
118 <exclude-pattern>*/maintenance/mwdocgen\.php</exclude-pattern>
119 <exclude-pattern>*/maintenance/rebuildall\.php</exclude-pattern>
120 <exclude-pattern>*/maintenance/rebuildmessages\.php</exclude-pattern>
121 <exclude-pattern>*/maintenance/rebuildrecentchanges\.php</exclude-pattern>
122 <exclude-pattern>*/maintenance/rebuildtextindex\.php</exclude-pattern>
123 <exclude-pattern>*/maintenance/storage/checkStorage\.php</exclude-pattern>
124 <exclude-pattern>*/maintenance/storage/recompressTracked\.php</exclude-pattern>
125 <exclude-pattern>*/maintenance/storage/trackBlobs\.php</exclude-pattern>
126 <!-- Skip violations in some tests for now -->
127 <exclude-pattern>*/tests/phpunit/unit/includes/GlobalFunctions/*</exclude-pattern>
128 <exclude-pattern>*/tests/phpunit/includes/GlobalFunctions/*</exclude-pattern>
129 <exclude-pattern>*/tests/phpunit/maintenance/*</exclude-pattern>
130 <exclude-pattern>*/tests/phpunit/integration/includes/GlobalFunctions/*</exclude-pattern>
132 <rule ref="Generic.PHP.NoSilencedErrors.Discouraged">
134 Our normal policy of using Wikimedia\AtEase does not always make sense tests.
136 AtEase cannot be cleanly used in tests that also use expectException() as
137 the restoreWarnings() call would never be reached:
139 $this->expectException( PasswordError::class );
140 AtEase::suppressWarnings();
141 $password->crypt( 'whatever' );
142 AtEase::restoreWarnings();
144 The above will stop at crypt(), as expected, and leave AtEase in a dirty
145 state for unrelated tests.
147 TODO: Stop using PHPUnit TestCase directly. Require with a structure test
148 or with a high-level check in our run() hook, that all test cases use either
149 MediaWikiUnitTestCase or MediaWikiIntegrationTestCase. Otherwise the check
150 in MediaWikiTestCaseTrait can still be bypassed and cause a random failures.
153 <exclude-pattern>*/tests/*</exclude-pattern>
155 <rule ref="Generic.Files.OneObjectStructurePerFile.MultipleFound">
157 Continue to allow existing violations, but enable the sniff to prevent
160 <exclude-pattern>*/includes/libs/rdbms/dbal/MWPostgreSqlPlatformCompat\.php</exclude-pattern>
161 <exclude-pattern>*/maintenance/dumpIterator\.php</exclude-pattern>
162 <exclude-pattern>*/maintenance/findDeprecated\.php</exclude-pattern>
163 <exclude-pattern>*/maintenance/storage/recompressTracked\.php</exclude-pattern>
164 <exclude-pattern>*/maintenance/preprocessorFuzzTest\.php</exclude-pattern>
165 <exclude-pattern>*/maintenance/language/StatOutputs\.php</exclude-pattern>
166 <exclude-pattern>*/maintenance/language/generateCollationData\.php</exclude-pattern>
167 <!-- Language converters use the pattern of 2 classes in one file -->
168 <exclude-pattern>*/languages/*</exclude-pattern>
169 <!-- We don't care that much about violations in tests -->
170 <exclude-pattern>*/tests/*</exclude-pattern>
172 <rule ref="PSR2.Methods.MethodDeclaration.Underscore">
173 <exclude-pattern>*/includes/StubObject\.php</exclude-pattern>
174 <exclude-pattern>*/includes/StubGlobalUser\.php</exclude-pattern>
175 <exclude-pattern>*/includes/StubUserLang\.php</exclude-pattern>
177 <rule ref="MediaWiki.Usage.AssignmentInReturn.AssignmentInReturn">
178 <exclude-pattern>*/tests/phpunit/*</exclude-pattern>
180 <rule ref="MediaWiki.Usage.ForbiddenFunctions.popen">
182 Continue to allow existing violations, but enable the sniff to prevent
185 <exclude-pattern>*/includes/GlobalFunctions\.php</exclude-pattern>
186 <exclude-pattern>*/includes/libs/filebackend/FSFileBackend\.php</exclude-pattern>
187 <exclude-pattern>*/maintenance/includes/SevenZipStream\.php</exclude-pattern>
188 <exclude-pattern>*/maintenance/populateImageSha1\.php</exclude-pattern>
190 <rule ref="MediaWiki.Usage.ForbiddenFunctions.proc_open">
192 Continue to allow existing violations, but enable the sniff to prevent
195 <exclude-pattern>*/includes/export/DumpPipeOutput\.php</exclude-pattern>
196 <exclude-pattern>*/includes/ResourceLoader/Image\.php</exclude-pattern>
197 <exclude-pattern>*/includes/shell/Command\.php</exclude-pattern>
198 <exclude-pattern>*/maintenance/includes/TextPassDumper\.php</exclude-pattern>
199 <exclude-pattern>*/maintenance/mysql\.php</exclude-pattern>
200 <exclude-pattern>*/maintenance/storage/recompressTracked\.php</exclude-pattern>
201 <exclude-pattern>*/tests/parser/editTests\.php</exclude-pattern>
203 <rule ref="MediaWiki.Usage.ForbiddenFunctions.shell_exec">
205 Continue to allow existing violations, but enable the sniff to prevent
208 <exclude-pattern>*/maintenance/mwdocgen\.php</exclude-pattern>
209 <exclude-pattern>*/maintenance/updateCredits\.php</exclude-pattern>
211 <rule ref="MediaWiki.Usage.ForbiddenFunctions.system">
213 Continue to allow existing violations, but enable the sniff to prevent
216 <exclude-pattern>*/maintenance/mwdocgen\.php</exclude-pattern>
218 <rule ref="MediaWiki.Commenting.MissingCovers.MissingCovers">
219 <exclude-pattern>*/tests/phpunit/structure/*</exclude-pattern>
221 <rule ref="Generic.Arrays.DisallowShortArraySyntax">
223 T273340: Rule not to be enabled on any other file.
224 PHPVersionCheck.php requires syntax to be old PHP compatible.
225 The rest should therefore use [] rather than array() as per the
226 MediaWiki style guide.
228 <include-pattern>includes/PHPVersionCheck\.php</include-pattern>
231 <arg name="encoding" value="UTF-8"/>
232 <arg name="extensions" value="php"/>
233 <exclude-pattern type="relative">^(extensions|skins)/*</exclude-pattern>
234 <exclude-pattern>LocalSettings(-installer)?\.php</exclude-pattern>