wikimedia/mediawiki-core

View on GitHub
maintenance/includes/Maintenance.php

Summary

Maintainability
F
4 days
Test Coverage

File Maintenance.php has 642 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
Severity: Major
Found in maintenance/includes/Maintenance.php - About 1 day to fix

    Maintenance has 68 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class Maintenance {
        /**
         * Constants for DB access type
         * @see Maintenance::getDbType()
         */
    Severity: Major
    Found in maintenance/includes/Maintenance.php - About 1 day to fix

      Function finalSetup has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public function finalSetup( SettingsBuilder $settingsBuilder ) {
              $config = $settingsBuilder->getConfig();
              $overrides = [];
              $overrides['DBadminuser'] = $config->get( MainConfigNames::DBadminuser );
              $overrides['DBadminpassword'] = $config->get( MainConfigNames::DBadminpassword );
      Severity: Minor
      Found in maintenance/includes/Maintenance.php - About 3 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 finalSetup has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function finalSetup( SettingsBuilder $settingsBuilder ) {
              $config = $settingsBuilder->getConfig();
              $overrides = [];
              $overrides['DBadminuser'] = $config->get( MainConfigNames::DBadminuser );
              $overrides['DBadminpassword'] = $config->get( MainConfigNames::DBadminpassword );
      Severity: Major
      Found in maintenance/includes/Maintenance.php - About 2 hrs to fix

        Method purgeRedundantText has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function purgeRedundantText( $delete = true ) {
                # Data should come off the master, wrapped in a transaction
                $dbw = $this->getPrimaryDB();
                $this->beginTransaction( $dbw, __METHOD__ );
        
        
        Severity: Minor
        Found in maintenance/includes/Maintenance.php - About 1 hr to fix

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

              private static function readlineEmulation( $prompt ) {
                  $bash = ExecutableFinder::findInDefaultPaths( 'bash' );
                  if ( !wfIsWindows() && $bash ) {
                      $encPrompt = Shell::escape( $prompt );
                      $command = "read -er -p $encPrompt && echo \"\$REPLY\"";
          Severity: Minor
          Found in maintenance/includes/Maintenance.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

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

              protected function validateUserOption( $errorMsg ) {
                  if ( $this->hasOption( "user" ) ) {
                      $user = User::newFromName( $this->getOption( 'user' ) );
                  } elseif ( $this->hasOption( "userid" ) ) {
                      $user = User::newFromId( $this->getOption( 'userid' ) );
          Severity: Minor
          Found in maintenance/includes/Maintenance.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

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

              protected function addOption( $name, $description, $required = false,
                  $withArg = false, $shortName = false, $multiOccurrence = false
          Severity: Minor
          Found in maintenance/includes/Maintenance.php - About 45 mins to fix

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

                public function checkRequiredExtensions() {
                    $registry = ExtensionRegistry::getInstance();
                    $missing = [];
                    foreach ( $this->requiredExtensions as $name ) {
                        if ( !$registry->isLoaded( $name ) ) {
            Severity: Minor
            Found in maintenance/includes/Maintenance.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 runChild has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function runChild( $maintClass, $classFile = null ) {
                    // Make sure the class is loaded first
                    if ( !class_exists( $maintClass ) ) {
                        if ( $classFile ) {
                            require_once $classFile;
            Severity: Minor
            Found in maintenance/includes/Maintenance.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 readconsole has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function readconsole( $prompt = '> ' ) {
                    static $isatty = null;
                    if ( $isatty === null ) {
                        $isatty = self::posix_isatty( 0 /*STDIN*/ );
                    }
            Severity: Minor
            Found in maintenance/includes/Maintenance.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 output has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function output( $out, $channel = null ) {
                    // This is sometimes called very early, before Setup.php is included.
                    if ( defined( 'MW_SERVICE_BOOTSTRAP_COMPLETE' ) ) {
                        // Flush stats periodically in long-running CLI scripts to avoid OOM (T181385)
                        $stats = $this->getServiceContainer()->getStatsdDataFactory();
            Severity: Minor
            Found in maintenance/includes/Maintenance.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 countDown has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function countDown( $seconds ) {
                    if ( $this->isQuiet() ) {
                        return;
                    }
                    for ( $i = $seconds; $i >= 0; $i-- ) {
            Severity: Minor
            Found in maintenance/includes/Maintenance.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 purgeRedundantText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function purgeRedundantText( $delete = true ) {
                    # Data should come off the master, wrapped in a transaction
                    $dbw = $this->getPrimaryDB();
                    $this->beginTransaction( $dbw, __METHOD__ );
            
            
            Severity: Minor
            Found in maintenance/includes/Maintenance.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