File FileRepo.php
has 988 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @defgroup FileRepo File Repository
*
* @brief This module handles how MediaWiki interacts with filesystems.
FileRepo
has 84 functions (exceeds 20 allowed). Consider refactoring. Open
class FileRepo {
public const DELETE_SOURCE = 1;
public const OVERWRITE = 2;
public const OVERWRITE_SAME = 4;
public const SKIP_LOCKING = 8;
Function findFile
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function findFile( $title, $options = [] ) {
if ( !empty( $options['private'] ) && !( $options['private'] instanceof Authority ) ) {
throw new InvalidArgumentException(
__METHOD__ . ' called with the `private` option set to something ' .
'other than an Authority object'
- 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 publishBatch
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function publishBatch( array $ntuples, $flags = 0 ) {
$this->assertWritableRepo(); // fail out if read-only
$backend = $this->backend; // convenience
// Try creating directories
Function publishBatch
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function publishBatch( array $ntuples, $flags = 0 ) {
$this->assertWritableRepo(); // fail out if read-only
$backend = $this->backend; // convenience
// Try creating directories
- 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 findFile
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function findFile( $title, $options = [] ) {
if ( !empty( $options['private'] ) && !( $options['private'] instanceof Authority ) ) {
throw new InvalidArgumentException(
__METHOD__ . ' called with the `private` option set to something ' .
'other than an Authority object'
Method __construct
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( array $info = null ) {
// Verify required settings presence
if (
$info === null
|| !array_key_exists( 'name', $info )
Function __construct
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function __construct( array $info = null ) {
// Verify required settings presence
if (
$info === null
|| !array_key_exists( 'name', $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
Function findFiles
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function findFiles( array $items, $flags = 0 ) {
$result = [];
foreach ( $items as $item ) {
if ( is_array( $item ) ) {
$title = $item['title'];
- 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 storeBatch
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function storeBatch( array $triplets, $flags = 0 ) {
$this->assertWritableRepo(); // fail out if read-only
if ( $flags & self::DELETE_SOURCE ) {
throw new InvalidArgumentException( "DELETE_SOURCE not supported in " . __METHOD__ );
Function storeBatch
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function storeBatch( array $triplets, $flags = 0 ) {
$this->assertWritableRepo(); // fail out if read-only
if ( $flags & self::DELETE_SOURCE ) {
throw new InvalidArgumentException( "DELETE_SOURCE not supported in " . __METHOD__ );
- 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 findFileFromKey
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function findFileFromKey( $sha1, $options = [] ) {
if ( !empty( $options['private'] ) && !( $options['private'] instanceof Authority ) ) {
throw new InvalidArgumentException(
__METHOD__ . ' called with the `private` option set to something ' .
'other than an Authority object'
- 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 findFileFromKey
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function findFileFromKey( $sha1, $options = [] ) {
if ( !empty( $options['private'] ) && !( $options['private'] instanceof Authority ) ) {
throw new InvalidArgumentException(
__METHOD__ . ' called with the `private` option set to something ' .
'other than an Authority object'
Method findFiles
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function findFiles( array $items, $flags = 0 ) {
$result = [];
foreach ( $items as $item ) {
if ( is_array( $item ) ) {
$title = $item['title'];
Method quickImportBatch
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function quickImportBatch( array $triples ) {
$status = $this->newGood();
$operations = [];
foreach ( $triples as $triple ) {
[ $src, $dst ] = $triple;
Method deleteBatch
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function deleteBatch( array $sourceDestPairs ) {
$this->assertWritableRepo(); // fail out if read-only
// Try creating directories
$this->initZones( [ 'public', 'deleted' ] );
Function quickImportBatch
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function quickImportBatch( array $triples ) {
$status = $this->newGood();
$operations = [];
foreach ( $triples as $triple ) {
[ $src, $dst ] = $triple;
- 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 getInfo
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getInfo() {
$ret = [
'name' => $this->getName(),
'displayname' => $this->getDisplayName(),
'rootUrl' => $this->getZoneUrl( 'public' ),
Method publish
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$src, $dstRel, $archiveRel, $flags = 0, array $options = []
Function enumFilesInStorage
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function enumFilesInStorage( $callback ) {
$publicRoot = $this->getZonePath( 'public' );
$numDirs = 1 << ( $this->hashLevels * 4 );
// Use a priori assumptions about directory structure
// to reduce the tree height of the scanning process.
- 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 false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $img;
Avoid too many return
statements within this method. Open
return $img;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $this->thumbUrl;
Avoid too many return
statements within this method. Open
return "{$this->url}/transcoded";
Function newFile
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function newFile( $title, $time = false ) {
$title = File::normalizeTitle( $title );
if ( !$title ) {
return 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
Function deleteBatch
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function deleteBatch( array $sourceDestPairs ) {
$this->assertWritableRepo(); // fail out if read-only
// Try creating directories
$this->initZones( [ 'public', 'deleted' ] );
- 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 getZoneUrl
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getZoneUrl( $zone, $ext = null ) {
if ( in_array( $zone, [ 'public', 'thumb', 'transcoded' ] ) ) {
// standard public zones
if ( $ext !== null && isset( $this->zones[$zone]['urlsByExt'][$ext] ) ) {
// custom URL for extension/zone
- 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 getDescriptionRenderUrl
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getDescriptionRenderUrl( $name, $lang = null ) {
$query = 'action=render';
if ( $lang !== null ) {
$query .= '&uselang=' . urlencode( $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"