diff options
Diffstat (limited to 'build')
-rw-r--r-- | build/build.xml | 14 | ||||
-rw-r--r-- | build/code_sniffer/ruleset-minimum.xml | 3 | ||||
-rw-r--r-- | build/code_sniffer/ruleset-php-legacy.xml | 21 | ||||
-rw-r--r-- | build/code_sniffer/ruleset-php-strict.xml | 9 |
4 files changed, 45 insertions, 2 deletions
diff --git a/build/build.xml b/build/build.xml index c033b1fefd..0a5448f98d 100644 --- a/build/build.xml +++ b/build/build.xml @@ -81,7 +81,7 @@ --standard=build/code_sniffer/ruleset-php-strict.xml --ignore=phpBB/phpbb/db/migration/data/v30x/* phpBB/phpbb" - dir="." checkreturn="true" passthru="true" /> + dir="." returnProperty="retval-php-strict" passthru="true" /> <exec command="phpBB/vendor/bin/phpcs -s --extensions=php @@ -92,10 +92,20 @@ --ignore=phpBB/includes/sphinxapi.php --ignore=phpBB/includes/utf/data/* --ignore=phpBB/install/data/* + --ignore=phpBB/install/database_update.php --ignore=phpBB/phpbb/* --ignore=phpBB/vendor/* phpBB" - dir="." checkreturn="true" passthru="true" /> + dir="." returnProperty="retval-php-legacy" passthru="true" /> + <if> + <or> + <not><equals arg1="${retval-php-strict}" arg2="0" /></not> + <not><equals arg1="${retval-php-legacy}" arg2="0" /></not> + </or> + <then> + <fail message="PHP Code Sniffer failed." /> + </then> + </if> </target> <target name="docs"> diff --git a/build/code_sniffer/ruleset-minimum.xml b/build/code_sniffer/ruleset-minimum.xml index 2de1fb4be4..33d0177390 100644 --- a/build/code_sniffer/ruleset-minimum.xml +++ b/build/code_sniffer/ruleset-minimum.xml @@ -9,4 +9,7 @@ <!-- All code files MUST use the Unix LF (linefeed) line ending. --> <rule ref="Generic.Files.LineEndings" /> + <!-- Tabs MUST be used for indentation --> + <rule ref="Generic.WhiteSpace.DisallowSpaceIndent" /> + </ruleset> diff --git a/build/code_sniffer/ruleset-php-legacy.xml b/build/code_sniffer/ruleset-php-legacy.xml index ed8c7e98a0..247313441d 100644 --- a/build/code_sniffer/ruleset-php-legacy.xml +++ b/build/code_sniffer/ruleset-php-legacy.xml @@ -5,9 +5,21 @@ <rule ref="./ruleset-minimum.xml" /> + <!-- "for (; bar; )" should be "while (bar)" instead --> + <rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" /> + + <!-- A method MUST not only call its parent --> + <rule ref="Generic.CodeAnalysis.UselessOverridingMethod" /> + <!-- The body of each structure MUST be enclosed by braces. --> <rule ref="Generic.ControlStructures.InlineControlStructure" /> + <!-- There MUST not be more than one statement per line. --> + <rule ref="Generic.Formatting.DisallowMultipleStatements" /> + + <!-- Call-time pass-by-reference MUST not be used. --> + <rule ref="Generic.Functions.CallTimePassByReference.NotAllowed" /> + <!-- Class constants MUST be declared in all upper case with underscore separators. --> <rule ref="Generic.NamingConventions.UpperCaseConstantName" /> @@ -17,6 +29,15 @@ <!-- Method arguments with default values MUST go at the end of the argument list. --> <rule ref="PEAR.Functions.ValidDefaultValue" /> + <!-- In the argument list, there MUST NOT be a space before each comma, + and there MUST be one space after each comma. --> + <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing"> + <properties> + <property name="equalsSpacing" value="1"/> + </properties> + </rule> + <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint" /> + <!-- The ?> closing tag MUST be omitted from files containing only PHP. --> <rule ref="Zend.Files.ClosingTag" /> diff --git a/build/code_sniffer/ruleset-php-strict.xml b/build/code_sniffer/ruleset-php-strict.xml index 65b6763c57..5e3c26a616 100644 --- a/build/code_sniffer/ruleset-php-strict.xml +++ b/build/code_sniffer/ruleset-php-strict.xml @@ -34,6 +34,15 @@ <!-- Functions MUST NOT contain multiple empty lines in a row --> <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines" /> + <!-- Classes etc. MUST be namespaced --> + <rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace" /> + + <!-- A file MUST not contain more than one class/interface --> + <rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses" /> + + <!-- Files containing classes MUST not have any side-effects --> + <rule ref="PSR1.Files.SideEffects.FoundWithSymbols" /> + <!-- When present, all use declarations MUST go after the namespace declaration. There MUST be one use keyword per declaration. There MUST be one blank line after the use block. --> |