File WikiModule.php
has 402 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 preloadTitleInfo
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public static function preloadTitleInfo(
Context $context, array $moduleNames
) {
$rl = $context->getResourceLoader();
// getDB() can be overridden to point to a foreign database.
- 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
WikiModule
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class WikiModule extends Module {
/** @var string Origin defaults to users with sitewide authority */
protected $origin = self::ORIGIN_USER_SITEWIDE;
/**
Method preloadTitleInfo
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function preloadTitleInfo(
Context $context, array $moduleNames
) {
$rl = $context->getResourceLoader();
// getDB() can be overridden to point to a foreign database.
Function getPackageFiles
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function getPackageFiles( Context $context ): array {
$main = null;
$files = [];
foreach ( $this->getPages( $context ) as $titleText => $options ) {
- 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 getContentObj
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getContentObj(
PageIdentity $page, Context $context, $maxRedirects = 1
) {
$overrideCallback = $context->getContentOverrideCallback();
$content = $overrideCallback ? call_user_func( $overrideCallback, $page ) : null;
Method getPackageFiles
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getPackageFiles( Context $context ): array {
$main = null;
$files = [];
foreach ( $this->getPages( $context ) as $titleText => $options ) {
Function getContentObj
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function getContentObj(
PageIdentity $page, Context $context, $maxRedirects = 1
) {
$overrideCallback = $context->getContentOverrideCallback();
$content = $overrideCallback ? call_user_func( $overrideCallback, $page ) : 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 getScript
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function getScript( Context $context ) {
if ( $this->isPackaged() ) {
return $this->getPackageFiles( $context );
} else {
$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 getStyles
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getStyles( Context $context ) {
$remoteDir = $this->getConfig()->get( MainConfigNames::ScriptPath );
if ( $remoteDir === '' ) {
// When the site is configured with the script path at the
// document root, MediaWiki uses an empty string but that is
- 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 invalidateModuleCache
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function invalidateModuleCache(
PageIdentity $page,
?RevisionRecord $old,
?RevisionRecord $new,
string $domain
- 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 getPages
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function getPages( Context $context ) {
$config = $this->getConfig();
$pages = [];
// Filter out pages from origins not allowed by the current wiki configuration.
- 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 shouldEmbedModule
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function shouldEmbedModule( Context $context ) {
$overrideCallback = $context->getContentOverrideCallback();
if ( $overrideCallback && $this->getSource() === 'local' ) {
foreach ( $this->getPages( $context ) as $page => $info ) {
$title = Title::newFromText( $page );
- 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 getTitleInfo
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function getTitleInfo( Context $context ) {
$pageNames = array_keys( $this->getPages( $context ) );
sort( $pageNames );
$batchKey = implode( '|', $pageNames );
if ( !isset( $this->titleInfo[$batchKey] ) ) {
- 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 isKnownEmpty
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function isKnownEmpty( Context $context ) {
// If a module has dependencies it cannot be empty. An empty array will be cast to false
if ( $this->getDependencies() ) {
return false;
}
- 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 $content;
Function getContent
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function getContent( $titleText, Context $context ) {
$pageStore = MediaWikiServices::getInstance()->getPageStore();
$title = $pageStore->getPageByText( $titleText );
if ( !$title ) {
return null; // Bad 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
Function fetchTitleInfo
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected static function fetchTitleInfo( IReadableDatabase $db, array $pages, $fname = __METHOD__ ) {
$titleInfo = [];
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
$batch = $linkBatchFactory->newLinkBatch();
foreach ( $pages as $titleText ) {
- 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"