Function getConnection
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function getConnection( $server, LoggerInterface $logger = null ) {
// The above @return also documents 'Redis' for convenience with IDEs.
// RedisConnRef uses PHP magic methods, which wouldn't be recognised.
$logger = $logger ?: $this->logger;
- 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 getConnection
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getConnection( $server, LoggerInterface $logger = null ) {
// The above @return also documents 'Redis' for convenience with IDEs.
// RedisConnRef uses PHP magic methods, which wouldn't be recognised.
$logger = $logger ?: $this->logger;
Function closeExcessIdleConections
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function closeExcessIdleConections() {
if ( $this->idlePoolSize <= count( $this->connections ) ) {
return; // nothing to do (no more connections than servers)
}
- 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 __construct
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function __construct( array $options, $id ) {
if ( !class_exists( Redis::class ) ) {
throw new RuntimeException(
__CLASS__ . ' requires a Redis client library. ' .
'See https://www.mediawiki.org/wiki/Redis#Setup' );
- 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 new RedisConnRef( $this, $server, $conn, $logger );
Function __destruct
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function __destruct() {
foreach ( $this->connections as &$serverConnections ) {
foreach ( $serverConnections as &$connection ) {
try {
/** @var Redis $conn */
- 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"