wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

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

    private function canCollect( $pageId, $score ) {
        if ( in_array( $pageId, $this->bannedIds ) ) {
            return false;
        }

Severity: Minor
Found in includes/Search/CompletionResultsCollector.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 buildConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function buildConfig() {
        global $wgCirrusSearchWeights;

        $page = $this->getDefaultFields();

Severity: Minor
Found in includes/Maintenance/MappingConfigBuilder.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 defaults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function defaults( $language ) {
        // Use default lowercase filter
        $lowercase_type = [ 'type' => 'lowercase' ];
        if ( $this->isIcuAvailable() ) {
            $lowercase_type = [
Severity: Minor
Found in includes/Maintenance/SuggesterAnalysisConfigBuilder.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 getBackCompatOption has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getBackCompatOption( string $current, string $bc, bool $required = true ) {
        if ( $this->hasOption( $current ) && $this->hasOption( $bc ) ) {
            $this->error( "\nERROR: --$current cannot be provided with --$bc" );
            $this->maybeHelp( true );
        } elseif ( $this->hasOption( $current ) ) {
Severity: Minor
Found in includes/Maintenance/Maintenance.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 makeRemoteReindexInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function makeRemoteReindexInfo( Connection $source, Connection $dest ) {
        if ( $source->getClusterName() === $dest->getClusterName() ) {
            return null;
        }

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

    public function extractTitleAndSimilarRedirects( array $doc ) {
        $redirects = [];
        if ( isset( $doc['redirect'] ) ) {
            foreach ( $doc['redirect'] as $redir ) {
                // Avoid suggesting/displaying non existent titles
Severity: Minor
Found in includes/BuildDocument/Completion/SuggestBuilder.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 stripQuestionMarks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function stripQuestionMarks( $term, $strippingLevel ) {
        if ( strpos( $term, 'insource:/' ) === false &&
             strpos( $term, 'intitle:/' ) === false &&
            !preg_match( '/^[\p{P}\p{Z}]+$/u', $term )
        ) {
Severity: Minor
Found in includes/Util.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 parseValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function parseValue( $key, $value, $quotedValue, $valueDelimiter, $suffix, WarningCollector $warningCollector ) {
        $matches = [];
        $retValue = [];
        // FIXME: we should probably no longer accept the empty string and simply return false
        // instead of null
Severity: Minor
Found in includes/Query/PreferRecentFeature.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 setIfDefined has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function setIfDefined(
        array $sourceArray,
        $sourceKey,
        array &$destArray,
        $destKey = null,
Severity: Minor
Found in includes/Util.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 buildSimpleAllFilter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function buildSimpleAllFilter( $options, $query ) {
        $filter = new \Elastica\Query\BoolQuery();
        $filter->setMinimumShouldMatch( 1 );
        // FIXME: We can't use solely the stem field here
        // - Depending on languages it may lack stopwords,
Severity: Minor
Found in includes/Query/FullTextSimpleMatchQueryBuilder.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 cleanup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function cleanup() {
        $query = $this->rawQuery;
        $nquery = Util::stripQuestionMarks( $query, $this->questionMarkStripLevel );
        if ( $nquery !== $query ) {
            $this->queryCleanups[ParsedQuery::CLEANUP_QMARK_STRIPPING] = true;
Severity: Minor
Found in includes/Parser/QueryStringRegex/QueryStringRegexParser.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 isEmpty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function isEmpty( $v ) {
        return ( is_array( $v ) && count( $v ) === 0 ) ||
            ( is_object( $v ) && count( (array)$v ) === 0 ) ||
            ( is_string( $v ) && strlen( $v ) === 0 ) ||
            ( $v === null );
Severity: Minor
Found in includes/Util.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 buildRegexWithPlugin has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function buildRegexWithPlugin( $pattern, $insensitive ) {
        $filters = [];
        // TODO: Update plugin to accept multiple values for the field property
        // so that at index time we can create a single trigram index with
        // copy_to instead of creating multiple queries.
Severity: Minor
Found in includes/Query/BaseRegexFeature.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 replacePartsOfQuery has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function replacePartsOfQuery( $queryPart, $regex, $callable ) {
        $destination = [];
        $matches = [];
        $offset = 0;
        while ( preg_match( $regex, $queryPart, $matches, PREG_OFFSET_CAPTURE, $offset ) ) {
Severity: Minor
Found in includes/Query/FullTextQueryStringQueryBuilder.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 toArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function toArray() {
        $ar = [
            'query' => $this->query,
            'rawQuery' => $this->rawQuery
        ];
Severity: Minor
Found in includes/Parser/AST/ParsedQuery.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 searchFor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function searchFor( $query ) {
        $searchType = $this->getOption( 'type', 'full_text' );

        if ( $searchType === 'archive' ) {
            // Archive has its own engine so go directly there
Severity: Minor
Found in maintenance/RunSearch.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 decidePage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function decidePage( Updater $updater, WikiPage $page ) {
        try {
            $content = $page->getContent();
        } catch ( Throwable $ex ) {
            LoggerFactory::getInstance( 'CirrusSearch' )->warning(
Severity: Minor
Found in maintenance/ForceSearchIndex.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 processResultSet has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function processResultSet( CirrusSearchResultSet $value, $query ) {
        // these are prefix or full text results
        $rows = [];
        foreach ( $value as $result ) {
            /** @var CirrusSearch\Search\CirrusSearchResult $result */
Severity: Minor
Found in maintenance/RunSearch.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