wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 691 of 718 total issues

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

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

Severity
Category
Status
Source
Language