wikimedia/mediawiki-core

View on GitHub
maintenance/includes/TextPassDumper.php

Summary

Maintainability
F
1 wk
Test Coverage

File TextPassDumper.php has 733 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * BackupDumper that postprocesses XML dumps from dumpBackup.php to add page text
 *
 * Copyright (C) 2005 Brooke Vibber <bvibber@wikimedia.org>
Severity: Major
Found in maintenance/includes/TextPassDumper.php - About 1 day to fix

    Function getText has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function getText( $id, $model = null, $format = null, $expSize = null ) {
            if ( !$this->isValidTextId( $id ) ) {
                $msg = "Skipping bad text id " . $id . " of revision " . $this->thisRev;
                $this->progress( $msg );
                return '';
    Severity: Minor
    Found in maintenance/includes/TextPassDumper.php - About 6 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 getText has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function getText( $id, $model = null, $format = null, $expSize = null ) {
            if ( !$this->isValidTextId( $id ) ) {
                $msg = "Skipping bad text id " . $id . " of revision " . $this->thisRev;
                $this->progress( $msg );
                return '';
    Severity: Major
    Found in maintenance/includes/TextPassDumper.php - About 3 hrs to fix

      TextPassDumper has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class TextPassDumper extends BackupDumper {
          /** @var BaseDump|null */
          public $prefetch = null;
          /** @var string */
          private $thisPage;
      Severity: Minor
      Found in maintenance/includes/TextPassDumper.php - About 3 hrs to fix

        Method readDump has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function readDump( $input ) {
                $this->buffer = "";
                $this->openElement = false;
                $this->atStart = true;
                $this->state = "";
        Severity: Major
        Found in maintenance/includes/TextPassDumper.php - About 2 hrs to fix

          Function startElement has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function startElement( $parser, $name, $attribs ) {
                  $this->checkpointJustWritten = false;
          
                  $this->clearOpenElement( null );
                  $this->lastName = $name;
          Severity: Minor
          Found in maintenance/includes/TextPassDumper.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 showReport has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function showReport() {
                  if ( !$this->prefetch ) {
                      parent::showReport();
          
                      return;
          Severity: Major
          Found in maintenance/includes/TextPassDumper.php - About 2 hrs to fix

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

                public function showReport() {
                    if ( !$this->prefetch ) {
                        parent::showReport();
            
                        return;
            Severity: Minor
            Found in maintenance/includes/TextPassDumper.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 endElement has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function endElement( $parser, $name ) {
                    $this->checkpointJustWritten = false;
            
                    if ( $this->openElement ) {
                        $this->clearOpenElement( "" );
            Severity: Minor
            Found in maintenance/includes/TextPassDumper.php - About 2 hrs to fix

              Method getTextSpawnedOnce has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function getTextSpawnedOnce( $address ) {
                      if ( is_int( $address ) || intval( $address ) ) {
                          $address = SqlBlobStore::makeAddressFromTextId( (int)$address );
                      }
              
              
              Severity: Minor
              Found in maintenance/includes/TextPassDumper.php - About 1 hr to fix

                Method startElement has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function startElement( $parser, $name, $attribs ) {
                        $this->checkpointJustWritten = false;
                
                        $this->clearOpenElement( null );
                        $this->lastName = $name;
                Severity: Minor
                Found in maintenance/includes/TextPassDumper.php - About 1 hr to fix

                  Function getTextSpawnedOnce has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function getTextSpawnedOnce( $address ) {
                          if ( is_int( $address ) || intval( $address ) ) {
                              $address = SqlBlobStore::makeAddressFromTextId( (int)$address );
                          }
                  
                  
                  Severity: Minor
                  Found in maintenance/includes/TextPassDumper.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

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

                      protected function endElement( $parser, $name ) {
                          $this->checkpointJustWritten = false;
                  
                          if ( $this->openElement ) {
                              $this->clearOpenElement( "" );
                  Severity: Minor
                  Found in maintenance/includes/TextPassDumper.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

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

                      protected function readDump( $input ) {
                          $this->buffer = "";
                          $this->openElement = false;
                          $this->atStart = true;
                          $this->state = "";
                  Severity: Minor
                  Found in maintenance/includes/TextPassDumper.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 openSpawn has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function openSpawn() {
                          global $IP;
                  
                          $wiki = WikiMap::getCurrentWikiId();
                          if ( count( $this->php ) == 2 ) {
                  Severity: Minor
                  Found in maintenance/includes/TextPassDumper.php - About 1 hr to fix

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

                        protected function characterData( $parser, $data ) {
                            $this->clearOpenElement( null );
                            if ( $this->lastName == "id" ) {
                                if ( $this->state == "revision" ) {
                                    $this->thisRev .= $data;
                    Severity: Minor
                    Found in maintenance/includes/TextPassDumper.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 __construct has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function __construct( $args = null ) {
                            parent::__construct();
                    
                            $this->addDescription( <<<TEXT
                    This script postprocesses XML dumps from dumpBackup.php to add
                    Severity: Minor
                    Found in maintenance/includes/TextPassDumper.php - About 1 hr to fix

                      Method processOptions has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function processOptions() {
                              parent::processOptions();
                      
                              if ( $this->hasOption( 'buffersize' ) ) {
                                  $this->bufferSize = max( intval( $this->getOption( 'buffersize' ) ), 4 * 1024 );
                      Severity: Minor
                      Found in maintenance/includes/TextPassDumper.php - About 1 hr to fix

                        Method processFileOpt has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function processFileOpt( $opt ) {
                                $split = explode( ':', $opt, 2 );
                                $val = $split[0];
                                $param = '';
                                if ( count( $split ) === 2 ) {
                        Severity: Minor
                        Found in maintenance/includes/TextPassDumper.php - About 1 hr to fix

                          Function processOptions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              protected function processOptions() {
                                  parent::processOptions();
                          
                                  if ( $this->hasOption( 'buffersize' ) ) {
                                      $this->bufferSize = max( intval( $this->getOption( 'buffersize' ) ), 4 * 1024 );
                          Severity: Minor
                          Found in maintenance/includes/TextPassDumper.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

                          Function finalOptionCheck has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private function finalOptionCheck() {
                                  if ( ( $this->checkpointFiles && !$this->maxTimeAllowed )
                                      || ( $this->maxTimeAllowed && !$this->checkpointFiles )
                                  ) {
                                      throw new RuntimeException( "Options checkpointfile and maxtime must be specified together.\n" );
                          Severity: Minor
                          Found in maintenance/includes/TextPassDumper.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 characterData has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function characterData( $parser, $data ) {
                                  $this->clearOpenElement( null );
                                  if ( $this->lastName == "id" ) {
                                      if ( $this->state == "revision" ) {
                                          $this->thisRev .= $data;
                          Severity: Minor
                          Found in maintenance/includes/TextPassDumper.php - About 1 hr to fix

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

                                protected function processFileOpt( $opt ) {
                                    $split = explode( ':', $opt, 2 );
                                    $val = $split[0];
                                    $param = '';
                                    if ( count( $split ) === 2 ) {
                            Severity: Minor
                            Found in maintenance/includes/TextPassDumper.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 false;
                            Severity: Major
                            Found in maintenance/includes/TextPassDumper.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return false;
                              Severity: Major
                              Found in maintenance/includes/TextPassDumper.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                        return $normalized;
                                Severity: Major
                                Found in maintenance/includes/TextPassDumper.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return false;
                                  Severity: Major
                                  Found in maintenance/includes/TextPassDumper.php - About 30 mins to fix

                                    Function rotateDb has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        protected function rotateDb() {
                                            // Cleaning up old connections
                                            if ( isset( $this->lb ) ) {
                                                $this->lb->closeAll( __METHOD__ );
                                                unset( $this->lb );
                                    Severity: Minor
                                    Found in maintenance/includes/TextPassDumper.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