File ApiPageSet.php
has 958 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Copyright © 2006, 2013 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
*
* This program is free software; you can redistribute it and/or modify
ApiPageSet
has 65 functions (exceeds 20 allowed). Consider refactoring. Open
class ApiPageSet extends ApiBase {
/**
* Constructor flag: The new instance of ApiPageSet will ignore the 'generator=' parameter
* @since 1.21
*/
Function populateGeneratorData
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
public function populateGeneratorData( &$result, array $path = [] ) {
if ( $result instanceof ApiResult ) {
$data = $result->getResultData( $path );
if ( $data === null ) {
return true;
- 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 processTitlesArray
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
private function processTitlesArray( $titles ) {
$linkBatch = $this->linkBatchFactory->newLinkBatch();
/** @var Title[] $titleObjects */
$titleObjects = [];
- 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 executeInternal
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
private function executeInternal( $isDryRun ) {
$generatorName = $this->mAllowGenerator ? $this->mParams['generator'] : null;
if ( isset( $generatorName ) ) {
$dbSource = $this->mDbSource;
if ( !$dbSource instanceof ApiQuery ) {
- 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 initFromQueryResult
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
private function initFromQueryResult( $res, &$remaining = null, $processTitles = null ) {
if ( $remaining !== null && $processTitles === null ) {
ApiBase::dieDebug( __METHOD__, 'Missing $processTitles parameter when $remaining is provided' );
}
- 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 executeInternal
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function executeInternal( $isDryRun ) {
$generatorName = $this->mAllowGenerator ? $this->mParams['generator'] : null;
if ( isset( $generatorName ) ) {
$dbSource = $this->mDbSource;
if ( !$dbSource instanceof ApiQuery ) {
Method processTitlesArray
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processTitlesArray( $titles ) {
$linkBatch = $this->linkBatchFactory->newLinkBatch();
/** @var Title[] $titleObjects */
$titleObjects = [];
Method populateGeneratorData
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function populateGeneratorData( &$result, array $path = [] ) {
if ( $result instanceof ApiResult ) {
$data = $result->getResultData( $path );
if ( $data === null ) {
return true;
Method initFromRevIDs
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function initFromRevIDs( $revids ) {
if ( !$revids ) {
return;
}
Function getInvalidTitlesAndRevisions
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function getInvalidTitlesAndRevisions( $invalidChecks = [ 'invalidTitles',
'special', 'missingIds', 'missingRevIds', 'missingTitles', 'interwikiTitles' ]
) {
$result = [];
if ( in_array( 'invalidTitles', $invalidChecks ) ) {
- 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 initFromRevIDs
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private function initFromRevIDs( $revids ) {
if ( !$revids ) {
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 loadRedirectTargets
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function loadRedirectTargets() {
$titlesToResolve = [];
$db = $this->getDB();
if ( $this->mPendingRedirectIDs ) {
Function loadRedirectTargets
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function loadRedirectTargets() {
$titlesToResolve = [];
$db = $this->getDB();
if ( $this->mPendingRedirectIDs ) {
- 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 initFromQueryResult
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function initFromQueryResult( $res, &$remaining = null, $processTitles = null ) {
if ( $remaining !== null && $processTitles === null ) {
ApiBase::dieDebug( __METHOD__, 'Missing $processTitles parameter when $remaining is provided' );
}
Method getAllowedParams
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAllowedParams( $flags = 0 ) {
$result = [
'titles' => [
ParamValidator::PARAM_ISMULTI => true,
ApiBase::PARAM_HELP_MSG => 'api-pageset-param-titles',
Method getInvalidTitlesAndRevisions
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getInvalidTitlesAndRevisions( $invalidChecks = [ 'invalidTitles',
'special', 'missingIds', 'missingRevIds', 'missingTitles', 'interwikiTitles' ]
) {
$result = [];
if ( in_array( 'invalidTitles', $invalidChecks ) ) {
Function getRedirectTitlesAsResult
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function getRedirectTitlesAsResult( $result = null ) {
$values = [];
foreach ( $this->getRedirectTitles() as $titleStrFrom => $titleTo ) {
$r = [
'from' => strval( $titleStrFrom ),
- 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 resolvePendingRedirects
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function resolvePendingRedirects() {
if ( $this->mResolveRedirects ) {
$db = $this->getDB();
// Repeat until all redirects have been resolved
- 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 getRedirectTitlesAsResult
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getRedirectTitlesAsResult( $result = null ) {
$values = [];
foreach ( $this->getRedirectTitles() as $titleStrFrom => $titleTo ) {
$r = [
'from' => strval( $titleStrFrom ),
Function getGenerators
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function getGenerators() {
if ( self::$generators === null ) {
$query = $this->mDbSource;
if ( !( $query instanceof ApiQuery ) ) {
// If the parent container of this pageset is not ApiQuery,
- 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 addValues
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function addValues( array &$result, $values, $flags = [], $name = null ) {
foreach ( $values as $val ) {
if ( $val instanceof Title ) {
$v = [];
ApiQueryBase::addTitleInfo( $v, $val );
- 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 null;
Function handleParamNormalization
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function handleParamNormalization( $paramName, $value, $rawValue ) {
parent::handleParamNormalization( $paramName, $value, $rawValue );
if ( $paramName === 'titles' ) {
// For the 'titles' parameter, we want to split it like ApiBase would
- 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"