File Skin.php
has 1438 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
Skin
has 71 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class Skin extends ContextSource {
use ProtectedHookAccessorTrait;
/**
* @var array link options used in Skin::makeLink. Can be set by skin option `link`.
Function addToSidebarPlain
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
public function addToSidebarPlain( &$bar, $text ) {
$lines = explode( "\n", $text );
$heading = '';
$config = $this->getConfig();
- 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 buildNavUrls
has 128 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function buildNavUrls() {
$out = $this->getOutput();
$title = $this->getTitle();
$thispage = $title->getPrefixedDBkey();
$uploadNavigationUrl = $this->getConfig()->get( MainConfigNames::UploadNavigationUrl );
Function getLanguages
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public function getLanguages() {
if ( $this->getConfig()->get( MainConfigNames::HideInterlanguageLinks ) ) {
return [];
}
if ( $this->languageLinks === 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 buildNavUrls
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
protected function buildNavUrls() {
$out = $this->getOutput();
$title = $this->getTitle();
$thispage = $title->getPrefixedDBkey();
$uploadNavigationUrl = $this->getConfig()->get( MainConfigNames::UploadNavigationUrl );
- 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 getNewtalks
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getNewtalks() {
if ( $this->hideNewTalkMessagesForCurrentSession() ) {
return '';
}
Method getLanguages
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getLanguages() {
if ( $this->getConfig()->get( MainConfigNames::HideInterlanguageLinks ) ) {
return [];
}
if ( $this->languageLinks === null ) {
Method addToSidebarPlain
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addToSidebarPlain( &$bar, $text ) {
$lines = explode( "\n", $text );
$heading = '';
$config = $this->getConfig();
Method getDefaultModules
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getDefaultModules() {
$out = $this->getOutput();
$user = $this->getUser();
// Modules declared in the $modules literal are loaded
Function getSiteNotice
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function getSiteNotice() {
$siteNotice = '';
if ( $this->getHookRunner()->onSiteNoticeBefore( $siteNotice, $this ) ) {
if ( $this->getUser()->isRegistered() ) {
- 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 getTemplateData
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getTemplateData() {
$title = $this->getTitle();
$out = $this->getOutput();
$user = $this->getUser();
$isMainPage = $title->isMainPage();
Function subPageSubtitleInternal
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private function subPageSubtitleInternal() {
$services = MediaWikiServices::getInstance();
$linkRenderer = $services->getLinkRenderer();
$out = $this->getOutput();
$title = $out->getTitle();
- 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 getCategoryLinks
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getCategoryLinks() {
$out = $this->getOutput();
$allCats = $out->getCategoryLinks();
$title = $this->getTitle();
$services = MediaWikiServices::getInstance();
Function getPersonalToolsForMakeListItem
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
final public function getPersonalToolsForMakeListItem( $urls, $applyClassesToListItems = false ) {
$personal_tools = [];
foreach ( $urls as $key => $plink ) {
# The class on a personal_urls item is meant to go on the <a> instead
# of the <li> so we have to use a single item "links" array instead
- 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 getUndeleteLink
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function getUndeleteLink() {
$action = $this->getRequest()->getRawVal( 'action', 'view' );
$title = $this->getTitle();
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
- 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 makeToolbox
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function makeToolbox( $navUrls, $feedUrls ) {
$toolbox = [];
if ( $navUrls['whatlinkshere'] ?? null ) {
$toolbox['whatlinkshere'] = $navUrls['whatlinkshere'];
$toolbox['whatlinkshere']['id'] = 't-whatlinkshere';
Function getNewtalks
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function getNewtalks() {
if ( $this->hideNewTalkMessagesForCurrentSession() ) {
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 subPageSubtitleInternal
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function subPageSubtitleInternal() {
$services = MediaWikiServices::getInstance();
$linkRenderer = $services->getLinkRenderer();
$out = $this->getOutput();
$title = $out->getTitle();
Method getPersonalToolsForMakeListItem
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
final public function getPersonalToolsForMakeListItem( $urls, $applyClassesToListItems = false ) {
$personal_tools = [];
foreach ( $urls as $key => $plink ) {
# The class on a personal_urls item is meant to go on the <a> instead
# of the <li> so we have to use a single item "links" array instead
Method getUndeleteLink
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getUndeleteLink() {
$action = $this->getRequest()->getRawVal( 'action', 'view' );
$title = $this->getTitle();
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
Method buildSidebar
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildSidebar() {
if ( $this->sidebar === null ) {
$services = MediaWikiServices::getInstance();
$callback = function ( $old = null, &$ttl = null ) {
$bar = [];
Function getDefaultModules
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function getDefaultModules() {
$out = $this->getOutput();
$user = $this->getUser();
// Modules declared in the $modules literal are loaded
- 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 getCachedNotice
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getCachedNotice( $name ) {
$config = $this->getConfig();
if ( $name === 'default' ) {
// special case
Method doEditSectionLink
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function doEditSectionLink( Title $nt, $section, $sectionTitle, Language $lang ) {
// HTML generated here should probably have userlangattributes
// added to it for LTR text on RTL pages
$attribs = [];
Function getRelevantUser
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function getRelevantUser(): ?UserIdentity {
if ( $this->mRelevantUser === false ) {
$this->mRelevantUser = null; // false indicates we never attempted to load it.
$title = $this->getRelevantTitle();
if ( $title->hasSubjectNamespace( NS_USER ) ) {
- 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 makeToolbox
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function makeToolbox( $navUrls, $feedUrls ) {
$toolbox = [];
if ( $navUrls['whatlinkshere'] ?? null ) {
$toolbox['whatlinkshere'] = $navUrls['whatlinkshere'];
$toolbox['whatlinkshere']['id'] = 't-whatlinkshere';
- 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 normalizeKey
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function normalizeKey( string $key ) {
$config = MediaWikiServices::getInstance()->getMainConfig();
$defaultSkin = $config->get( MainConfigNames::DefaultSkin );
$fallbackSkin = $config->get( MainConfigNames::FallbackSkin );
$skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
Method preloadExistence
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function preloadExistence() {
$titles = [];
// User/talk link
$user = $this->getUser();
Method getSiteNotice
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getSiteNotice() {
$siteNotice = '';
if ( $this->getHookRunner()->onSiteNoticeBefore( $siteNotice, $this ) ) {
if ( $this->getUser()->isRegistered() ) {
Function getCategoryLinks
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getCategoryLinks() {
$out = $this->getOutput();
$allCats = $out->getCategoryLinks();
$title = $this->getTitle();
$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 getTemplateData
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getTemplateData() {
$title = $this->getTitle();
$out = $this->getOutput();
$user = $this->getUser();
$isMainPage = $title->isMainPage();
- 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 getPageClasses
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getPageClasses( $title ) {
$services = MediaWikiServices::getInstance();
$ns = $title->getNamespace();
$numeric = 'ns-' . $ns;
- 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 preloadExistence
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function preloadExistence() {
$titles = [];
// User/talk link
$user = $this->getUser();
- 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 initPage
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function initPage( OutputPage $out ) {
$skinMetaTags = $this->getConfig()->get( MainConfigNames::SkinMetaTags );
$siteName = $this->getConfig()->get( MainConfigNames::Sitename );
$this->preloadExistence();
Method getRelevantUser
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getRelevantUser(): ?UserIdentity {
if ( $this->mRelevantUser === false ) {
$this->mRelevantUser = null; // false indicates we never attempted to load it.
$title = $this->getRelevantTitle();
if ( $title->hasSubjectNamespace( NS_USER ) ) {
Function normalizeKey
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function normalizeKey( string $key ) {
$config = MediaWikiServices::getInstance()->getMainConfig();
$defaultSkin = $config->get( MainConfigNames::DefaultSkin );
$fallbackSkin = $config->get( MainConfigNames::FallbackSkin );
$skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
- 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 getCachedNotice
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function getCachedNotice( $name ) {
$config = $this->getConfig();
if ( $name === 'default' ) {
// special case
- 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 null;
Avoid too many return
statements within this method. Open
return Html::rawElement(
'div',
[
'class' => $name,
'lang' => $contLang->getHtmlCode(),