File File.php
has 1104 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @defgroup FileAbstraction File abstraction
* @ingroup FileRepo
*
File
has 135 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class File implements MediaHandlerState {
use ProtectedHookAccessorTrait;
// Bitfield values akin to the revision deletion constants
public const DELETED_FILE = 1;
Function transform
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function transform( $params, $flags = 0 ) {
$thumbnailEpoch = MediaWikiServices::getInstance()->getMainConfig()
->get( MainConfigNames::ThumbnailEpoch );
do {
- 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 transform
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function transform( $params, $flags = 0 ) {
$thumbnailEpoch = MediaWikiServices::getInstance()->getMainConfig()
->get( MainConfigNames::ThumbnailEpoch );
do {
Function getThumbnailSource
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function getThumbnailSource( $params ) {
if ( $this->repo
&& $this->getHandler()->supportsBucketing()
&& isset( $params['physicalWidth'] )
&& $bucket = $this->getThumbnailBucket( $params['physicalWidth'] )
- 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 generateAndSaveThumb
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generateAndSaveThumb( $tmpFile, $transformParams, $flags ) {
$ignoreImageErrors = MediaWikiServices::getInstance()->getMainConfig()
->get( MainConfigNames::IgnoreImageErrors );
if ( !$this->repo->canTransformLocally() ) {
Method getThumbnailSource
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getThumbnailSource( $params ) {
if ( $this->repo
&& $this->getHandler()->supportsBucketing()
&& isset( $params['physicalWidth'] )
&& $bucket = $this->getThumbnailBucket( $params['physicalWidth'] )
Function generateAndSaveThumb
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function generateAndSaveThumb( $tmpFile, $transformParams, $flags ) {
$ignoreImageErrors = MediaWikiServices::getInstance()->getMainConfig()
->get( MainConfigNames::IgnoreImageErrors );
if ( !$this->repo->canTransformLocally() ) {
- 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 generateBucketsIfNeeded
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function generateBucketsIfNeeded( $params, $flags = 0 ) {
if ( !$this->repo
|| !isset( $params['physicalWidth'] )
|| !isset( $params['physicalHeight'] )
) {
Function normalizeTitle
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function normalizeTitle( $title, $exception = false ) {
$ret = $title;
if ( !$ret instanceof Title ) {
if ( $ret instanceof PageIdentity ) {
- 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 getDescriptionText
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getDescriptionText( Language $lang = null ) {
global $wgLang;
if ( !$this->repo || !$this->repo->fetchDescription ) {
return false;
Function getThumbnailBucket
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getThumbnailBucket( $desiredWidth, $page = 1 ) {
$thumbnailBuckets = MediaWikiServices::getInstance()
->getMainConfig()->get( MainConfigNames::ThumbnailBuckets );
$thumbnailMinimumBucketDistance = MediaWikiServices::getInstance()
->getMainConfig()->get( MainConfigNames::ThumbnailMinimumBucketDistance );
- 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 getIsSafeFileUncached
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function getIsSafeFileUncached() {
$trustedMediaFormats = MediaWikiServices::getInstance()->getMainConfig()
->get( MainConfigNames::TrustedMediaFormats );
if ( $this->allowInlineDisplay() ) {
- 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 getDisplayWidthHeight
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getDisplayWidthHeight( $maxWidth, $maxHeight, $page = 1 ) {
if ( !$maxWidth || !$maxHeight ) {
// should never happen
throw new ConfigException( 'Using a choice from $wgImageLimits that is 0x0' );
}
- 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 true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false; # unknown type, not trusted
Avoid too many return
statements within this method. Open
return $bucket;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Function generateBucketsIfNeeded
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function generateBucketsIfNeeded( $params, $flags = 0 ) {
if ( !$this->repo
|| !isset( $params['physicalWidth'] )
|| !isset( $params['physicalHeight'] )
) {
- 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 getTransformScript
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function getTransformScript() {
if ( !isset( $this->transformScript ) ) {
$this->transformScript = false;
if ( $this->repo ) {
$script = $this->repo->getThumbScriptUrl();
- 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"