wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub
includes/MetaStore/MetaStoreIndex.php

Summary

Maintainability
B
5 hrs
Test Coverage

File MetaStoreIndex.php has 264 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace CirrusSearch\MetaStore;

use CirrusSearch\Connection;
Severity: Minor
Found in includes/MetaStore/MetaStoreIndex.php - About 2 hrs to fix

    Method switchAliasTo has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function switchAliasTo( $index ) {
            $name = $index->getName();
            $oldIndexName = $this->getAliasedIndexName();
            if ( $oldIndexName !== null ) {
                $this->log( "Switching " . self::INDEX_NAME . " alias from $oldIndexName to $name.\n" );
    Severity: Minor
    Found in includes/MetaStore/MetaStoreIndex.php - About 1 hr to fix

      Method upgradeIndexVersion has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function upgradeIndexVersion() {
              $pluginsStatus = $this->configUtils->scanAvailableModules();
              if ( !$pluginsStatus->isGood() ) {
                  throw new \RuntimeException( (string)$pluginsStatus );
              }
      Severity: Minor
      Found in includes/MetaStore/MetaStoreIndex.php - About 1 hr to fix

        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 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

        There are no issues that match your filters.

        Category
        Status