Page MenuHomePhabricator

Remove parenthesis on break or continue in a inner loop
Closed, ResolvedPublic

Description

I have seen a break(2) where the parenthesis are not needed and it looks like a function.

The parenthesis should be removed.
break and continue can get these numbers

while ( !$stack->isEmpty() ) {
	....
	foreach ( $node->mChildren as $child ) {
		if ( $child->mWithinTreeMatchCount > 0 ) {
			if ( $nodeCount >= $wgCargoMaxVisibleHierarchyDrilldownValues ) {
				break(2);
			}
			$queue->enqueue( $child );
			$nodeCount++;
		}
	}
}

Maybe the sniff could remove the default of 1 as a second feature.

[1] https://gerrit.wikimedia.org/r/#/c/426266/2/drilldown/CargoDrilldownHierarchy.php

Event Timeline

Change 429448 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/tools/codesniffer@master] Add break and continue to ParenthesesAroundKeywordSniff

https://gerrit.wikimedia.org/r/429448

Umherirrender triaged this task as Medium priority.

Change 429448 merged by jenkins-bot:
[mediawiki/tools/codesniffer@master] Add break and continue to ParenthesesAroundKeywordSniff

https://gerrit.wikimedia.org/r/429448