wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 691 of 718 total issues

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

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

            ClusterSettings $cluster,
            string $updateGroup,
            string $method,
            array $arguments,
            array $params = [],
    Severity: Major
    Found in includes/Job/ElasticaWrite.php - About 50 mins to fix

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

          public function onPageDeleteComplete( ProperPageIdentity $page, Authority $deleter,
              string $reason, int $pageID, RevisionRecord $deletedRev, ManualLogEntry $logEntry,
              int $archivedRevisionCount
      Severity: Major
      Found in includes/ChangeListener.php - About 50 mins to fix

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

                $old, $new, $user, $pageid, $redirid,
                $reason, $revision
        Severity: Major
        Found in includes/ChangeListener.php - About 50 mins to fix

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

              public static function build( $fromPageId, $toPageId, $delay, $profile, $cluster, $loopId, \JobQueueGroup $jobQueueGroup ) {
          Severity: Major
          Found in includes/Job/CheckerJob.php - About 50 mins to fix

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

                    string $indexSuffix,
                    array $docIds,
                    string $tagField,
                    string $tagPrefix,
                    $tagNames = null,
            Severity: Major
            Found in includes/DataSender.php - About 50 mins to fix
              Severity
              Category
              Status
              Source
              Language