wikimedia/mediawiki-core

View on GitHub
maintenance/storage/compressOld.php

Summary

Maintainability
F
3 days
Test Coverage

Function compressWithConcat has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring.
Open

    private function compressWithConcat( $startId, $maxChunkSize, $beginDate,
        $endDate, $extdb = "", $maxPageId = false
    ) {
        $dbr = $this->getReplicaDB();
        $dbw = $this->getPrimaryDB();
Severity: Minor
Found in maintenance/storage/compressOld.php - About 1 day 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 compressWithConcat has 210 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function compressWithConcat( $startId, $maxChunkSize, $beginDate,
        $endDate, $extdb = "", $maxPageId = false
    ) {
        $dbr = $this->getReplicaDB();
        $dbw = $this->getPrimaryDB();
Severity: Major
Found in maintenance/storage/compressOld.php - About 1 day to fix

    File compressOld.php has 358 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Compress the text of a wiki.
     *
     * Usage:
    Severity: Minor
    Found in maintenance/storage/compressOld.php - About 4 hrs to fix

      Method __construct has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __construct() {
              parent::__construct();
              $this->addDescription( 'Compress the text of a wiki' );
              $this->addOption( 'type', 'Set compression type to either: gzip|concat', false, true, 't' );
              $this->addOption(
      Severity: Minor
      Found in maintenance/storage/compressOld.php - About 1 hr to fix

        Method execute has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function execute() {
                global $wgDBname;
                if ( !function_exists( "gzdeflate" ) ) {
                    $this->fatalError( "You must enable zlib support in PHP to compress old revisions!\n" .
                        "Please see https://www.php.net/manual/en/ref.zlib.php\n" );
        Severity: Minor
        Found in maintenance/storage/compressOld.php - About 1 hr to fix

          Method compressPage has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function compressPage( $row, $extdb ) {
                  if ( strpos( $row->old_flags, 'gzip' ) !== false
                      || strpos( $row->old_flags, 'object' ) !== false
                  ) {
                      # print "Already compressed row {$row->old_id}\n";
          Severity: Minor
          Found in maintenance/storage/compressOld.php - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                                        if ( $stubs[$j] !== false && $revs[$i + $j]->old_id != $primaryOldid ) {
                                            $dbw->newUpdateQueryBuilder()
                                                ->update( 'text' )
                                                ->set( [
                                                    'old_text' => serialize( $stubs[$j] ),
            Severity: Major
            Found in maintenance/storage/compressOld.php - About 45 mins to fix

              Method compressWithConcat has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private function compressWithConcat( $startId, $maxChunkSize, $beginDate,
                      $endDate, $extdb = "", $maxPageId = false
              Severity: Minor
              Found in maintenance/storage/compressOld.php - About 45 mins to fix

                Function execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function execute() {
                        global $wgDBname;
                        if ( !function_exists( "gzdeflate" ) ) {
                            $this->fatalError( "You must enable zlib support in PHP to compress old revisions!\n" .
                                "Please see https://www.php.net/manual/en/ref.zlib.php\n" );
                Severity: Minor
                Found in maintenance/storage/compressOld.php - About 45 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