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
Maintenance
has 68 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class Maintenance {
/**
* Constants for DB access type
* @see Maintenance::getDbType()
*/
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 );
- Read upRead up
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 );
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__ );
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\"";
- Read upRead up
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' ) );
- Read upRead up
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
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 ) ) {
- Read upRead up
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;
- Read upRead up
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*/ );
}
- Read upRead up
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();
- Read upRead up
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-- ) {
- Read upRead up
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__ );
- Read upRead up
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"