Showing 718 of 718 total issues
Method interleaveResults
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function interleaveResults( $a, $b, $limit ) {
$interleaved = [];
$teamA = [];
$teamB = [];
$aIds = array_combine( array_keys( $a ), array_keys( $a ) );
Method postProcess
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function postProcess( CompletionResultsCollector $collector, ResultSet $results, $indexName ) {
$suggestResp = $results->getSuggests();
if ( $suggestResp === [] ) {
// Edge case where the index contains 0 documents and does not even return the 'suggest' field
return 0;
Method finalizeReal
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function finalizeReal(
Document $doc,
WikiPage $page,
CirrusSearch $engine,
RevisionRecord $revision
Method execute
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
$indexPattern = $this->getSearchConfig()->get( SearchConfig::INDEX_BASE_NAME ) . '_*';
$end = microtime( true ) + 60;
while ( true ) {
try {
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',
Function getCompiledReplacements
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function getCompiledReplacements() {
if ( $this->compiledReplacements === null ) {
$this->compiledReplacements = [];
foreach ( $this->replacements as $repl => $value ) {
if ( !is_string( $repl ) ) {
- 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 sendOtherIndexUpdates
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function sendOtherIndexUpdates( $localSite, $indexName, array $otherActions, $batchSize = 30 ) {
$client = $this->connection->getClient();
$status = Status::newGood();
foreach ( array_chunk( $otherActions, $batchSize ) as $updates ) {
'@phan-var array[] $updates';
- 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 isProfileNamespaceSupported
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function isProfileNamespaceSupported( array $profile ) {
if ( !is_array( $profile['supported_namespaces'] ) ) {
switch ( $profile['supported_namespaces'] ) {
case 'all':
return 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
Function transformOneElasticResult
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function transformOneElasticResult( \Elastica\Result $r, array $namespaces = [] ) {
$title = $this->getTitleHelper()->makeTitle( $r );
$highlights = $r->getHighlights();
$resultForTitle = [];
- 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 pushAnalyzerAliasesIntoField
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function pushAnalyzerAliasesIntoField( array $properties, array $aliases ) {
foreach ( $properties as &$config ) {
foreach ( self::$ANALYZER_FIELDS as $key ) {
if ( isset( $config[$key] ) && isset( $aliases[$config[$key]] ) ) {
$config[$key] = $aliases[$config[$key]];
- 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 apply
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function apply( SearchContext $context, $term ) {
$keyListRegex = implode(
'|',
array_map(
static function ( $kw ) {
- 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 getPageIdentities
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function getPageIdentities() {
if ( $this->hasOption( 'page' ) ) {
$pageName = $this->getOption( 'page' );
$title = Title::newFromText( $pageName );
if ( !$title ) {
- 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 recycle
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function recycle() {
$this->log( "Recycling index {$this->getIndex()->getName()}\n" );
$this->recycle = true;
$indexedDocs = $this->indexData();
// This is fragile... hopefully most of the docs will be deleted from the old segments
- 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 decideClusters
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function decideClusters( string $updateGroup ) {
$params = $this->getParams();
$searchConfig = $this->getSearchConfig();
$jobType = $this->getType();
Method __construct
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( SearchConfig $config, $requestedNamespaces, $localSearch, $withDefaultBoosts, $weight ) {
parent::__construct( $config, $weight );
// Use the boosted templates from extra indexes if available
$queries = [];
$weights = [];
Method validateParams
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function validateParams() {
$pageOptionCount = (int)$this->hasOption( 'page' ) + (int)$this->hasOption( 'page-list' )
+ (int)$this->hasOption( 'pageid-list' );
if ( $pageOptionCount !== 1 ) {
$this->fatalError( "Exactly one of --page, --page-list and --pageid-list must be used" );
Method doSearchText
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doSearchText( $term ) {
try {
$builder = SearchQueryBuilder::newFTSearchQueryBuilder( $this->config,
$term, $this->namespacePrefixParser, $this->getCirrusSearchHookRunner() );
} catch ( SearchQueryParseException $e ) {
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 __construct
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( $results, $result, TitleHelper $titleHelper = null ) {
$this->titleHelper = $titleHelper ?: new TitleHelper();
parent::__construct( $this->titleHelper->makeTitle( $result ) );
$this->namespaceText = $result->namespace_text;
$this->docId = $result->getId();
Method transformOneElasticResult
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function transformOneElasticResult( \Elastica\Result $r, array $namespaces = [] ) {
$title = $this->getTitleHelper()->makeTitle( $r );
$highlights = $r->getHighlights();
$resultForTitle = [];