Function getDiffRevision
has a Cognitive Complexity of 97 (exceeds 5 allowed). Consider refactoring. Open
private function getDiffRevision( $prefix, array $params ) {
// Back compat params
$this->requireMaxOneParameter( $params, "{$prefix}text", "{$prefix}slots" );
$this->requireMaxOneParameter( $params, "{$prefix}section", "{$prefix}slots" );
if ( $params["{$prefix}text"] !== 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
File ApiComparePages.php
has 618 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 execute
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
$params = $this->extractRequestParams();
// Parameter validation
$this->requireAtLeastOneParameter(
- 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 getDiffRevision
has 178 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getDiffRevision( $prefix, array $params ) {
// Back compat params
$this->requireMaxOneParameter( $params, "{$prefix}text", "{$prefix}slots" );
$this->requireMaxOneParameter( $params, "{$prefix}section", "{$prefix}slots" );
if ( $params["{$prefix}text"] !== null ) {
Function setVals
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
private function setVals( &$vals, $prefix, $rev ) {
if ( $rev ) {
$title = Title::newFromLinkTarget( $rev->getPageAsLinkTarget() );
if ( isset( $this->props['ids'] ) ) {
$vals["{$prefix}id"] = $title->getArticleID();
- 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 execute
has 141 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
$params = $this->extractRequestParams();
// Parameter validation
$this->requireAtLeastOneParameter(
Method getAllowedParams
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAllowedParams() {
$slotRoles = $this->slotRoleRegistry->getKnownRoles();
sort( $slotRoles, SORT_STRING );
// Parameters for the 'from' and 'to' content
Function guessTitle
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
private function guessTitle() {
if ( $this->guessedTitle !== false ) {
return $this->guessedTitle;
}
- 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 setVals
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function setVals( &$vals, $prefix, $rev ) {
if ( $rev ) {
$title = Title::newFromLinkTarget( $rev->getPageAsLinkTarget() );
if ( isset( $this->props['ids'] ) ) {
$vals["{$prefix}id"] = $title->getArticleID();
Function guessModel
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function guessModel( $role ) {
$params = $this->extractRequestParams();
foreach ( [ 'from', 'to' ] as $prefix ) {
if ( $params["{$prefix}rev"] !== 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 __construct
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
ApiMain $mainModule,
$moduleName,
RevisionStore $revisionStore,
ArchivedRevisionLookup $archivedRevisionLookup,
SlotRoleRegistry $slotRoleRegistry,
Method guessTitle
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function guessTitle() {
if ( $this->guessedTitle !== false ) {
return $this->guessedTitle;
}
Method guessModel
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function guessModel( $role ) {
$params = $this->extractRequestParams();
foreach ( [ 'from', 'to' ] as $prefix ) {
if ( $params["{$prefix}rev"] !== null ) {
Avoid too many return
statements within this method. Open
return $params['tocontentmodel'];
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return $params['fromcontentmodel'];
Function getAllowedParams
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getAllowedParams() {
$slotRoles = $this->slotRoleRegistry->getKnownRoles();
sort( $slotRoles, SORT_STRING );
// Parameters for the 'from' and 'to' content
- 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"