Function loadWithArgv
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
public function loadWithArgv( array $argv, int $skip = 0 ) {
$this->clear();
$options = [];
$args = [];
- 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
File MaintenanceParameters.php
has 376 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
MaintenanceParameters
has 34 functions (exceeds 20 allowed). Consider refactoring. Open
class MaintenanceParameters {
/**
* Array of desired/allowed params
* @var array<string,array>
Function getHelp
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function getHelp(): string {
$screenWidth = 80; // TODO: Calculate this!
$tab = " ";
$descWidth = $screenWidth - ( 2 * strlen( $tab ) );
- 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 getHelp
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getHelp(): string {
$screenWidth = 80; // TODO: Calculate this!
$tab = " ";
$descWidth = $screenWidth - ( 2 * strlen( $tab ) );
Method loadWithArgv
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function loadWithArgv( array $argv, int $skip = 0 ) {
$this->clear();
$options = [];
$args = [];
Function validate
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function validate() {
$valid = true;
# Check to make sure we've got all the required options
foreach ( $this->mOptDefs as $opt => $info ) {
if ( $info['require'] && !$this->hasOption( $opt ) ) {
- 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 addArg
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addArg( string $arg, string $description, bool $required = true, bool $multi = false ): int {
if ( isset( $this->mArgOffsets[$arg] ) ) {
throw new UnexpectedValueException( "Argument already defined: $arg" );
}
Method addOption
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function addOption( string $name, string $description, bool $required = false,
bool $withArg = false, $shortName = false, bool $multiOccurrence = false
Function setOptionValue
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function setOptionValue( array &$options, string $option, $value ) {
$this->optionsSequence[] = [ $option, $value ];
if ( isset( $this->mOptDefs[$option] ) ) {
$multi = $this->mOptDefs[$option]['multiOccurrence'];
- 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 addArg
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function addArg( string $arg, string $description, bool $required = true, bool $multi = false ): int {
if ( isset( $this->mArgOffsets[$arg] ) ) {
throw new UnexpectedValueException( "Argument already defined: $arg" );
}
- 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 formatHelpItems
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function formatHelpItems( array $items, $heading, $descWidth, $tab ) {
if ( $items === [] ) {
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"