wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 691 of 718 total issues

Function reformat has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function reformat( array $problems ): array {
        $clean = [];
        $indexBaseName = $this->getSearchConfig()->get( SearchConfig::INDEX_BASE_NAME );
        // Generic connection for resolving index names, its always the same everywhere
        $connection = Connection::getPool( $this->getSearchConfig() );
Severity: Minor
Found in includes/Api/CheckSanity.php - About 35 mins to fix

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 sendDeletes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function sendDeletes( $docIds, $indexSuffix = null ) {
        if ( $indexSuffix === null ) {
            $indexes = $this->connection->getAllIndexSuffixes( Connection::PAGE_DOC_TYPE );
        } else {
            $indexes = [ $indexSuffix ];
Severity: Minor
Found in includes/DataSender.php - About 35 mins to fix

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 intersect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function intersect( CrossSearchStrategy $other ) {
        if ( $other === self::hostWikiOnlyStrategy() || $this === self::hostWikiOnlyStrategy() ) {
            return self::hostWikiOnlyStrategy();
        }
        $crossL = $other->crossLanguageSearchSupported && $this->crossLanguageSearchSupported;
Severity: Minor
Found in includes/CrossSearchStrategy.php - About 35 mins to fix

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 onLinksUpdateComplete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function onLinksUpdateComplete( $linksUpdate, $ticket ) {
        if ( !$this->isEnabled() ) {
            return;
        }
        // defer processing the LinksUpdateComplete hook until other hooks tagged in PageChangeTracker
Severity: Minor
Found in includes/ChangeListener.php - About 35 mins to fix

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 preparePageReferencesForLinksUpdate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function preparePageReferencesForLinksUpdate( $pageReferences, int $max, $excludeBadUTF = false ) {
        $pageReferences = self::pickFromArray( $pageReferences, $max );
        $dBKeys = [];
        foreach ( $pageReferences as $pageReference ) {
            $title = Title::newFromPageReference( $pageReference );
Severity: Minor
Found in includes/ChangeListener.php - About 35 mins to fix

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 getDetectors has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getDetectors() {
        $detectors = [];
        foreach ( $this->config->get( 'CirrusSearchLanguageDetectors' ) as $name => $klass ) {
            if ( !class_exists( $klass ) ) {
                LoggerFactory::getInstance( 'CirrusSearch' )->info(
Severity: Minor
Found in includes/LanguageDetector/LanguageDetectorFactory.php - About 35 mins to fix

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 prefixSearch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function prefixSearch( $search, $variants ) {
        $searcher = $this->makeSearcher();

        if ( $search ) {
            $searcher->setResultsType( new FancyTitleResultsType( 'prefix' ) );
Severity: Minor
Found in includes/CirrusSearch.php - About 35 mins to fix

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 buildLogMessage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function buildLogMessage( RequestLog $log, array $context ) {
        $message = $log->getDescription();
        $message .= " against {index} took {tookMs} millis";
        if ( isset( $context['elasticTookMs'] ) ) {
            $message .= " and {elasticTookMs} Elasticsearch millis";
Severity: Minor
Found in includes/RequestLogger.php - About 35 mins to fix

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 getProfiles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getProfiles( $profileType, User $user = null ) {
        $profileService = $this->config->getProfileService();
        $serviceProfileType = null;
        switch ( $profileType ) {
            case SearchEngine::COMPLETION_PROFILE_TYPE:
Severity: Minor
Found in includes/CirrusSearch.php - About 35 mins to fix

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 checkExisitingPage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkExisitingPage( $docId, $pageId, $page, array $fromIndex ) {
        $inIndex = $fromIndex !== [];
        if ( $this->checkIfRedirect( $page ) ) {
            if ( $inIndex ) {
                foreach ( $fromIndex as $indexInfo ) {
Severity: Minor
Found in includes/Sanity/Checker.php - About 35 mins to fix

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 completionSearchBackend has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function completionSearchBackend( $search ) {
        if ( in_array( NS_SPECIAL, $this->namespaces ) ) {
            // delegate special search to parent
            return parent::completionSearchBackend( $search );
        }
Severity: Minor
Found in includes/CirrusSearch.php - About 35 mins to fix

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 getAllIndexSuffixes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getAllIndexSuffixes( $documentType = self::PAGE_DOC_TYPE ) {
        Assert::parameter( $documentType === null || isset( self::SUFFIX_MAPPING[$documentType] ),
            '$documentType', "Unknown mapping type $documentType" );
        $indexSuffixes = [];

Severity: Minor
Found in includes/Connection.php - About 35 mins to fix

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 loadProfileByName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function loadProfileByName( $type, $name, $failIfMissing = true ) {
        if ( isset( $this->repositories[$type] ) ) {
            $repos = $this->repositories[$type];
            foreach ( $repos as $repo ) {
                $prof = $repo->getProfile( $name );
Severity: Minor
Found in includes/Profile/SearchProfileService.php - About 35 mins to fix

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 getIndex has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getIndex(): \Elastica\Index {
        if ( $this->index ) {
            return $this->index;
        } else {
            $indexBaseName = $this->indexBaseName;
Severity: Minor
Found in includes/Search/SearchRequestBuilder.php - About 35 mins to fix

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 getAliasedIndexName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function getAliasedIndexName() {
        // FIXME: Elastica seems to have trouble parsing the error reason
        // for this endpoint. Running a simple HEAD first to check if it
        // exists
        $resp = $this->client->request( '_alias/' . self::INDEX_NAME, \Elastica\Request::HEAD, [] );
Severity: Minor
Found in includes/MetaStore/MetaStoreIndex.php - About 35 mins to fix

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 transformOneResult has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

            protected function transformOneResult( \Elastica\Result $result ) {
                $source = $result->getSource();
                if ( $source['namespace'] === NS_FILE ) {
                    if ( in_array( $source['title'], $this->fileTitles ) ) {
                        if ( $this->deduplicate ) {
Severity: Minor
Found in includes/Search/FullTextResultsType.php - About 35 mins to fix

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 getPrefixSearchRequest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function getPrefixSearchRequest( $term, $variants ) {
        $namespaces = $this->searchContext->getNamespaces();
        if ( $namespaces === null ) {
            return null;
        }
Severity: Minor
Found in includes/CompletionSuggester.php - About 35 mins to fix

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 build has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function build() {
        $rescores = [];
        foreach ( $this->profile['rescore'] as $rescoreDef ) {
            $windowSize = $this->windowSize( $rescoreDef );
            if ( $windowSize <= 0 ) {
Severity: Minor
Found in includes/Search/Rescore/RescoreBuilder.php - About 35 mins to fix

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 buildFullTextSearch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function buildFullTextSearch( $term ) {
        // Convert the unicode character 'ideographic whitespace' into standard
        // whitespace. Cirrussearch treats them both as normal whitespace, but
        // the preceding isn't appropriately trimmed.
        // No searching for nothing! That takes forever!
Severity: Minor
Found in includes/Searcher.php - About 35 mins to fix

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 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( SearchConfig $config, $namespaces, $weight, NamespaceInfo $namespaceInfo = null ) {
        parent::__construct( $config, $weight );

        $this->namespaceInfo = $namespaceInfo ?: MediaWikiServices::getInstance()->getNamespaceInfo();
        $this->namespacesToBoost =
Severity: Minor
Found in includes/Search/Rescore/NamespacesFunctionScoreBuilder.php - About 35 mins to fix

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

Severity
Category
Status
Source
Language