Function makeFormattedData
has a Cognitive Complexity of 283 (exceeds 5 allowed). Consider refactoring. Open
public function makeFormattedData( $tags ) {
$resolutionunit = !isset( $tags['ResolutionUnit'] ) || $tags['ResolutionUnit'] == 2 ? 2 : 3;
unset( $tags['ResolutionUnit'] );
// Ignore these complex values
- 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 makeFormattedData
has 822 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function makeFormattedData( $tags ) {
$resolutionunit = !isset( $tags['ResolutionUnit'] ) || $tags['ResolutionUnit'] == 2 ? 2 : 3;
unset( $tags['ResolutionUnit'] );
// Ignore these complex values
File FormatMetadata.php
has 1399 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Formatting of image metadata values into human readable form.
*
* This program is free software; you can redistribute it and/or modify
Function flattenArrayReal
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public function flattenArrayReal( $vals, $type = 'ul', $noHtml = false ) {
if ( !is_array( $vals ) ) {
return $vals; // do nothing if not an array;
}
- 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 collapseContactInfo
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public function collapseContactInfo( array $vals ) {
if ( !( isset( $vals['CiAdrExtadr'] )
|| isset( $vals['CiAdrCity'] )
|| isset( $vals['CiAdrCtry'] )
|| isset( $vals['CiEmailWork'] )
- 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 collapseContactInfo
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function collapseContactInfo( array $vals ) {
if ( !( isset( $vals['CiAdrExtadr'] )
|| isset( $vals['CiAdrCity'] )
|| isset( $vals['CiAdrCtry'] )
|| isset( $vals['CiEmailWork'] )
Method flattenArrayReal
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function flattenArrayReal( $vals, $type = 'ul', $noHtml = false ) {
if ( !is_array( $vals ) ) {
return $vals; // do nothing if not an array;
}
Function convertNewsCode
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private function convertNewsCode( $val ) {
if ( !preg_match( '/^\d{8}$/D', $val ) ) {
// Not a valid news code.
return $val;
}
- 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
FormatMetadata
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class FormatMetadata extends ContextSource {
use ProtectedHookAccessorTrait;
/**
* Only output a single language for multi-language fields
Method convertNewsCode
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function convertNewsCode( $val ) {
if ( !preg_match( '/^\d{8}$/D', $val ) ) {
// Not a valid news code.
return $val;
}
Function formatNum
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function formatNum( $num, $round = false, $tagName = null ) {
$m = [];
if ( is_array( $num ) ) {
$out = [];
foreach ( $num as $number ) {
- 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 langItem
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function langItem( $value, $lang, $default = false, $noHtml = false ) {
if ( $lang === false && $default === false ) {
throw new InvalidArgumentException( '$lang and $default cannot both be false.' );
}
- 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 formatNum
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function formatNum( $num, $round = false, $tagName = null ) {
$m = [];
if ( is_array( $num ) ) {
$out = [];
foreach ( $num as $number ) {
Method langItem
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function langItem( $value, $lang, $default = false, $noHtml = false ) {
if ( $lang === false && $default === false ) {
throw new InvalidArgumentException( '$lang and $default cannot both be false.' );
}
Consider simplifying this complex logical expression. Open
if ( !( isset( $vals['CiAdrExtadr'] )
|| isset( $vals['CiAdrCity'] )
|| isset( $vals['CiAdrCtry'] )
|| isset( $vals['CiEmailWork'] )
|| isset( $vals['CiTelWork'] )
Method fetchExtendedMetadata
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fetchExtendedMetadata( File $file ) {
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
// If revision deleted, exit immediately
if ( $file->isDeleted( File::DELETED_FILE ) ) {
Function sanitizeArrayForAPI
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function sanitizeArrayForAPI( &$arr ) {
if ( !is_array( $arr ) ) {
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
Method formatCoords
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function formatCoords( $coord, string $type ) {
if ( !is_numeric( $coord ) ) {
wfDebugLog( 'exif', __METHOD__ . ": \"$coord\" is not a number" );
return $this->literal( (string)$coord );
}
Function formatCoords
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function formatCoords( $coord, string $type ) {
if ( !is_numeric( $coord ) ) {
wfDebugLog( 'exif', __METHOD__ . ": \"$coord\" is not a number" );
return $this->literal( (string)$coord );
}
- 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 discardMultipleValues
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function discardMultipleValues( &$metadata ) {
if ( !is_array( $metadata ) ) {
return;
}
foreach ( $metadata as $key => &$field ) {
- 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
Consider simplifying this complex logical expression. Open
if ( !isset( $h[1] )
|| !isset( $m[1] )
|| !isset( $s[1] )
|| $h[1] == 0
|| $m[1] == 0
Function resolveMultilangValue
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function resolveMultilangValue( $value ) {
if (
!is_array( $value )
|| !isset( $value['_type'] )
|| $value['_type'] !== 'lang'
- 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
Avoid too many return
statements within this method. Open
return "<ol><li>" . implode( "</li>\n<li>", $vals ) . '</li></ol>';
Avoid too many return
statements within this method. Open
return '<ul class="metadata-langlist">' . $content . '</ul>';
Avoid too many return
statements within this method. Open
return $defaultItem;
Avoid too many return
statements within this method. Open
return "<ul><li>" . implode( "</li>\n<li>", $vals ) . '</li></ul>';
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return $content;
Avoid too many return
statements within this method. Open
return "\n*" . implode( "\n*", $vals );
Avoid too many return
statements within this method. Open
return "\n#" . implode( "\n#", $vals );
Avoid too many return
statements within this method. Open
return Html::rawElement( 'span', [ 'lang' => $lang ], $item );
Function resolveMultivalueValue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function resolveMultivalueValue( $value ) {
if ( !is_array( $value ) ) {
return $value;
}
if ( isset( $value['_type'] ) && $value['_type'] === 'lang' ) {
- 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 fetchExtendedMetadata
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function fetchExtendedMetadata( File $file ) {
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
// If revision deleted, exit immediately
if ( $file->isDeleted( File::DELETED_FILE ) ) {
- 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"