wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

Function run has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

def run(wiki, clusters, index_types, batch_size, start, end, q, stats):
Severity: Major
Found in scripts/compare-clusters.py - About 1 hr to fix

    Function addRequest has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function addRequest( RequestLog $log, UserIdentity $user = null, $slowMillis = null ) {
            global $wgCirrusSearchLogElasticRequests;
    
            // @todo Is this necessary here? Check on what uses the response value
            $finalContext = $log->getLogVariables() + [
    Severity: Minor
    Found in includes/RequestLogger.php - About 55 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 classifyError has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function classifyError( \Elastica\Exception\ExceptionInterface $exception = null ) {
            if ( $exception === null ) {
                return 'unknown';
            }
            $error = self::extractFullError( $exception );
    Severity: Minor
    Found in includes/ElasticaErrorHandler.php - About 55 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 getStatus has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getStatus() {
            if ( $this->response ) {
                // task complete
                return $this->response;
            }
    Severity: Minor
    Found in includes/Elastica/ReindexTask.php - About 55 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 createFromProfile has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function createFromProfile( SearchQuery $query, array $profile, InterwikiResolver $interwikiResolver ): FallbackRunner {
            $fallbackMethods = [];
            $methodDefs = $profile['methods'] ?? [];
            foreach ( $methodDefs as $name => $methodDef ) {
                if ( !isset( $methodDef['class'] ) ) {
    Severity: Minor
    Found in includes/Fallbacks/FallbackRunner.php - About 55 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 canMerge has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private function canMerge( BaseHighlightedField $other ) {
            if ( $this->highlighterType !== $other->highlighterType ) {
                return false;
            }
            if ( $this->getTarget() !== $other->getTarget() ) {
    Severity: Minor
    Found in includes/Search/Fetch/BaseHighlightedField.php - About 55 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 prepareQueryParams has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private function prepareQueryParams( array $settings ) {
            $def = [];
            foreach ( self::$rescoreMainParams as $param ) {
                if ( !isset( $settings[$param] ) ) {
                    continue;
    Severity: Minor
    Found in includes/Search/Rescore/RescoreBuilder.php - About 55 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 findRedirectTitle has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function findRedirectTitle( \Elastica\Result $result, $snippet ) {
            $title = $this->stripHighlighting( $snippet );
            // Grab the redirect that matches the highlighted title with the lowest namespace.
            $redirects = $result->redirect;
            // That is pretty arbitrary but it prioritizes 0 over others.
    Severity: Minor
    Found in includes/Search/Fetch/HighlightingTrait.php - About 55 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 merge has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function merge( HighlightedField $other ): HighlightedField {
            if ( $this->getFieldName() !== $other->getFieldName() ) {
                throw new \InvalidArgumentException(
                    "Rejecting nonsense merge: Refusing to merge two HighlightFields with different field names: " .
                "[{$other->getFieldName()}] != [{$this->getFieldName()}]" );
    Severity: Minor
    Found in includes/Search/Fetch/BaseHighlightedField.php - About 55 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 doMainSnippet has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private function doMainSnippet( $highlights ) {
            $hasTextSnippet = false;
            foreach ( $this->highligtedFields[ArrayCirrusSearchResult::TEXT_SNIPPET] as $hlField ) {
                if ( isset( $highlights[$hlField->getFieldName()][0] ) ) {
                    $snippet = $highlights[$hlField->getFieldName()][0];
    Severity: Minor
    Found in includes/Search/FullTextCirrusSearchResultBuilder.php - About 55 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 getDefaultFilters has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getDefaultFilters( array &$config, array $analyzers ) {
            $defaultFilters = [];
            foreach ( $analyzers as $analyzer ) {
                if ( empty( $config[ 'analyzer' ][ $analyzer ][ 'filter' ] ) ) {
                    continue;
    Severity: Minor
    Found in includes/Maintenance/AnalysisConfigBuilder.php - About 55 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 handleVariants has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private function handleVariants( Suggest $suggests, array $variants, $queryLen, $term ) {
            $variantIndex = 0;
            $done = [ $term ];
            foreach ( $variants as $variant ) {
                if ( in_array( $variant, $done, true ) ) {
    Severity: Minor
    Found in includes/Query/CompSuggestQueryBuilder.php - About 55 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 parseValue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function parseValue( $key, $value, $quotedValue, $valueDelimiter, $suffix, WarningCollector $warningCollector ) {
            $values = explode( '|', $value, self::MAX_CONDITIONS + 1 );
            if ( count( $values ) > self::MAX_CONDITIONS ) {
                $warningCollector->addWarning(
                    'cirrussearch-feature-too-many-conditions',
    Severity: Minor
    Found in includes/Query/HasTemplateFeature.php - About 55 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 getValueRegex has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getValueRegex() {
            Assert::invariant( $this->hasValue(), __METHOD__ . ' called but hasValue() is false' );
            if ( $this->greedy() ) {
                Assert::precondition( !$this->allowEmptyValue(), "greedy keywords must not accept empty value" );
                // XXX: we ignore value delimiter for greedy keywords
    Severity: Minor
    Found in includes/Query/SimpleKeywordFeature.php - About 55 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 getValueRegex has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getValueRegex( KeywordFeature $feature ) {
            Assert::invariant( $feature->hasValue(), __METHOD__ . ' called but hasValue() is false' );
            if ( $feature->greedy() ) {
                // XXX: we send raw value to the keyword
                return '(?<unquoted>.+)';
    Severity: Minor
    Found in includes/Parser/QueryStringRegex/KeywordParser.php - About 55 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 parse has a Cognitive Complexity of 9 (exceeds 5 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',
    Severity: Minor
    Found in includes/Parser/QueryStringRegex/QueryStringRegexParser.php - About 55 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 checkQueryLen has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private function checkQueryLen(): void {
            Assert::precondition( $this->query !== null, "Query must be set" );
            $maxLen = $this->maxQueryLen;
            $exemptKeywords = [];
            foreach ( $this->preTaggedNodes as $node ) {
    Severity: Minor
    Found in includes/Parser/QueryStringRegex/QueryStringRegexParser.php - About 55 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 boostTemplates has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function boostTemplates( array $doc, $score ) {
            if ( !isset( $doc['template'] ) ) {
                return $score;
            }
    
    
    Severity: Minor
    Found in includes/BuildDocument/Completion/QualityScore.php - About 55 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 canRecycle has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private function canRecycle() {
            global $wgCirrusSearchRecycleCompletionSuggesterIndex;
            if ( !$wgCirrusSearchRecycleCompletionSuggesterIndex ) {
                return false;
            }
    Severity: Minor
    Found in maintenance/UpdateSuggesterIndex.php - About 55 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

    Method onPageDeleteComplete has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            ProperPageIdentity $page,
            Authority $deleter,
            string $reason,
            int $pageID,
            RevisionRecord $deletedRev,
    Severity: Major
    Found in includes/PageChangeTracker.php - About 50 mins to fix
      Severity
      Category
      Status
      Source
      Language