Showing 691 of 718 total issues
Method buildFromParsedQuery
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildFromParsedQuery( ParsedQuery $query ): AbstractQuery {
$visitor = new class( $query ) extends LeafVisitor {
public string $nearMatch;
public function __construct( ParsedQuery $query ) {
File SuggesterAnalysisConfigBuilder.php
has 251 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace CirrusSearch\Maintenance;
/**
Method detect
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function detect( $text ) {
$dirs = $this->config->getElement( 'CirrusSearchTextcatModel' );
if ( !$dirs ) {
return null;
}
Method updateOtherIndex
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateOtherIndex( $titles ) {
if ( !$this->connection->getConfig()->getElement( 'CirrusSearchWikimediaExtraPlugin', 'super_detect_noop' ) ) {
$this->logFailure( $titles, 'super_detect_noop plugin not enabled' );
return;
}
Method explain
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function explain( array $doc ) {
$qualityExplain = $this->intermediateExplain( $doc );
$pop = $doc['popularity_score'] ?? 0;
if ( $pop > self::POPULARITY_MAX ) {
$popExplain = [
Method customize
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function customize( array $config, $language ) {
$defaultStopSet = $this->getDefaultStopSet( $language );
$config['filter']['stop_filter']['stopwords'] = $defaultStopSet;
switch ( $this->getDefaultTextAnalyzerType( $language ) ) {
Function isProfileSyntaxSupported
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function isProfileSyntaxSupported( array $profile ) {
if ( ( $profile['supported_syntax'] ?? [] ) !== [] ) {
$supportedSyntax = false;
foreach ( $profile['supported_syntax'] as $supported ) {
if ( $this->context->isSyntaxUsed( $supported ) ) {
- 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 parseValue
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function parseValue( $key, $value, $quotedValue, $valueDelimiter, $suffix, WarningCollector $warningCollector ) {
$parsedValue = [];
$field = self::KEY_TABLE[$key];
$parsedValue['field'] = $field;
- 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 customize
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function customize( array $config, $language ) {
$defaultStopSet = $this->getDefaultStopSet( $language );
$config['filter']['stop_filter']['stopwords'] = $defaultStopSet;
switch ( $this->getDefaultTextAnalyzerType( $language ) ) {
- 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 unify
has a Cognitive Complexity of 15 (exceeds 5 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.
- 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 extractSimilars
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function extractSimilars( $groupHead, array $candidates, $checkVariants = false ) {
$group = [
'text' => $groupHead,
'variants' => []
];
- 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 loadConfigFromAPI
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function loadConfigFromAPI( $wikis, array $hashConfigFlags, $fallbackConfig ) {
$endpoints = [];
foreach ( $wikis as $prefix => $wiki ) {
$iw = $this->interwikiLookup->fetch( $prefix );
if ( !$iw || !$this->useConfigDumpApi || !$iw->isLocal() ) {
Method get
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get( array $docIds, $sourceFiltering, $usePoolCounter = true ) {
$connection = $this->getOverriddenConnection();
$indexSuffix = $connection->pickIndexSuffixForNamespaces(
$this->searchContext->getNamespaces()
);
Method parse
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse( string $query ): ParsedQuery {
$this->reInit( $query );
$queryLen = mb_strlen( $query );
if ( $queryLen > self::QUERY_LEN_HARD_LIMIT ) {
throw new SearchQueryParseException( 'cirrussearch-query-too-long',
Method readLineBatch
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function readLineBatch( SplFileObject $file, bool $useIds ) {
$titleParser = MediaWikiServices::getInstance()->getTitleParser();
$pageStore = MediaWikiServices::getInstance()->getPageStore();
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
$batchSize = $this->getBatchSize();
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 getInterwikiResults
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getInterwikiResults( SearchQuery $query ): Status {
$sources = MediaWikiServices::getInstance()
->getService( InterwikiResolver::SERVICE )
->getSisterProjectConfigs();
if ( !$sources ) {
Method __construct
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( SearchConfig $config, $weight, $profile ) {
parent::__construct( $config, $weight );
if ( isset( $profile['impact'] ) ) {
$this->impact = $this->getOverriddenFactor( $profile['impact'] );
Method buildConfig
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildConfig() {
global $wgCirrusSearchWeights;
$page = $this->getDefaultFields();
Method validate
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function validate() {
$this->out->outputIndented( "Validating new index is different..." );
if ( !$this->oldIndex->exists() ) {
$this->out->output( "ok\n" );
return Status::newGood( true );