wikimedia/mediawiki-core

View on GitHub
maintenance/updateCollation.php

Summary

Maintainability
D
2 days
Test Coverage

File updateCollation.php has 294 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Find all rows in the categorylinks table whose collation is out-of-date
 * (cl_collation != $wgCategoryCollation) and repopulate cl_sortkey
 * using the page title and cl_sortkey_prefix.
Severity: Minor
Found in maintenance/updateCollation.php - About 3 hrs to fix

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

        public function execute() {
            $this->init();
            $batchSize = $this->getBatchSize();
    
            if ( $this->targetTable ) {
    Severity: Major
    Found in maintenance/updateCollation.php - About 2 hrs to fix

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

          public function execute() {
              $this->init();
              $batchSize = $this->getBatchSize();
      
              if ( $this->targetTable ) {
      Severity: Minor
      Found in maintenance/updateCollation.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 showSortKeySizeHistogram has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function showSortKeySizeHistogram() {
              if ( !$this->sizeHistogram ) {
                  return;
              }
              $maxLength = max( array_keys( $this->sizeHistogram ) );
      Severity: Minor
      Found in maintenance/updateCollation.php - About 1 hr to fix

        Function showSortKeySizeHistogram has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            private function showSortKeySizeHistogram() {
                if ( !$this->sizeHistogram ) {
                    return;
                }
                $maxLength = max( array_keys( $this->sizeHistogram ) );
        Severity: Minor
        Found in maintenance/updateCollation.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 updateBatch has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function updateBatch( IResultWrapper $res ) {
                if ( !$this->dryRun ) {
                    $this->beginTransaction( $this->dbw, __METHOD__ );
                }
                foreach ( $res as $row ) {
        Severity: Minor
        Found in maintenance/updateCollation.php - About 1 hr to fix

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

              private function updateBatch( IResultWrapper $res ) {
                  if ( !$this->dryRun ) {
                      $this->beginTransaction( $this->dbw, __METHOD__ );
                  }
                  foreach ( $res as $row ) {
          Severity: Minor
          Found in maintenance/updateCollation.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 copyBatch has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function copyBatch( IResultWrapper $res ) {
                  $sortKeyInputs = [];
                  foreach ( $res as $row ) {
                      $title = Title::newFromRow( $row );
                      $sortKeyInputs[] = $title->getCategorySortkey( $row->cl_sortkey_prefix );
          Severity: Minor
          Found in maintenance/updateCollation.php - About 1 hr to fix

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

                public function __construct() {
                    parent::__construct();
            
                    $this->addDescription( <<<TEXT
            This script will find all rows in the categorylinks table whose collation is
            Severity: Minor
            Found in maintenance/updateCollation.php - About 1 hr to fix

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

                  private function copyBatch( IResultWrapper $res ) {
                      $sortKeyInputs = [];
                      foreach ( $res as $row ) {
                          $title = Title::newFromRow( $row );
                          $sortKeyInputs[] = $title->getCategorySortkey( $row->cl_sortkey_prefix );
              Severity: Minor
              Found in maintenance/updateCollation.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