File Title.php
has 1901 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Representation of a title within MediaWiki.
*
* See Title.md
Title
has 168 functions (exceeds 20 allowed). Consider refactoring. Open
class Title implements LinkTarget, PageIdentity {
use WikiAwareEntityTrait;
use LinkTargetTrait;
/** @var MapCacheLRU|null */
Function getLocalURL
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
public function getLocalURL( $query = '' ) {
global $wgArticlePath, $wgScript, $wgMainPageIsDomainRoot;
$query = is_array( $query ) ? wfArrayToCgi( $query ) : $query;
- 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 convertByteClassToUnicodeClass
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
public static function convertByteClassToUnicodeClass( $byteClass ) {
$length = strlen( $byteClass );
// Input token queue
$x0 = $x1 = $x2 = '';
// Decoded queue
- 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 convertByteClassToUnicodeClass
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function convertByteClassToUnicodeClass( $byteClass ) {
$length = strlen( $byteClass );
// Input token queue
$x0 = $x1 = $x2 = '';
// Decoded queue
Method getLocalURL
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getLocalURL( $query = '' ) {
global $wgArticlePath, $wgScript, $wgMainPageIsDomainRoot;
$query = is_array( $query ) ? wfArrayToCgi( $query ) : $query;
Function loadFromRow
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function loadFromRow( $row ) {
if ( $row ) { // page found
if ( isset( $row->page_id ) ) {
$this->mArticleID = (int)$row->page_id;
}
- 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 getLinksFrom
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getLinksFrom( $options = [], $table = 'pagelinks', $prefix = 'pl' ) {
$id = $this->getArticleID();
# If the page doesn't exist; there can't be any link from this page
if ( !$id ) {
Method getEditNotices
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getEditNotices( $oldid = 0 ) {
$notices = [];
$editnotice_base = 'editnotice-' . $this->mNamespace;
// Optional notice for the entire namespace
Method getLinksTo
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getLinksTo( $options = [], $table = 'pagelinks', $prefix = 'pl' ) {
if ( count( $options ) > 0 ) {
$db = $this->getDbProvider()->getPrimaryDatabase();
} else {
$db = $this->getDbProvider()->getReplicaDatabase();
Method purgeExpiredRestrictions
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function purgeExpiredRestrictions() {
if ( MediaWikiServices::getInstance()->getReadOnlyMode()->isReadOnly() ) {
return;
}
Function getParentCategoryTree
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function getParentCategoryTree( $children = [] ) {
$stack = [];
$parents = $this->getParentCategories();
if ( $parents ) {
- 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 invalidateCache
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function invalidateCache( $purgeTime = null ) {
if ( MediaWikiServices::getInstance()->getReadOnlyMode()->isReadOnly() ) {
return false;
}
if ( $this->mArticleID === 0 ) {
Method loadFromRow
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function loadFromRow( $row ) {
if ( $row ) { // page found
if ( isset( $row->page_id ) ) {
$this->mArticleID = (int)$row->page_id;
}
Function getLinksTo
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getLinksTo( $options = [], $table = 'pagelinks', $prefix = 'pl' ) {
if ( count( $options ) > 0 ) {
$db = $this->getDbProvider()->getPrimaryDatabase();
} else {
$db = $this->getDbProvider()->getReplicaDatabase();
- 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 getEditNotices
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getEditNotices( $oldid = 0 ) {
$notices = [];
$editnotice_base = 'editnotice-' . $this->mNamespace;
// Optional notice for the entire namespace
- 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 getNsText
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getNsText() {
if ( $this->isExternal() ) {
// This probably shouldn't even happen, except for interwiki transclusion.
// If possible, use the canonical name for the foreign namespace.
if ( $this->mNamespace === NS_MAIN ) {
- 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 makeName
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function makeName( $ns, $title, $fragment = '', $interwiki = '',
$canonicalNamespace = false
Function isValidRedirectTarget
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function isValidRedirectTarget() {
global $wgInvalidRedirectTargets;
if ( $this->isSpecialPage() ) {
// invalid redirect targets are stored in a global array, but explicitly disallow Userlogout here
- 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 getLinksFrom
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getLinksFrom( $options = [], $table = 'pagelinks', $prefix = 'pl' ) {
$id = $this->getArticleID();
# If the page doesn't exist; there can't be any link from this page
if ( !$id ) {
- 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 $this->mDbkeyform == '';
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->hasSourceText() !== false;
Avoid too many return
statements within this method. Open
return $pageLang;
Avoid too many return
statements within this method. Open
return $this->isValid();
Function newFromTextThrow
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function newFromTextThrow( $text, $defaultNamespace = NS_MAIN ) {
if ( is_object( $text ) ) {
throw new InvalidArgumentException( '$text must be a string, given an object' );
} elseif ( $text === null ) {
// Legacy code relies on MalformedTitleException being thrown in this 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
Function getPageViewLanguage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getPageViewLanguage() {
$services = MediaWikiServices::getInstance();
if ( $this->isSpecialPage() ) {
// If the user chooses a variant, the content is actually
- 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 fixSpecialName
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function fixSpecialName() {
if ( $this->isSpecialPage() ) {
$spFactory = MediaWikiServices::getInstance()->getSpecialPageFactory();
[ $canonicalName, $par ] = $spFactory->resolveAlias( $this->mDbkeyform );
if ( $canonicalName ) {
- 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 getContentModel
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getContentModel( $flags = 0 ) {
if ( $this->mForcedContentModel ) {
if ( !$this->mContentModel ) {
throw new RuntimeException( 'Got out of sync; an empty model is being forced' );
}
- 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 getFieldFromPageStore
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function getFieldFromPageStore( $field, $flags ) {
$pageStore = MediaWikiServices::getInstance()->getPageStore();
if ( !in_array( $field, $pageStore->getSelectFields(), true ) ) {
throw new InvalidArgumentException( "Unknown field: $field" );
- 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"