wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub
includes/Maintenance/Reindexer.php

Summary

Maintainability
D
1 day
Test Coverage

File Reindexer.php has 338 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace CirrusSearch\Maintenance;

use CirrusSearch\Connection;
Severity: Minor
Found in includes/Maintenance/Reindexer.php - About 4 hrs to fix

    Function monitorReindexTask has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        private function monitorReindexTask( ReindexTask $task, Index $target ) {
            $consecutiveErrors = 0;
            $sleepSeconds = self::monitorSleepSeconds( 1, 2, self::MONITOR_SLEEP_SECONDS );
            $completionEstimateGen = self::estimateTimeRemaining();
            while ( !$task->isComplete() ) {
    Severity: Minor
    Found in includes/Maintenance/Reindexer.php - About 2 hrs 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 reindex has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function reindex(
            $slices = null,
            $chunkSize = 100,
            $acceptableCountDeviation = 0.05
        ) {
    Severity: Major
    Found in includes/Maintenance/Reindexer.php - About 2 hrs to fix

      Method monitorReindexTask has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function monitorReindexTask( ReindexTask $task, Index $target ) {
              $consecutiveErrors = 0;
              $sleepSeconds = self::monitorSleepSeconds( 1, 2, self::MONITOR_SLEEP_SECONDS );
              $completionEstimateGen = self::estimateTimeRemaining();
              while ( !$task->isComplete() ) {
      Severity: Minor
      Found in includes/Maintenance/Reindexer.php - About 1 hr to fix

        Method makeRemoteReindexInfo has 29 lines of code (exceeds 25 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 1 hr to fix

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

                  SearchConfig $searchConfig,
                  Connection $source,
                  Connection $target,
                  Index $index,
                  Index $oldIndex,
          Severity: Major
          Found in includes/Maintenance/Reindexer.php - About 50 mins to fix

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

            There are no issues that match your filters.

            Category
            Status