File Article.php
has 1328 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
Article
has 48 functions (exceeds 20 allowed). Consider refactoring. Open
class Article implements Page {
use ProtectedHookAccessorTrait;
use NonSerializableTrait;
/**
Method setOldSubtitle
has 135 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setOldSubtitle( $oldid = 0 ) {
if ( !$this->getHookRunner()->onDisplayOldSubtitle( $this, $oldid ) ) {
return;
}
Method generateContentOutput
has 124 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function generateContentOutput(
Authority $performer,
ParserOptions $parserOptions,
int $oldid,
OutputPage $outputPage,
Method showMissingArticle
has 124 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function showMissingArticle() {
$context = $this->getContext();
$send404Code = $context->getConfig()->get( MainConfigNames::Send404Code );
$outputPage = $context->getOutput();
Method view
has 115 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function view() {
$context = $this->getContext();
$useFileCache = $context->getConfig()->get( MainConfigNames::UseFileCache );
# Get variables from query string
Method showPatrolFooter
has 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function showPatrolFooter() {
$context = $this->getContext();
$mainConfig = $context->getConfig();
$useNPPatrol = $mainConfig->get( MainConfigNames::UseNPPatrol );
$useRCPatrol = $mainConfig->get( MainConfigNames::UseRCPatrol );
Function getOldIDFromRequest
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public function getOldIDFromRequest() {
$this->mRedirectUrl = false;
$request = $this->getContext()->getRequest();
$oldid = $request->getIntOrNull( 'oldid' );
- 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 generateContentOutput
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
private function generateContentOutput(
Authority $performer,
ParserOptions $parserOptions,
int $oldid,
OutputPage $outputPage,
- 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 showPatrolFooter
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function showPatrolFooter() {
$context = $this->getContext();
$mainConfig = $context->getConfig();
$useNPPatrol = $mainConfig->get( MainConfigNames::UseNPPatrol );
$useRCPatrol = $mainConfig->get( MainConfigNames::UseRCPatrol );
- 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 showMissingArticle
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function showMissingArticle() {
$context = $this->getContext();
$send404Code = $context->getConfig()->get( MainConfigNames::Send404Code );
$outputPage = $context->getOutput();
- 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 getRobotPolicy
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getRobotPolicy( $action, ParserOutput $pOutput = null ) {
$context = $this->getContext();
$mainConfig = $context->getConfig();
$articleRobotPolicies = $mainConfig->get( MainConfigNames::ArticleRobotPolicies );
$namespaceRobotPolicies = $mainConfig->get( MainConfigNames::NamespaceRobotPolicies );
Function view
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function view() {
$context = $this->getContext();
$useFileCache = $context->getConfig()->get( MainConfigNames::UseFileCache );
# Get variables from query string
- 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 showDiffPage
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function showDiffPage() {
$context = $this->getContext();
$outputPage = $context->getOutput();
$outputPage->addBodyClasses( 'mw-article-diff' );
$request = $context->getRequest();
Method getOldIDFromRequest
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getOldIDFromRequest() {
$this->mRedirectUrl = false;
$request = $this->getContext()->getRequest();
$oldid = $request->getIntOrNull( 'oldid' );
Function fetchRevisionRecord
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function fetchRevisionRecord() {
if ( $this->fetchResult ) {
return $this->mRevisionRecord;
}
- 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 showRedirectedFromHeader
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function showRedirectedFromHeader() {
$context = $this->getContext();
$redirectSources = $context->getConfig()->get( MainConfigNames::RedirectSources );
$outputPage = $context->getOutput();
$request = $context->getRequest();
Function getRobotPolicy
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function getRobotPolicy( $action, ParserOutput $pOutput = null ) {
$context = $this->getContext();
$mainConfig = $context->getConfig();
$articleRobotPolicies = $mainConfig->get( MainConfigNames::ArticleRobotPolicies );
$namespaceRobotPolicies = $mainConfig->get( MainConfigNames::NamespaceRobotPolicies );
- 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 showDeletedRevisionHeader
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function showDeletedRevisionHeader() {
if ( !$this->mRevisionRecord->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
// Not deleted
return true;
}
Method fetchRevisionRecord
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fetchRevisionRecord() {
if ( $this->fetchResult ) {
return $this->mRevisionRecord;
}
Method doOutputFromRenderStatus
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function doOutputFromRenderStatus(
RevisionRecord $rev,
Status $renderStatus,
OutputPage $outputPage,
array $textOptions
Function showRedirectedFromHeader
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function showRedirectedFromHeader() {
$context = $this->getContext();
$redirectSources = $context->getConfig()->get( MainConfigNames::RedirectSources );
$outputPage = $context->getOutput();
$request = $context->getRequest();
- 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
Consider simplifying this complex logical expression. Open
if ( !( $user && $user->isRegistered() ) && !$ip ) {
// User does not exist
$outputPage->addHTML( Html::warningBox(
$context->msg( 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) )->parse(),
'mw-userpage-userdoesnotexist'
Method generateContentOutput
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Authority $performer,
ParserOptions $parserOptions,
int $oldid,
OutputPage $outputPage,
array $textOptions
Function setOldSubtitle
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setOldSubtitle( $oldid = 0 ) {
if ( !$this->getHookRunner()->onDisplayOldSubtitle( $this, $oldid ) ) {
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 formatRobotPolicy
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function formatRobotPolicy( $policy ) {
if ( is_array( $policy ) ) {
return $policy;
} elseif ( !$policy ) {
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
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 $this->mRevisionRecord;
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;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false; // skip all further output to OutputPage
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return $policy;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Function showDiffPage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function showDiffPage() {
$context = $this->getContext();
$outputPage = $context->getOutput();
$outputPage->addBodyClasses( 'mw-article-diff' );
$request = $context->getRequest();
- 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 tryFileCache
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function tryFileCache() {
static $called = false;
if ( $called ) {
wfDebug( "Article::tryFileCache(): called twice!?" );
- 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"