File ForceSearchIndex.php
has 516 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace CirrusSearch\Maintenance;
use BatchRowIterator;
Function execute
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
$this->disablePoolCountersAndLogging();
$wiki = sprintf( "[%20s]", WikiMap::getCurrentWikiId() );
// Make sure we've actually got indices to populate
- 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 execute
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
$this->disablePoolCountersAndLogging();
$wiki = sprintf( "[%20s]", WikiMap::getCurrentWikiId() );
// Make sure we've actually got indices to populate
Method __construct
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct() {
parent::__construct();
$this->addDescription( "Force indexing some pages. Setting --from or --to will switch "
. "from page id based indexing to "
. "date based indexing which uses less efficient queries and follows redirects.\n\n"
Method getDeletesIterator
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getDeletesIterator() {
$dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] );
$it = new BatchRowIterator(
$dbr,
'logging',
Method decidePage
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function decidePage( Updater $updater, WikiPage $page ) {
try {
$content = $page->getContent();
} catch ( Throwable $ex ) {
LoggerFactory::getInstance( 'CirrusSearch' )->warning(
Method buildChunks
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function buildChunks( $buildChunks ) {
$dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] );
if ( $this->toId === null ) {
$this->toId = $dbr->newSelectQueryBuilder()
->select( 'MAX(page_id)' )
Function waitForQueueToDrain
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function waitForQueueToDrain( $wiki ) {
if ( !$this->queue ) {
return;
}
- 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
Consider simplifying this complex logical expression. Open
if ( !$this->indexUpdates || $this->hasOption( 'limit' )
|| $this->hasOption( 'from' ) || $this->hasOption( 'to' )
|| $this->hasOption( 'fromId' ) || $this->hasOption( 'toId' )
) {
$this->fatalError(
Function wrapDecodeResults
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function wrapDecodeResults( BatchRowIterator $it, $endingAtColumn ) {
return new CallbackIterator( $it, function ( $batch ) use ( $endingAtColumn ) {
// Build the updater outside the loop because it stores the redirects it hits.
// Don't build it at the top level so those are stored when it is freed.
$updater = $this->createUpdater();
- 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
Function buildChunks
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function buildChunks( $buildChunks ) {
$dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] );
if ( $this->toId === null ) {
$this->toId = $dbr->newSelectQueryBuilder()
->select( 'MAX(page_id)' )
- 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;
Avoid too many return
statements within this method. Open
return $page;
Function decidePage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function decidePage( Updater $updater, WikiPage $page ) {
try {
$content = $page->getContent();
} catch ( Throwable $ex ) {
LoggerFactory::getInstance( 'CirrusSearch' )->warning(
- 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"