Method execute
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
if ( !WikibaseSettings::isRepoEnabled() ) {
$this->fatalError( "You need to have Wikibase enabled in order to use this maintenance script!" );
}
$format = $this->getOption( 'format', 'json' );
Function execute
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
if ( !WikibaseSettings::isRepoEnabled() ) {
$this->fatalError( "You need to have Wikibase enabled in order to use this maintenance script!" );
}
$format = $this->getOption( 'format', 'json' );
- 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 reduceUnits
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function reduceUnits( $reconvert, &$convertUnits ) {
while ( $reconvert ) {
$converted = false;
foreach ( $reconvert as $name => $unit ) {
$convertedUnit = $this->convertDerivedUnit( $unit, $convertUnits );
- 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 convertUnit
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function convertUnit( $unit, $convertUnits, $coherentUnits, $unitUsage, &$reconvert ) {
$unit['unit'] = substr( $unit['unit'], $this->baseLen );
$unit['siUnit'] = substr( $unit['siUnit'], $this->baseLen );
if ( isset( $convertUnits[$unit['unit']] ) ) {
Function convertUnit
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function convertUnit( $unit, $convertUnits, $coherentUnits, $unitUsage, &$reconvert ) {
$unit['unit'] = substr( $unit['unit'], $this->baseLen );
$unit['siUnit'] = substr( $unit['siUnit'], $this->baseLen );
if ( isset( $convertUnits[$unit['unit']] ) ) {
- 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 convertUnit
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function convertUnit( $unit, $convertUnits, $coherentUnits, $unitUsage, &$reconvert ) {
Avoid too many return
statements within this method. Open
return [
'factor' => $unit['si'],
'unit' => $unit['siUnit'],
// These two are just for humans, not used by actual converter
'label' => $unit['unitLabel'],
Avoid too many return
statements within this method. Open
return null;