From b16dd9dd96ef9ba71a2aef9eee7e138aa83767ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Sun, 10 Mar 2024 22:57:41 +0100 Subject: [PATCH] Update PHPCS overrides There's now a different rule for the same thing in mediawiki/mediawiki-codesniffer v43.0.0. Also document the reason for the override. Follow-up to 8b00546749072d636b2bf53869f696984dbbbb29. Change-Id: I392ee10639ffda6de55b091555e8c3cadd2af485 --- .phpcs.xml | 15 ++++++++++++++- includes/CommentModifier.php | 4 ---- includes/CommentParser.php | 5 ----- includes/CommentUtils.php | 3 --- includes/ImmutableRange.php | 2 -- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.phpcs.xml b/.phpcs.xml index 63cef758d..b47a643bc 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -1,7 +1,20 @@ - + + . diff --git a/includes/CommentModifier.php b/includes/CommentModifier.php index 93b0756f4..259388b0d 100644 --- a/includes/CommentModifier.php +++ b/includes/CommentModifier.php @@ -148,7 +148,6 @@ class CommentModifier { $transclusionNode = CommentUtils::getTranscludedFromElement( $target ); if ( $transclusionNode ) { while ( - // @phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition ( $nextSibling = $transclusionNode->nextSibling ) && $nextSibling instanceof Element && $nextSibling->getAttribute( 'about' ) === $transclusionNode->getAttribute( 'about' ) @@ -491,7 +490,6 @@ class CommentModifier { ( // This would be easier to check in prepareWikitextReply(), but that would result // in an empty list item being added at the end if we don't need to add a signature. - // @phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.Found ( $wtNode = $wrapperNode->lastChild ) && $wtNode instanceof Element && static::isWikitextNodeListItem( $wtNode ) @@ -564,7 +562,6 @@ class CommentModifier { // By request from the community, avoid this if possible after bullet indentation (T259864). if ( !( $replyIndentation === 'bullet' && - // @phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.Found ( $wtNode = $container->firstChild->lastChild ) && $wtNode instanceof Element && !static::isWikitextNodeListItem( $wtNode ) @@ -598,7 +595,6 @@ class CommentModifier { // By request from the community, avoid this if possible after bullet indentation (T259864). if ( !( $replyIndentation === 'bullet' && - // @phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.Found ( $wtNode = $container->firstChild->lastChild ) && $wtNode instanceof Element && !static::isWikitextNodeListItem( $wtNode ) diff --git a/includes/CommentParser.php b/includes/CommentParser.php index 4553a5978..829a03563 100644 --- a/includes/CommentParser.php +++ b/includes/CommentParser.php @@ -800,7 +800,6 @@ class CommentParser { // which apparently are often turned into   entities by buggy editing tools. To handle // this, we must piece together the text, so that our regexp can match those timestamps. if ( - // @phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.Found ( $previousSibling = $node->previousSibling ) && $previousSibling instanceof Element && $previousSibling->getAttribute( 'typeof' ) === 'mw:Entity' @@ -909,7 +908,6 @@ class CommentParser { NodeFilter::SHOW_ELEMENT | NodeFilter::SHOW_TEXT, [ static::class, 'acceptOnlyNodesAllowingComments' ] ); - // @phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition while ( $node = $treeWalker->nextNode() ) { if ( $node instanceof Element && preg_match( '/^h([1-6])$/i', $node->tagName, $match ) ) { $headingNodeAndOffset = CommentUtils::getHeadlineNodeAndOffset( $node ); @@ -923,7 +921,6 @@ class CommentParser { $curComment->setRootNode( $this->rootNode ); $result->addThreadItem( $curComment ); $curCommentEnd = $node; - // @phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.Found } elseif ( $node instanceof Text && ( $match = $this->findTimestamp( $node, $timestampRegexps ) ) ) { $warnings = []; $foundSignature = $this->findSignature( $node, $curCommentEnd ); @@ -968,7 +965,6 @@ class CommentParser { if ( $event === 'leave' && $n instanceof Text && $n !== $node && - // @phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.Found ( $match2 = $this->findTimestamp( $n, $timestampRegexps ) ) ) { // If this skips over another potential signature, also skip it in the main TreeWalker loop @@ -1262,7 +1258,6 @@ class CommentParser { // Phan doesn't realize that the conditions on $nextSibling can terminate the loop // @phan-suppress-next-line PhanInfiniteLoop $endNode && - // @phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition ( $nextSibling = $endNode->nextSibling ) && $nextSibling instanceof Element && $nextSibling->getAttribute( 'about' ) === $endNode->getAttribute( 'about' ) diff --git a/includes/CommentUtils.php b/includes/CommentUtils.php index 9490a1df4..78e573050 100644 --- a/includes/CommentUtils.php +++ b/includes/CommentUtils.php @@ -215,7 +215,6 @@ class CommentUtils { */ public static function childIndexOf( Node $child ): int { $i = 0; - // @phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition while ( ( $child = $child->previousSibling ) ) { $i++; } @@ -302,7 +301,6 @@ class CommentUtils { // 2. while ( - // @phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition ( $previousSibling = $node->previousSibling ) && $previousSibling instanceof Element && $previousSibling->getAttribute( 'about' ) === $about @@ -455,7 +453,6 @@ class CommentUtils { if ( $matches ) { // If these are all of the children (or the only child), go up one more level while ( - // @phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition ( $parent = $siblings[ 0 ]->parentNode ) && $parent !== $excludedAncestorNode && static::compareRanges( $makeRange( [ $parent ] ), $item->getRange() ) === 'equal' diff --git a/includes/ImmutableRange.php b/includes/ImmutableRange.php index 90aba3796..b1e85cd6b 100644 --- a/includes/ImmutableRange.php +++ b/includes/ImmutableRange.php @@ -54,7 +54,6 @@ class ImmutableRange { return $b; } $ancestorsA[] = $parent; - // @phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition } while ( $parent = $parent->parentNode ); $parent = $b; @@ -64,7 +63,6 @@ class ImmutableRange { return $a; } $ancestorsB[] = $parent; - // @phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition } while ( $parent = $parent->parentNode ); $node = null;