File Database.php
has 2205 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
Database
has 206 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAwareInterface {
/** @var CriticalSectionProvider|null */
protected $csProvider;
/** @var LoggerInterface */
protected $logger;
Function sourceStream
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public function sourceStream(
$fp,
callable $lineCallback = null,
callable $resultCallback = null,
$fname = __METHOD__,
- 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 assessConnectionLoss
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
private function assessConnectionLoss(
string $verb,
float $walltime,
CriticalSessionInfo $priorSessInfo
) {
- 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 attemptQuery
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function attemptQuery(
$sql,
string $fname,
bool $isPermWrite
) {
Method upsert
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function upsert( $table, array $rows, $uniqueKeys, array $set, $fname = __METHOD__ ) {
$uniqueKey = $this->platform->normalizeUpsertParams( $uniqueKeys, $rows );
if ( !$rows ) {
return true;
}
Function executeQuery
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
final protected function executeQuery( $sql, $fname, $flags ) {
$this->assertHasConnectionHandle();
$isPermWrite = false;
$isWrite = $sql->isWriteQuery();
- 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 cancelAtomic
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
final public function cancelAtomic(
$fname = __METHOD__,
AtomicSectionIdentifier $sectionId = null
) {
$this->transactionManager->onCancelAtomicBeforeCriticalSection( $this, $fname );
Method __construct
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( array $params ) {
$this->logger = $params['logger'] ?? new NullLogger();
$this->transactionManager = new TransactionManager(
$this->logger,
$params['trxProfiler']
Method assessConnectionLoss
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function assessConnectionLoss(
string $verb,
float $walltime,
CriticalSessionInfo $priorSessInfo
) {
Function startAtomic
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
final public function startAtomic(
$fname = __METHOD__,
$cancelable = self::ATOMIC_NOT_CANCELABLE
) {
$cs = $this->commenceCriticalSection( __METHOD__ );
- 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 sourceStream
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sourceStream(
$fp,
callable $lineCallback = null,
callable $resultCallback = null,
$fname = __METHOD__,
Function handleErroredQuery
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function handleErroredQuery( QueryStatus $status, $sql, $fname, $queryRuntime, $priorSessInfo ) {
$errflags = self::ERR_NONE;
$error = $status->message;
$errno = $status->code;
if ( $status->res !== false ) {
- 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 rollback
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
final public function rollback( $fname = __METHOD__, $flush = self::FLUSHING_ONE ) {
if (
$flush !== self::FLUSHING_INTERNAL &&
$flush !== self::FLUSHING_ALL_PEERS &&
$this->flagsHolder->hasImplicitTrxFlag()
Method executeQuery
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
final protected function executeQuery( $sql, $fname, $flags ) {
$this->assertHasConnectionHandle();
$isPermWrite = false;
$isWrite = $sql->isWriteQuery();
Method handleErroredQuery
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function handleErroredQuery( QueryStatus $status, $sql, $fname, $queryRuntime, $priorSessInfo ) {
$errflags = self::ERR_NONE;
$error = $status->message;
$errno = $status->code;
if ( $status->res !== false ) {
Method replaceLostConnection
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function replaceLostConnection( $lastErrno, $fname ) {
if ( $this->conn ) {
$this->closeConnection();
$this->conn = null;
$this->handleSessionLossPreconnect();
Method startAtomic
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
final public function startAtomic(
$fname = __METHOD__,
$cancelable = self::ATOMIC_NOT_CANCELABLE
) {
$cs = $this->commenceCriticalSection( __METHOD__ );
Method doInsertSelectGeneric
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function doInsertSelectGeneric(
$destTable,
$srcTable,
array $varMap,
$conds,
Method flushSession
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function flushSession( $fname = __METHOD__, $flush = self::FLUSHING_ONE ) {
if (
$flush !== self::FLUSHING_INTERNAL &&
$flush !== self::FLUSHING_ALL_PEERS &&
$this->flagsHolder->hasImplicitTrxFlag()
Function runOnTransactionIdleCallbacks
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function runOnTransactionIdleCallbacks( $trigger, array &$errors = [] ) {
if ( $this->trxLevel() ) {
throw new DBUnexpectedError( $this, __METHOD__ . ': a transaction is still open' );
}
- 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 runOnTransactionIdleCallbacks
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function runOnTransactionIdleCallbacks( $trigger, array &$errors = [] ) {
if ( $this->trxLevel() ) {
throw new DBUnexpectedError( $this, __METHOD__ . ': a transaction is still open' );
}
Method selectRowCount
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function selectRowCount(
$tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
) {
$conds = $this->platform->normalizeConditions( $conds, $fname );
$column = $this->platform->extractSingleFieldFromList( $var );
Function upsert
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function upsert( $table, array $rows, $uniqueKeys, array $set, $fname = __METHOD__ ) {
$uniqueKey = $this->platform->normalizeUpsertParams( $uniqueKeys, $rows );
if ( !$rows ) {
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
Method commit
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
final public function commit( $fname = __METHOD__, $flush = self::FLUSHING_ONE ) {
static $modes = [ self::FLUSHING_ONE, self::FLUSHING_ALL_PEERS, self::FLUSHING_INTERNAL ];
if ( !in_array( $flush, $modes, true ) ) {
throw new DBUnexpectedError( $this, "$fname: invalid flush parameter '$flush'" );
}
Method commenceCriticalSection
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function commenceCriticalSection( string $fname ) {
if ( $this->csmError ) {
throw new DBUnexpectedError(
$this,
"Cannot execute $fname critical section while session state is out of sync.\n\n" .
Method insertSelect
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
final public function insertSelect(
$destTable,
$srcTable,
$varMap,
$conds,
Method replace
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function replace( $table, $uniqueKeys, $rows, $fname = __METHOD__ ) {
$uniqueKey = $this->platform->normalizeUpsertParams( $uniqueKeys, $rows );
if ( !$rows ) {
return;
}
Method doInsertSelectGeneric
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
$destTable,
$srcTable,
array $varMap,
$conds,
$fname,
Method insertSelect
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
$destTable,
$srcTable,
$varMap,
$conds,
$fname = __METHOD__,
Method doInsertSelectNative
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
$destTable,
$srcTable,
array $varMap,
$conds,
$fname,
Function attemptQuery
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function attemptQuery(
$sql,
string $fname,
bool $isPermWrite
) {
- 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 cancelAtomic
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
final public function cancelAtomic(
$fname = __METHOD__,
AtomicSectionIdentifier $sectionId = null
) {
$this->transactionManager->onCancelAtomicBeforeCriticalSection( $this, $fname );
- 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 onTransactionPreCommitOrIdle
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
final public function onTransactionPreCommitOrIdle( callable $callback, $fname = __METHOD__ ) {
if ( !$this->trxLevel() && $this->getTransactionRoundId() ) {
// This DB handle is set to participate in LoadBalancer transaction rounds and
// an explicit transaction round is active. Start an implicit transaction on this
// DB handle (setting trxAutomatic) similar to how query() does in such situations.
- 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 getCacheSetOptions
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function getCacheSetOptions( ?IReadableDatabase ...$dbs ) {
$res = [ 'lag' => 0, 'since' => INF, 'pending' => false ];
foreach ( func_get_args() as $db ) {
if ( $db instanceof IReadableDatabase ) {
- 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 selectRowCount
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
Method select
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$table, $vars, $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
Method open
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
abstract protected function open( $server, $user, $password, $db, $schema, $tablePrefix );
Method selectSQLText
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$table, $vars, $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
Function close
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
final public function close( $fname = __METHOD__ ) {
$error = null; // error to throw after disconnecting
$wasOpen = (bool)$this->conn;
// This should mostly do nothing if the connection is already closed
- 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 rollback
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
final public function rollback( $fname = __METHOD__, $flush = self::FLUSHING_ONE ) {
if (
$flush !== self::FLUSHING_INTERNAL &&
$flush !== self::FLUSHING_ALL_PEERS &&
$this->flagsHolder->hasImplicitTrxFlag()
- 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 buildSelectSubquery
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$table, $vars, $conds = '', $fname = __METHOD__,
$options = [], $join_conds = []
Method selectFieldValues
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
Method selectField
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
Method selectRow
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function selectRow( $table, $vars, $conds, $fname = __METHOD__,
$options = [], $join_conds = []
Method estimateRowCount
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
Method deleteJoin
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$delTable,
$joinTable,
$delVar,
$joinVar,
$conds,
Function doInsertSelectGeneric
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function doInsertSelectGeneric(
$destTable,
$srcTable,
array $varMap,
$conds,
- 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 upsert
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function upsert( $table, array $rows, $uniqueKeys, array $set, $fname = __METHOD__ ) {
Method sourceFile
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$filename,
callable $lineCallback = null,
callable $resultCallback = null,
$fname = false,
callable $inputCallback = null
Method handleErroredQuery
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function handleErroredQuery( QueryStatus $status, $sql, $fname, $queryRuntime, $priorSessInfo ) {
Method update
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function update( $table, $set, $conds, $fname = __METHOD__, $options = [] ) {
Method reportQueryError
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function reportQueryError( $error, $errno, $sql, $fname, $ignore = false ) {
Method lockForUpdate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$table, $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
Method buildGroupConcatField
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$delim, $table, $field, $conds = '', $join_conds = []
Method sourceStream
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$fp,
callable $lineCallback = null,
callable $resultCallback = null,
$fname = __METHOD__,
callable $inputCallback = null
Avoid too many return
statements within this method. Open
return "'" . $this->strencode( $s ) . "'";
Function selectRowCount
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function selectRowCount(
$tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
) {
$conds = $this->platform->normalizeConditions( $conds, $fname );
$column = $this->platform->extractSingleFieldFromList( $var );
- 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 commit
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
final public function commit( $fname = __METHOD__, $flush = self::FLUSHING_ONE ) {
static $modes = [ self::FLUSHING_ONE, self::FLUSHING_ALL_PEERS, self::FLUSHING_INTERNAL ];
if ( !in_array( $flush, $modes, true ) ) {
throw new DBUnexpectedError( $this, "$fname: invalid flush parameter '$flush'" );
}
- 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 addQuotes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function addQuotes( $s ) {
if ( $s instanceof Blob ) {
$s = $s->fetch();
}
if ( $s instanceof IExpression ) {
- 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 setLBInfo
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function setLBInfo( $nameOrArray, $value = null ) {
if ( is_array( $nameOrArray ) ) {
$this->lbInfo = $nameOrArray;
} elseif ( is_string( $nameOrArray ) ) {
if ( $value !== 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 flushSession
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function flushSession( $fname = __METHOD__, $flush = self::FLUSHING_ONE ) {
if (
$flush !== self::FLUSHING_INTERNAL &&
$flush !== self::FLUSHING_ALL_PEERS &&
$this->flagsHolder->hasImplicitTrxFlag()
- 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"