File MaintenanceRunner.php
has 457 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace MediaWiki\Maintenance;
use Exception;
MaintenanceRunner
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class MaintenanceRunner {
/**
* Identifies the script to execute. This may be a class name, the relative or absolute
* path of a script file, a plain name with or without an extension prefix, etc.
Method run
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run(): bool {
$config = $this->getConfig();
// Apply warning thresholds and output mode to Profiler.
// This MUST happen after Setup.php calls MaintenanceRunner::setup,
Method initFromWrapper
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function initFromWrapper( array $argv ) {
$script = null;
$this->parameters->setName( $argv[0] );
$this->parameters->setAllowUnregisteredOptions( true );
Method setup
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setup( SettingsBuilder $settings ) {
// NOTE: this has to happen after the autoloader has been initialized.
$scriptClass = $this->getScriptClass();
$cls = new ReflectionClass( $scriptClass );
Method defineSettings
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function defineSettings() {
global $IP;
if ( $this->parameters->hasOption( 'conf' ) ) {
// Define the constant instead of directly setting $settingsFile
Function defineSettings
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function defineSettings() {
global $IP;
if ( $this->parameters->hasOption( 'conf' ) ) {
// Define the constant instead of directly setting $settingsFile
- 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 overrideConfig
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function overrideConfig( SettingsBuilder $settingsBuilder ) {
$config = $settingsBuilder->getConfig();
if ( $this->scriptObject->getDbType() === Maintenance::DB_NONE ) {
$cacheConf = $config->get( MainConfigNames::LocalisationCacheConf );
- 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 initFromWrapper
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function initFromWrapper( array $argv ) {
$script = null;
$this->parameters->setName( $argv[0] );
$this->parameters->setAllowUnregisteredOptions( true );
- 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 findScriptClass
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function findScriptClass( string $script ): string {
[ $extName, $scriptName ] = $this->splitScript( $script );
if ( $extName !== null ) {
$extension = $this->getExtensionInfo( $extName );
- 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 run
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function run(): bool {
$config = $this->getConfig();
// Apply warning thresholds and output mode to Profiler.
// This MUST happen after Setup.php calls MaintenanceRunner::setup,
- 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 shutdown
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function shutdown() {
$lbFactory = null;
if (
$this->scriptObject->getDbType() !== Maintenance::DB_NONE &&
// Service might be disabled, e.g. when running install.php
- 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 preloadScriptFile
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function preloadScriptFile( string $script ): void {
if ( $this->scriptClass !== null && class_exists( $this->scriptClass ) ) {
// We know the script class, and file-level code was executed because class_exists triggers auto-loading.
return;
}
- 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 shouldExecute
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function shouldExecute() {
if ( !function_exists( 'debug_backtrace' ) ) {
// If someone has a better idea...
return MW_ENTRY_POINT === 'cli';
}
- 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 isAbsolutePath
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static function isAbsolutePath( $path ) {
if ( str_starts_with( $path, '/' ) ) {
return true;
}
- 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 expandScriptFile
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function expandScriptFile( string $scriptName, ?array $extension ): string {
// Append ".php" if not present
$scriptFile = $scriptName;
if ( !str_ends_with( $scriptFile, '.php' ) ) {
$scriptFile .= '.php';
- 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"