File ForeignAPIRepo.php
has 369 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
Function fileExistsBatch
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function fileExistsBatch( array $files ) {
$results = [];
foreach ( $files as $k => $f ) {
if ( isset( $this->mFileExists[$f] ) ) {
$results[$k] = $this->mFileExists[$f];
- 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 getThumbUrlFromCache
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getThumbUrlFromCache( $name, $width, $height, $params = "" ) {
// We can't check the local cache using FileRepo functions because
// we override fileExistsBatch(). We have to use the FileBackend directly.
$backend = $this->getBackend(); // convenience
Method fileExistsBatch
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fileExistsBatch( array $files ) {
$results = [];
foreach ( $files as $k => $f ) {
if ( isset( $this->mFileExists[$f] ) ) {
$results[$k] = $this->mFileExists[$f];
Function getThumbUrlFromCache
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function getThumbUrlFromCache( $name, $width, $height, $params = "" ) {
// We can't check the local cache using FileRepo functions because
// we override fileExistsBatch(). We have to use the FileBackend directly.
$backend = $this->getBackend(); // convenience
- 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 getImageInfo
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function getImageInfo( $data ) {
if ( $data && isset( $data['query']['pages'] ) ) {
foreach ( $data['query']['pages'] as $info ) {
if ( isset( $info['imageinfo'][0] ) ) {
$return = $info['imageinfo'][0];
- 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 httpGet
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function httpGet(
$url, $timeout = 'default', $options = [], &$mtime = false
) {
$options['timeout'] = $timeout;
$url = MediaWikiServices::getInstance()->getUrlUtils()
Function __construct
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function __construct( $info ) {
$localFileRepo = MediaWikiServices::getInstance()->getMainConfig()
->get( MainConfigNames::LocalFileRepo );
parent::__construct( $info );
- 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 getThumbUrl
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$name, $width = -1, $height = -1, &$result = null, $otherParams = ''
Method getThumbError
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$name, $width = -1, $height = -1, $otherParams = '', $lang = null
Function findBySha1
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function findBySha1( $hash ) {
$results = $this->fetchImageQuery( [
'aisha1base36' => $hash,
'aiprop' => ForeignAPIFile::getProps(),
'list' => 'allimages',
- 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 $foreignUrl;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $localUrl;
Avoid too many return
statements within this method. Open
return $localUrl;