Function animateFilterAndLang
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
private function animateFilterAndLang( $name ) {
$this->debug( "animate filter for tag $name" );
if ( $this->reader->nodeType !== XMLReader::ELEMENT ) {
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 animateFilterAndLang
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function animateFilterAndLang( $name ) {
$this->debug( "animate filter for tag $name" );
if ( $this->reader->nodeType !== XMLReader::ELEMENT ) {
return;
}
File SVGReader.php
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Extraction of SVG image metadata.
*
Function read
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
protected function read() {
$keepReading = $this->reader->read();
/* Skip until first element */
while ( $keepReading && $this->reader->nodeType !== XMLReader::ELEMENT ) {
- 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 handleSVGAttribs
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function handleSVGAttribs() {
$defaultWidth = self::DEFAULT_WIDTH;
$defaultHeight = self::DEFAULT_HEIGHT;
$aspect = 1.0;
$width = null;
- 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 read
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function read() {
$keepReading = $this->reader->read();
/* Skip until first element */
while ( $keepReading && $this->reader->nodeType !== XMLReader::ELEMENT ) {
Method handleSVGAttribs
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function handleSVGAttribs() {
$defaultWidth = self::DEFAULT_WIDTH;
$defaultHeight = self::DEFAULT_HEIGHT;
$aspect = 1.0;
$width = null;
Method __construct
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( $source ) {
$svgMetadataCutoff = MediaWikiServices::getInstance()->getMainConfig()
->get( MainConfigNames::SVGMetadataCutoff );
$this->reader = new XMLReader();
Method scaleSVGUnit
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function scaleSVGUnit( $length, $viewportSize = 512 ) {
// Per CSS values spec, assume 96dpi.
static $unitLength = [
'px' => 1.0,
'pt' => 1.333333,
Function readField
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function readField( $name, $metafield = null ) {
$this->debug( "Read field $metafield" );
if ( !$metafield || $this->reader->nodeType !== XMLReader::ELEMENT ) {
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
Avoid deeply nested control flow statements. Open
if ( LanguageCode::isWellFormedLanguageTag( $itemPrefix ) ) {
$this->languagePrefixes[$itemPrefix] = self::LANG_PREFIX_MATCH;
}
Consider simplifying this complex logical expression. Open
if ( $isSVG && $tag === 'title' ) {
$this->readField( $tag, 'title' );
} elseif ( $isSVG && $tag === 'desc' ) {
$this->readField( $tag, 'description' );
} elseif ( $isSVG && $tag === 'metadata' && $type === XMLReader::ELEMENT ) {
Function __construct
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function __construct( $source ) {
$svgMetadataCutoff = MediaWikiServices::getInstance()->getMainConfig()
->get( MainConfigNames::SVGMetadataCutoff );
$this->reader = new XMLReader();
- 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"