From: Kunal Mehta Date: Mon, 7 May 2018 08:09:19 +0000 (-0700) Subject: Don't globally disable PHPCS's prohibition of assert() X-Git-Tag: 1.34.0-rc.0~5510 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%22id_auteur=%24connect_id_auteur%22%29%20.%20%22?a=commitdiff_plain;h=f093fb419243e327d2f685823a75a6634c18b279;p=lhc%2Fweb%2Fwiklou.git Don't globally disable PHPCS's prohibition of assert() Whitelist the remaining usages of assert(), and reinstate the PHPCS sniff that forbids usage of it. Add FIXME comments as well, so any casual readers of the code will not think that the disabling and usage is intentional. Change-Id: I7cabe715c0e6aa6a9ef3ffe5657f3de7fd8e662b --- diff --git a/.phpcs.xml b/.phpcs.xml index 31e6eebc71..d43a2814cf 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -17,7 +17,6 @@ - diff --git a/includes/diff/DiffEngine.php b/includes/diff/DiffEngine.php index 53378e5827..273d1d61f6 100644 --- a/includes/diff/DiffEngine.php +++ b/includes/diff/DiffEngine.php @@ -24,6 +24,9 @@ */ use MediaWiki\Diff\ComplexityException; +// FIXME: Don't use assert() in this file +// phpcs:disable MediaWiki.Usage.ForbiddenFunctions.assert + /** * This diff implementation is mainly lifted from the LCS algorithm of the Eclipse project which * in turn is based on Myers' "An O(ND) difference algorithm and its variations" diff --git a/includes/diff/WordAccumulator.php b/includes/diff/WordAccumulator.php index ad802756ef..88631ed415 100644 --- a/includes/diff/WordAccumulator.php +++ b/includes/diff/WordAccumulator.php @@ -89,6 +89,8 @@ class WordAccumulator { $this->flushLine( $tag ); $word = substr( $word, 1 ); } + // FIXME: Don't use assert() + // phpcs:ignore MediaWiki.Usage.ForbiddenFunctions.assert assert( !strstr( $word, "\n" ) ); $this->group .= $word; } diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 64edbb2f6c..104cd135e9 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -566,6 +566,8 @@ class Preprocessor_DOM extends Preprocessor { } elseif ( $found == 'line-end' ) { $piece = $stack->top; // A heading must be open, otherwise \n wouldn't have been in the search list + // FIXME: Don't use assert() + // phpcs:ignore MediaWiki.Usage.ForbiddenFunctions.assert assert( $piece->open === "\n" ); $part = $piece->getCurrentPart(); // Search back through the input to see if it has a proper close. diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index c7f630d5db..8e74380c4d 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -504,6 +504,8 @@ class Preprocessor_Hash extends Preprocessor { } elseif ( $found == 'line-end' ) { $piece = $stack->top; // A heading must be open, otherwise \n wouldn't have been in the search list + // FIXME: Don't use assert() + // phpcs:ignore MediaWiki.Usage.ForbiddenFunctions.assert assert( $piece->open === "\n" ); $part = $piece->getCurrentPart(); // Search back through the input to see if it has a proper close.