wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

Avoid too many return statements within this method.
Open

                    return $result;
Severity: Major
Found in maintenance/RunSearch.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                return false;
    Severity: Major
    Found in maintenance/UpdateSuggesterIndex.php - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return 'Duplicate of live index ' + live_index + '. ' + reason
      Severity: Major
      Found in scripts/check_indices.py - About 30 mins to fix

        Function getExtraIndexesForNamespaces has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function getExtraIndexesForNamespaces( SearchConfig $config, array $namespaces ) {
                $extraIndexes = [];
                foreach ( $config->get( 'CirrusSearchExtraIndexes' ) ?: [] as $namespace => $indexes ) {
                    if ( !in_array( $namespace, $namespaces ) ) {
                        continue;
        Severity: Minor
        Found in includes/OtherIndexesUpdater.php - About 25 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 hasProfile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function hasProfile( $type, $name ) {
                if ( isset( $this->repositories[$type] ) ) {
                    foreach ( $this->repositories[$type] as $repo ) {
                        if ( $repo->hasProfile( $name ) ) {
                            return true;
        Severity: Minor
        Found in includes/Profile/SearchProfileService.php - About 25 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 loadInterwikiOverrides has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function loadInterwikiOverrides( SearchProfileService $service, SearchConfig $config ) {
                if ( $config->isLocalWiki() || $config === $this->hostWikiConfig ) {
                    return;
                }
                $iwPrefix = $this->interwikiResolver->getInterwikiPrefix( $config->getWikiId() );
        Severity: Minor
        Found in includes/Profile/SearchProfileServiceFactory.php - About 25 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 newHighlightField has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function newHighlightField(
                $name,
                $target,
                $priority = HighlightedField::DEFAULT_TARGET_PRIORITY
            ): BaseHighlightedField {
        Severity: Minor
        Found in includes/Search/Fetch/FetchPhaseConfigBuilder.php - About 25 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 suggest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function suggest( $text, $variants = null ) {
                $suggestSearch = $this->getSuggestSearchRequest( $text, $variants );
                $mSearchRequests = new MSearchRequests();
        
                if ( $suggestSearch !== null ) {
        Severity: Minor
        Found in includes/CompletionSuggester.php - About 25 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 getBoostForNamespace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function getBoostForNamespace( $namespace ) {
                if ( isset( $this->normalizedNamespaceWeights[$namespace] ) ) {
                    return $this->normalizedNamespaceWeights[$namespace];
                }
                if ( $this->namespaceInfo->isSubject( $namespace ) ) {
        Severity: Minor
        Found in includes/Search/Rescore/NamespacesFunctionScoreBuilder.php - About 25 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 attachSearchRequests has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function attachSearchRequests( MSearchRequests $requests, Client $client ) {
                $position = 0;
                foreach ( $this->fallbackMethods as $method ) {
                    $position++;
                    if ( $method instanceof ElasticSearchRequestFallbackMethod ) {
        Severity: Minor
        Found in includes/Fallbacks/FallbackRunner.php - About 25 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 buildRescoreQuery has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function buildRescoreQuery() {
                if ( !isset( $this->chain['functions'] ) ) {
                    throw new InvalidRescoreProfileException( "No functions defined in chain {$this->chainName}." );
                }
                foreach ( $this->chain['functions'] as $func ) {
        Severity: Minor
        Found in includes/Search/Rescore/FunctionScoreChain.php - About 25 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 buildMapping has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function buildMapping() {
                $properties = [
                    'type' => [ 'type' => 'keyword' ],
                    'wiki' => [ 'type' => 'keyword' ],
                ];
        Severity: Minor
        Found in includes/MetaStore/MetaStoreIndex.php - About 25 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 unbalancedQuotes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function unbalancedQuotes( $text, $from = 0, $to = -1 ) {
                $to = $to < 0 ? strlen( $text ) : $to;
                $inQuote = false;
                $inEscape = false;
                for ( $i = $from; $i < $to; $i++ ) {
        Severity: Minor
        Found in includes/Search/Escaper.php - About 25 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 maybeSearchAndRewrite has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function maybeSearchAndRewrite(
                FallbackRunnerContext $context,
                SearchQuery $originalQuery,
                string $suggestedQuery,
                $suggestedQuerySnippet = null,
        Severity: Minor
        Found in includes/Fallbacks/FallbackMethodTrait.php - About 25 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 getPoolCounterType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function getPoolCounterType(): string {
                // Default pool counter for all search requests. Note that not all
                // possible requests go through Searcher, so this isn't globally
                // definitive.
                $pool = 'CirrusSearch-Search';
        Severity: Minor
        Found in includes/Searcher.php - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __construct( SearchConfig $config, $weight, $profile ) {
                parent::__construct( $config, $weight );
        
                if ( isset( $profile['midpoint'] ) ) {
                    $this->midpoint = $this->getOverriddenFactor( $profile['midpoint'] );
        Severity: Minor
        Found in includes/Search/Rescore/LogScaleBoostFunctionScoreBuilder.php - About 25 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 handleSearchGetNearMatch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function handleSearchGetNearMatch( $term, &$titleResult ) {
                global $wgSearchType;
                if ( $wgSearchType !== 'CirrusSearch' ) {
                    return true;
                }
        Severity: Minor
        Found in includes/Hooks.php - About 25 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 switchFiltersToICUFoldingPreserve has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function switchFiltersToICUFoldingPreserve( array $filters, $append = false ) {
                if ( in_array( 'icu_folding', $filters ) ) {
                    // ICU folding already here
                    return $filters;
                }
        Severity: Minor
        Found in includes/Maintenance/AnalysisConfigBuilder.php - About 25 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 makeUpdateFieldsScript has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function makeUpdateFieldsScript() {
                $script = [
                    'source' => '',
                    'lang' => 'painless',
                ];
        Severity: Minor
        Found in includes/Maintenance/Reindexer.php - About 25 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 prefixSearchExtractNamespaceWithConnection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function prefixSearchExtractNamespaceWithConnection(
                Connection $connection,
                &$namespaces,
                &$search
            ) {
        Severity: Minor
        Found in includes/Hooks.php - About 25 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