File OutputPage.php
has 2401 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Preparation for the final page rendering.
*
* This program is free software; you can redistribute it and/or modify
OutputPage
has 199 functions (exceeds 20 allowed). Consider refactoring. Open
class OutputPage extends ContextSource {
use ProtectedHookAccessorTrait;
/** Output CSP policies as headers */
public const CSP_HEADERS = 'headers';
Function output
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
public function output( $return = false ) {
if ( $this->mDoNothing ) {
return $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
Method getJSVars
has 122 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getJSVars( ?int $flag = null ) {
$curRevisionId = 0;
$articleId = 0;
$canonicalSpecialPageName = false; # T23115
$services = MediaWikiServices::getInstance();
Method getHeadLinksArray
has 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getHeadLinksArray() {
$tags = [];
$config = $this->getConfig();
if ( $this->cspOutputMode === self::CSP_META ) {
Function addParserOutputMetadata
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public function addParserOutputMetadata( ParserOutput $parserOutput ) {
// T301020 This should eventually use the standard "merge ParserOutput"
// function between $parserOutput and $this->metadata.
$this->mLanguageLinks =
array_merge( $this->mLanguageLinks, $parserOutput->getLanguageLinks() );
- 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 output
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function output( $return = false ) {
if ( $this->mDoNothing ) {
return $return ? '' : null;
}
Method addParserOutputMetadata
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addParserOutputMetadata( ParserOutput $parserOutput ) {
// T301020 This should eventually use the standard "merge ParserOutput"
// function between $parserOutput and $this->metadata.
$this->mLanguageLinks =
array_merge( $this->mLanguageLinks, $parserOutput->getLanguageLinks() );
Function getJSVars
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public function getJSVars( ?int $flag = null ) {
$curRevisionId = 0;
$articleId = 0;
$canonicalSpecialPageName = false; # T23115
$services = MediaWikiServices::getInstance();
- 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 getHeadLinksArray
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function getHeadLinksArray() {
$tags = [];
$config = $this->getConfig();
if ( $this->cspOutputMode === self::CSP_META ) {
- 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 addCategoryLinks
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function addCategoryLinks( array $categories ) {
if ( !$categories ) {
return;
}
- 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 showPermissionsErrorPage
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function showPermissionsErrorPage( array $errors, $action = null ) {
$services = MediaWikiServices::getInstance();
$groupPermissionsLookup = $services->getGroupPermissionsLookup();
foreach ( $errors as $key => $error ) {
$errors[$key] = (array)$error;
- 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 checkLastModified
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function checkLastModified( $timestamp ) {
if ( !$timestamp || $timestamp == '19700101000000' ) {
wfDebug( __METHOD__ . ": CACHE DISABLED, NO TIMESTAMP" );
return false;
}
Method showPermissionsErrorPage
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function showPermissionsErrorPage( array $errors, $action = null ) {
$services = MediaWikiServices::getInstance();
$groupPermissionsLookup = $services->getGroupPermissionsLookup();
foreach ( $errors as $key => $error ) {
$errors[$key] = (array)$error;
Method getRlClient
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getRlClient() {
if ( !$this->rlClient ) {
$context = $this->getRlClientContext();
$rl = $this->getResourceLoader();
$this->addModules( [
Method getHeadLinksSyndicationArray
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getHeadLinksSyndicationArray( Config $config ) {
if ( !$config->get( MainConfigNames::Feed ) ) {
return [];
}
Method sendCacheControl
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sendCacheControl() {
$response = $this->getRequest()->response();
$config = $this->getConfig();
$this->addVaryHeader( 'Cookie' );
Method headElement
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function headElement( Skin $sk, $includeStyle = true ) {
$config = $this->getConfig();
$userdir = $this->getLanguage()->getDir();
$services = MediaWikiServices::getInstance();
$sitedir = $services->getContentLanguage()->getDir();
Function sendCacheControl
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function sendCacheControl() {
$response = $this->getRequest()->response();
$config = $this->getConfig();
$this->addVaryHeader( 'Cookie' );
- 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 getHeadLinksAlternateURLsArray
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getHeadLinksAlternateURLsArray() {
$tags = [];
$languageUrls = [];
$action = $this->getContext()->getActionName();
$isCanonicalUrlAction = in_array( $action, [ 'history', 'info' ] );
Method addCategoryLinks
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addCategoryLinks( array $categories ) {
if ( !$categories ) {
return;
}
Method getRlClientContext
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getRlClientContext() {
if ( !$this->rlClientContext ) {
$query = ResourceLoader::makeLoaderQuery(
[], // modules; not relevant
$this->getLanguage()->getCode(),
Method getHeadLinksCanonicalURLArray
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getHeadLinksCanonicalURLArray( Config $config ) {
$tags = [];
$canonicalUrl = $this->mCanonicalUrl;
if ( $config->get( MainConfigNames::EnableCanonicalServerLink ) ) {
Consider simplifying this complex logical expression. Open
if ( in_array( $action, [ 'read', 'edit', 'createpage', 'createtalk', 'upload' ] )
&& !$this->getUser()->isNamed() && count( $errors ) == 1 && isset( $errors[0][0] )
&& ( $errors[0][0] == 'badaccess-groups' || $errors[0][0] == 'badaccess-group0' )
&& ( $groupPermissionsLookup->groupHasPermission( 'user', $action )
|| $groupPermissionsLookup->groupHasPermission( 'autoconfirmed', $action ) )
Function getHeadLinksCopyrightArray
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function getHeadLinksCopyrightArray( Config $config ) {
$tags = [];
if ( $this->copyrightUrl !== null ) {
$copyright = $this->copyrightUrl;
- 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 getHeadLinksCanonicalURLArray
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function getHeadLinksCanonicalURLArray( Config $config ) {
$tags = [];
$canonicalUrl = $this->mCanonicalUrl;
if ( $config->get( MainConfigNames::EnableCanonicalServerLink ) ) {
- 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 styleLink
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function styleLink( $style, array $options ) {
if ( isset( $options['dir'] ) && $this->getLanguage()->getDir() != $options['dir'] ) {
return '';
}
Function checkLastModified
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function checkLastModified( $timestamp ) {
if ( !$timestamp || $timestamp == '19700101000000' ) {
wfDebug( __METHOD__ . ": CACHE DISABLED, NO TIMESTAMP" );
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
Function styleLink
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function styleLink( $style, array $options ) {
if ( isset( $options['dir'] ) && $this->getLanguage()->getDir() != $options['dir'] ) {
return '';
}
- 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 getContentLangForJS
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function getContentLangForJS(): Language {
if ( !$this->contentLang ) {
// If this is not set, then we're likely not on in a request that renders page content
// (e.g. ViewAction or ApiParse), but rather a different Action or SpecialPage.
// In that case there isn't a main ParserOutput object to represent the page or output.
- 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 getHeadLinksSyndicationArray
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function getHeadLinksSyndicationArray( Config $config ) {
if ( !$config->get( MainConfigNames::Feed ) ) {
return [];
}
- 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 addWikiTextTitleInternal
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$text, PageReference $title, $linestart, $interface, $wrapperClass = null
Method showErrorPage
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$title, $msg, $params = [], $returnto = null, $returntoquery = null
Function getHeadLinksAlternateURLsArray
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function getHeadLinksAlternateURLsArray() {
$tags = [];
$languageUrls = [];
$action = $this->getContext()->getActionName();
$isCanonicalUrlAction = in_array( $action, [ 'history', '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 buildExemptModules
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function buildExemptModules() {
$chunks = [];
// Requirements:
// - Within modules provided by the software (core, skin, extensions),
- 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 loadSkinModules
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function loadSkinModules( $sk ) {
foreach ( $sk->getDefaultModules() as $group => $modules ) {
if ( $group === 'styles' ) {
foreach ( $modules as $moduleMembers ) {
$this->addModuleStyles( $moduleMembers );
- 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 true;
Avoid too many return
statements within this method. Open
return false;
Function prepareErrorPage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function prepareErrorPage( $pageTitle = null, $htmlTitle = false ) {
if ( $pageTitle !== null || $htmlTitle !== false ) {
wfDeprecated( __METHOD__ . ' with explicit arguments', '1.41' );
if ( $pageTitle !== null ) {
$this->setPageTitle( $pageTitle );
- 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 formatPermissionsErrorMessage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function formatPermissionsErrorMessage( array $errors, $action = null ) {
if ( $action == null ) {
$text = $this->msg( 'permissionserrorstext', count( $errors ) )->plain() . "\n\n";
} else {
$action_desc = $this->msg( "action-$action" )->plain();
- 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"