Function updateLinkedArticles
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function updateLinkedArticles( $titles ): void {
$pages = [];
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
foreach ( $titles as $title ) {
// Special pages don't get updated, we only index
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File Updater.php
has 304 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace CirrusSearch;
use CirrusSearch\BuildDocument\BuildDocument;
Function traceRedirects
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function traceRedirects( $title ) {
// Loop through redirects until we get to the ultimate target
$redirects = [];
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
while ( true ) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method updatePages
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updatePages( $pages, $flags, string $updateKind = null, int $rootEventTime = null ): int {
// Don't update the same page twice. We shouldn't, but meh
$pageIds = [];
$pages = array_filter( $pages, static function ( WikiPage $page ) use ( &$pageIds ) {
if ( !in_array( $page->getId(), $pageIds ) ) {
Method traceRedirects
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function traceRedirects( $title ) {
// Loop through redirects until we get to the ultimate target
$redirects = [];
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
while ( true ) {
Method updateLinkedArticles
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateLinkedArticles( $titles ): void {
$pages = [];
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
foreach ( $titles as $title ) {
// Special pages don't get updated, we only index
Function pushElasticaWriteJobs
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function pushElasticaWriteJobs( string $updateGroup, array $items, $factory, int $batchSize = 10 ): void {
// Elasticsearch has a queue capacity of 50 so if $documents contains 50 pages it could bump up
// against the max. So we chunk it and do them sequentially.
$jobs = [];
$config = $this->connection->getConfig();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return [ null, $redirects ];
Avoid too many return
statements within this method. Open
return [ $page, $redirects ];