wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

Function getIndex has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getIndex(): \Elastica\Index {
        if ( $this->index ) {
            return $this->index;
        } else {
            $indexBaseName = $this->indexBaseName;
Severity: Minor
Found in includes/Search/SearchRequestBuilder.php - About 35 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 getAliasedIndexName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function getAliasedIndexName() {
        // FIXME: Elastica seems to have trouble parsing the error reason
        // for this endpoint. Running a simple HEAD first to check if it
        // exists
        $resp = $this->client->request( '_alias/' . self::INDEX_NAME, \Elastica\Request::HEAD, [] );
Severity: Minor
Found in includes/MetaStore/MetaStoreIndex.php - About 35 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 transformOneResult has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

            protected function transformOneResult( \Elastica\Result $result ) {
                $source = $result->getSource();
                if ( $source['namespace'] === NS_FILE ) {
                    if ( in_array( $source['title'], $this->fileTitles ) ) {
                        if ( $this->deduplicate ) {
Severity: Minor
Found in includes/Search/FullTextResultsType.php - About 35 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 getPrefixSearchRequest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function getPrefixSearchRequest( $term, $variants ) {
        $namespaces = $this->searchContext->getNamespaces();
        if ( $namespaces === null ) {
            return null;
        }
Severity: Minor
Found in includes/CompletionSuggester.php - About 35 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 build has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function build() {
        $rescores = [];
        foreach ( $this->profile['rescore'] as $rescoreDef ) {
            $windowSize = $this->windowSize( $rescoreDef );
            if ( $windowSize <= 0 ) {
Severity: Minor
Found in includes/Search/Rescore/RescoreBuilder.php - About 35 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 buildFullTextSearch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function buildFullTextSearch( $term ) {
        // Convert the unicode character 'ideographic whitespace' into standard
        // whitespace. Cirrussearch treats them both as normal whitespace, but
        // the preceding isn't appropriately trimmed.
        // No searching for nothing! That takes forever!
Severity: Minor
Found in includes/Searcher.php - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( SearchConfig $config, $namespaces, $weight, NamespaceInfo $namespaceInfo = null ) {
        parent::__construct( $config, $weight );

        $this->namespaceInfo = $namespaceInfo ?: MediaWikiServices::getInstance()->getNamespaceInfo();
        $this->namespacesToBoost =
Severity: Minor
Found in includes/Search/Rescore/NamespacesFunctionScoreBuilder.php - About 35 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 buildSuggestConfig has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function buildSuggestConfig() {
        $field = 'suggest';
        $config = $this->query->getSearchConfig();
        $suggestSettings = $this->getProfile();
        $settings = [
Severity: Minor
Found in includes/Fallbacks/PhraseSuggestFallbackMethod.php - About 35 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 enableICUTokenizer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function enableICUTokenizer( array $config ) {
        foreach ( $config[ 'analyzer' ] as $name => &$value ) {
            if ( isset( $value[ 'type' ] ) && $value[ 'type' ] != 'custom' ) {
                continue;
            }
Severity: Minor
Found in includes/Maintenance/AnalysisConfigBuilder.php - About 35 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 reindex has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function reindex(
        $slices = null,
        $chunkSize = 100,
        $acceptableCountDeviation = 0.05
    ) {
Severity: Minor
Found in includes/Maintenance/Reindexer.php - About 35 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 estimateTimeRemaining has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function estimateTimeRemaining(): \Generator {
        $estimatedStr = null;
        $remain = null;
        $prevRemain = null;
        $now = microtime( true );
Severity: Minor
Found in includes/Maintenance/Reindexer.php - About 35 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 standardTokenizerOnlyCleanup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function standardTokenizerOnlyCleanup( array $config ) {
        foreach ( $config[ 'analyzer' ] as $name => &$value ) {
            if ( isset( $value[ 'type' ] ) && $value[ 'type' ] != 'custom' ) {
                continue;
            }
Severity: Minor
Found in includes/Maintenance/AnalysisConfigBuilder.php - About 35 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 collect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function collect( SearchSuggestion $suggestion, $profileName, $index ) {
        if ( !$this->canCollect( $suggestion->getSuggestedTitleID(), $suggestion->getScore() ) ) {
            return false;
        }

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

    public function validate() {
        $this->outputIndented( "Validating mappings..." );
        if ( $this->optimizeIndexForExperimentalHighlighter &&
            !in_array( 'experimental-highlighter', $this->availablePlugins ) ) {
            $this->output( "impossible!\n" );
Severity: Minor
Found in includes/Maintenance/Validators/MappingValidator.php - About 35 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 resolveFilters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function resolveFilters( array &$config, array $standardFilters, array $defaultFilters,
            string $prefix ) {
        $resultFilters = [];
        foreach ( $config[ 'filter' ] as $name => $filter ) {
            $existingFilter = $standardFilters[$name] ?? $defaultFilters[$name] ?? null;
Severity: Minor
Found in includes/Maintenance/AnalysisConfigBuilder.php - About 35 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 waitForCounts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function waitForCounts( float $acceptableCountDeviation ) {
        $oldCount = (float)$this->oldIndex->count();
        $this->index->refresh();
        // While elasticsearch should be ready immediately after a refresh, we have seen this return
        // exceptionally low values in 2% of reindex attempts. Wait around a bit and hope the refresh
Severity: Minor
Found in includes/Maintenance/Reindexer.php - About 35 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 setupCopyTo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function setupCopyTo( $config, $fields, $destination ) {
        foreach ( $fields as $field => $weight ) {
            // Note that weights this causes weights that are not whole numbers to be rounded up.
            // We're ok with that because we don't have a choice.
            for ( $r = 0; $r < $weight; $r++ ) {
Severity: Minor
Found in includes/Maintenance/MappingConfigBuilder.php - About 35 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 fix has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function fix( $replacement ) {
        Assert::precondition( $this->visited, "getFixablePart must be called before trying to fix the query" );
        if ( $this->node === null ) {
            return null;
        }
Severity: Minor
Found in includes/Parser/AST/Visitor/QueryFixer.php - About 35 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 getActualNamespaces has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getActualNamespaces( array $namespaces = null, array $additionalRequiredNamespaces = null ) {
        if ( $this->requiredNamespaces === 'all' ) {
            // e.g. prefix:all:foo (all namespaces must be queried no matter what is requested before
            return [];
        }
Severity: Minor
Found in includes/Parser/AST/ParsedQuery.php - About 35 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 visitKeywordFeatureNode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

            public function visitKeywordFeatureNode( KeywordFeatureNode $node ) {
                if ( !$this->negated() && ( $node->getKeyword() instanceof InTitleFeature ) && $node->getParsedValue() == [] ) {
                    // TODO: generalize this InTitleFeature behavior
                    // We want to keep the text of the intitle keyword on if:
                    // - it's not negated
Severity: Minor
Found in includes/Query/Builder/NearMatchFieldQueryBuilder.php - About 35 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