File FileModule.php
has 858 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
FileModule
has 46 functions (exceeds 20 allowed). Consider refactoring. Open
class FileModule extends Module {
/** @var string Local base path, see __construct() */
protected $localBasePath = '';
/** @var string Remote base path, see __construct() */
Function expandFileInfo
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
private function expandFileInfo( Context $context, $fileInfo, $debugKey ) {
if ( is_string( $fileInfo ) ) {
// Inline common case
return [
'name' => $fileInfo,
- 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 __construct
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public function __construct(
array $options = [],
string $localBasePath = null,
string $remoteBasePath = 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 expandFileInfo
has 97 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function expandFileInfo( Context $context, $fileInfo, $debugKey ) {
if ( is_string( $fileInfo ) ) {
// Inline common case
return [
'name' => $fileInfo,
Method __construct
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(
array $options = [],
string $localBasePath = null,
string $remoteBasePath = null
) {
Function expandPackageFiles
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private function expandPackageFiles( Context $context ) {
$hash = $context->getHash();
if ( isset( $this->expandedPackageFiles[$hash] ) ) {
return $this->expandedPackageFiles[$hash];
}
- 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 readFileInfo
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function readFileInfo( Context $context, array &$fileInfo ) {
// Turn any 'filePath' or 'callback' key into actual 'content',
// and remove the key after that. The callback could return a
// FilePath object; if that happens, fall through to the 'filePath'
// handling.
Function readFileInfo
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private function readFileInfo( Context $context, array &$fileInfo ) {
// Turn any 'filePath' or 'callback' key into actual 'content',
// and remove the key after that. The callback could return a
// FilePath object; if that happens, fall through to the 'filePath'
// handling.
- 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 getFileHashes
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function getFileHashes( Context $context ) {
$files = [];
foreach ( $this->getStyleFiles( $context ) as $filePaths ) {
foreach ( $filePaths as $filePath ) {
- 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 compileLessString
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function compileLessString( $style, $stylePath, Context $context ) {
static $cache;
// @TODO: dependency injection
if ( !$cache ) {
$cache = MediaWikiServices::getInstance()->getObjectCacheFactory()
Method expandPackageFiles
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function expandPackageFiles( Context $context ) {
$hash = $context->getHash();
if ( isset( $this->expandedPackageFiles[$hash] ) ) {
return $this->expandedPackageFiles[$hash];
}
Method getDefinitionSummary
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getDefinitionSummary( Context $context ) {
$summary = parent::getDefinitionSummary( $context );
$options = [];
foreach ( [
Method getFileHashes
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getFileHashes( Context $context ) {
$files = [];
foreach ( $this->getStyleFiles( $context ) as $filePaths ) {
foreach ( $filePaths as $filePath ) {
Function hasGeneratedScripts
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function hasGeneratedScripts() {
foreach (
[ $this->scripts, $this->languageScripts, $this->skinScripts, $this->debugScripts ]
as $scripts
) {
- 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 setSkinStylesOverride
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function setSkinStylesOverride( array $moduleSkinStyles ): void {
$moduleName = $this->getName();
foreach ( $moduleSkinStyles as $skinName => $overrides ) {
// If a module provides overrides for a skin, and that skin also provides overrides
// for the same module, then the module has precedence.
- 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 getScript
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getScript( Context $context ) {
$packageFiles = $this->getPackageFiles( $context );
if ( $packageFiles !== null ) {
foreach ( $packageFiles['files'] as &$file ) {
if ( $file['type'] === 'script+style' ) {
- 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 getLanguageScripts
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function getLanguageScripts( string $lang ): array {
$scripts = self::tryForKey( $this->languageScripts, $lang );
if ( $scripts ) {
return $scripts;
}
- 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 processStyle
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function processStyle( $style, $styleLang, $path, Context $context ) {
$localPath = $this->getLocalPath( $path );
$remotePath = $this->getRemotePath( $path );
if ( $styleLang === 'less' ) {
- 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 getStyles
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getStyles( Context $context ) {
$styles = $this->readStyleFiles(
$this->getStyleFiles( $context ),
$context
);
- 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 getDefinitionSummary
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getDefinitionSummary( Context $context ) {
$summary = parent::getDefinitionSummary( $context );
$options = [];
foreach ( [
- 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 extractBasePaths
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function extractBasePaths(
array $options = [],
$localBasePath = null,
$remoteBasePath = 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"