Showing 718 of 718 total issues
Method unify
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function unify( array $mustFilters, array $mustNotFilters ) {
// We want to make sure that we execute script filters last. So we do these steps:
// 1. Strip script filters from $must and $mustNot.
// 2. Unify the non-script filters.
// 3. Build a BoolAnd filter out of the script filters if there are any.
Method parseValue
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parseValue( $key, $value, $quotedValue, $valueDelimiter, $suffix, WarningCollector $warningCollector ) {
$parsedValue = [];
$field = self::KEY_TABLE[$key];
$parsedValue['field'] = $field;
Method execute
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
$this->metaStore = $this->getMetaStore();
if ( $this->hasOption( 'dump' ) ) {
$this->dump();
Method __construct
has 12 arguments (exceeds 4 allowed). Consider refactoring. Open
Connection $conn, $offset,
$limit,
SearchConfig $config,
array $namespaces = null,
User $user = null,
Method buildWeightedTags
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function buildWeightedTags(
string $tagPrefix,
?array $tagWeightsByName = null
): array {
Assert::precondition(
Method searchFor
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function searchFor( $query ) {
$searchType = $this->getOption( 'type', 'full_text' );
if ( $searchType === 'archive' ) {
// Archive has its own engine so go directly there
Method parse
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse( $query, $start, $end ) {
$match = [];
Assert::precondition( $start < $end, '$start < $end' );
Assert::precondition( $end <= strlen( $query ), '$end <= strlen( $query )' );
if ( preg_match( self::PHRASE_REGEX, $query, $match, 0, $start ) === 1 ) {
Method intermediateExplain
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function intermediateExplain( array $doc ) {
$incLinks = $this->explainScoreNormLog2( $doc['incoming_links'] ?? 0,
$this->incomingLinksNorm, 'incoming_links' );
$pageSize = $this->explainScoreNormLog2( $doc['text_bytes'] ?? 0,
self::PAGE_SIZE_NORM, 'text_bytes' );
Method pushJobs
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function pushJobs() {
$profile = $this->getSearchConfig()
->getProfileService()
->loadProfileByName( SearchProfileService::SANEITIZER, $this->profileName );
'@phan-var array $profile';
Function sendConfigDumpRequest
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function sendConfigDumpRequest( $endpoints ) {
$logger = LoggerFactory::getInstance( 'CirrusSearch' );
$reqs = [];
foreach ( $endpoints as $prefix => $info ) {
$reqs[$prefix] = [
- 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 serde
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private static function serde( $method, array $arguments, $serialize = true ) {
if ( isset( self::$SERDE[$method] ) ) {
foreach ( self::$SERDE[$method] as $i => $serde ) {
if ( $serde !== null && array_key_exists( $i, $arguments ) ) {
$impl = new $serde();
- 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 determineCirrusDocId
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function determineCirrusDocId( PageIdentity $title ) {
$hasRedirects = false;
$seen = [];
$now = wfTimestamp( TS_MW );
$services = MediaWikiServices::getInstance();
- 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 check
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function check( array $pageIds ) {
$docIds = array_map( [ $this->searchConfig, 'makeId' ], $pageIds );
$pagesFromDb = $this->loadPagesFromDB( $pageIds );
$pagesFromIndex = $this->loadPagesFromIndex( $docIds );
- 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 pickTextSnippet
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function pickTextSnippet( $highlights ) {
// This can get skipped if there the page was sent to Elasticsearch without text.
// This could be a bug or it could be that the page simply doesn't have any text.
$mainSnippet = '';
// Prefer source_text.plain it's likely a regex
- 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 __construct
has a Cognitive Complexity of 12 (exceeds 5 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();
- 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 successApproximation
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function successApproximation( FallbackRunnerContext $context ) {
$firstPassResults = $context->getInitialResultSet();
if ( !$this->query->isAllowRewrite() ) {
return 0.0;
}
- 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 interleaveResults
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function interleaveResults( $a, $b, $limit ) {
$interleaved = [];
$teamA = [];
$teamB = [];
$aIds = array_combine( array_keys( $a ), array_keys( $a ) );
- 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 updateIndices
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function updateIndices( array $add, array $remove ) {
if ( !$remove ) {
return $this->updateFreeIndices( $add );
}
- 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 pickIndexIdentifierFromOption
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function pickIndexIdentifierFromOption( $option, $typeName ): Status {
if ( $option === 'now' ) {
$identifier = strval( time() );
$this->outputIndented( "Setting index identifier...{$typeName}_{$identifier}\n" );
return Status::newGood( $identifier );
- 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 runMSearch
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function runMSearch(
Search $search,
RequestLog $log,
Connection $connection = null,
callable $resultsTransformer = null
- 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"