wikimedia/mediawiki-core

View on GitHub
includes/libs/redis/RedisConnectionPool.php

Summary

Maintainability
C
1 day
Test Coverage

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;
Severity: Minor
Found in includes/libs/redis/RedisConnectionPool.php - About 3 hrs to fix

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;
Severity: Major
Found in includes/libs/redis/RedisConnectionPool.php - About 3 hrs to fix

    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)
            }
    
    
    Severity: Minor
    Found in includes/libs/redis/RedisConnectionPool.php - About 1 hr to fix

    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' );
    Severity: Minor
    Found in includes/libs/redis/RedisConnectionPool.php - About 45 mins to fix

    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 );
    Severity: Major
    Found in includes/libs/redis/RedisConnectionPool.php - About 30 mins to fix

      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 */
      Severity: Minor
      Found in includes/libs/redis/RedisConnectionPool.php - About 25 mins to fix

      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

      There are no issues that match your filters.

      Category
      Status