wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub
includes/DataSender.php

Summary

Maintainability
F
4 days
Test Coverage

File DataSender.php has 507 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace CirrusSearch;

use CirrusSearch\BuildDocument\BuildDocument;
Severity: Major
Found in includes/DataSender.php - About 1 day to fix

    Method sendData has 120 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function sendData( $indexSuffix, array $documents ) {
            if ( !$documents ) {
                return Status::newGood();
            }
    
    
    Severity: Major
    Found in includes/DataSender.php - About 4 hrs to fix

      Function sendData has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public function sendData( $indexSuffix, array $documents ) {
              if ( !$documents ) {
                  return Status::newGood();
              }
      
      
      Severity: Minor
      Found in includes/DataSender.php - About 4 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

      Function bulkResponseExceptionIsJustDocumentMissing has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function bulkResponseExceptionIsJustDocumentMissing(
              ResponseException $exception, $logCallback = null
          ) {
              $justDocumentMissing = true;
              foreach ( $exception->getResponseSet()->getBulkResponses() as $bulkResponse ) {
      Severity: Minor
      Found in includes/DataSender.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 sendWeightedTagsUpdate has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function sendWeightedTagsUpdate(
              string $indexSuffix,
              string $tagPrefix,
              array $tagWeights,
              int $batchSize = 30
      Severity: Major
      Found in includes/DataSender.php - About 2 hrs to fix

        Method sendOtherIndexUpdates has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function sendOtherIndexUpdates( $localSite, $indexName, array $otherActions, $batchSize = 30 ) {
                $client = $this->connection->getClient();
                $status = Status::newGood();
                foreach ( array_chunk( $otherActions, $batchSize ) as $updates ) {
                    '@phan-var array[] $updates';
        Severity: Major
        Found in includes/DataSender.php - About 2 hrs to fix

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

              public function sendWeightedTagsUpdate(
                  string $indexSuffix,
                  string $tagPrefix,
                  array $tagWeights,
                  int $batchSize = 30
          Severity: Minor
          Found in includes/DataSender.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 sendDeletes has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function sendDeletes( $docIds, $indexSuffix = null ) {
                  if ( $indexSuffix === null ) {
                      $indexes = $this->connection->getAllIndexSuffixes( Connection::PAGE_DOC_TYPE );
                  } else {
                      $indexes = [ $indexSuffix ];
          Severity: Minor
          Found in includes/DataSender.php - About 1 hr to fix

            Function sendOtherIndexUpdates has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                public function sendOtherIndexUpdates( $localSite, $indexName, array $otherActions, $batchSize = 30 ) {
                    $client = $this->connection->getClient();
                    $status = Status::newGood();
                    foreach ( array_chunk( $otherActions, $batchSize ) as $updates ) {
                        '@phan-var array[] $updates';
            Severity: Minor
            Found in includes/DataSender.php - About 1 hr 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 reportUpdateMetrics has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function reportUpdateMetrics(
                    \Elastica\Bulk\ResponseSet $responseSet, $indexSuffix, $sent
                ) {
                    $updateStats = [
                        'sent' => $sent,
            Severity: Minor
            Found in includes/DataSender.php - About 1 hr to fix

              Function reportUpdateMetrics has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function reportUpdateMetrics(
                      \Elastica\Bulk\ResponseSet $responseSet, $indexSuffix, $sent
                  ) {
                      $updateStats = [
                          'sent' => $sent,
              Severity: Minor
              Found in includes/DataSender.php - About 1 hr 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 bulkResponseExceptionIsJustDocumentMissing has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function bulkResponseExceptionIsJustDocumentMissing(
                      ResponseException $exception, $logCallback = null
                  ) {
                      $justDocumentMissing = true;
                      foreach ( $exception->getResponseSet()->getBulkResponses() as $bulkResponse ) {
              Severity: Minor
              Found in includes/DataSender.php - About 1 hr to fix

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

                        string $indexSuffix,
                        array $docIds,
                        string $tagField,
                        string $tagPrefix,
                        $tagNames = null,
                Severity: Major
                Found in includes/DataSender.php - About 50 mins to fix

                  Method sendResetWeightedTags has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          string $indexSuffix,
                          array $docIds,
                          string $tagField,
                          string $tagPrefix,
                          int $batchSize = 30
                  Severity: Minor
                  Found in includes/DataSender.php - About 35 mins to fix

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

                        public function sendDeletes( $docIds, $indexSuffix = null ) {
                            if ( $indexSuffix === null ) {
                                $indexes = $this->connection->getAllIndexSuffixes( Connection::PAGE_DOC_TYPE );
                            } else {
                                $indexes = [ $indexSuffix ];
                    Severity: Minor
                    Found in includes/DataSender.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

                    Avoid too many return statements within this method.
                    Open

                                return (string)( $d->getId() );
                    Severity: Major
                    Found in includes/DataSender.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return Status::newGood();
                      Severity: Major
                      Found in includes/DataSender.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return Status::newFatal( 'cirrussearch-failed-send-data' );
                        Severity: Major
                        Found in includes/DataSender.php - About 30 mins to fix

                          There are no issues that match your filters.

                          Category
                          Status