wikimedia/mediawiki-core

View on GitHub
includes/libs/rdbms/lbfactory/LBFactory.php

Summary

Maintainability
D
2 days
Test Coverage

File LBFactory.php has 477 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
Severity: Minor
Found in includes/libs/rdbms/lbfactory/LBFactory.php - About 7 hrs to fix

    LBFactory has 42 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class LBFactory implements ILBFactory {
        /** @var CriticalSectionProvider|null */
        private $csProvider;
        /**
         * @var callable|null An optional callback that returns a ScopedCallback instance,
    Severity: Minor
    Found in includes/libs/rdbms/lbfactory/LBFactory.php - About 5 hrs to fix

      Function waitForReplication has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function waitForReplication( array $opts = [] ) {
              $opts += [
                  'timeout' => $this->replicationWaitTimeout,
                  'ifWritesSince' => null
              ];
      Severity: Minor
      Found in includes/libs/rdbms/lbfactory/LBFactory.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

      Method waitForReplication has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function waitForReplication( array $opts = [] ) {
              $opts += [
                  'timeout' => $this->replicationWaitTimeout,
                  'ifWritesSince' => null
              ];
      Severity: Minor
      Found in includes/libs/rdbms/lbfactory/LBFactory.php - About 1 hr to fix

        Method configure has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function configure( array $conf ): void {
                $this->localDomain = isset( $conf['localDomain'] )
                    ? DatabaseDomain::newFromId( $conf['localDomain'] )
                    : DatabaseDomain::newUnspecified();
        
        
        Severity: Minor
        Found in includes/libs/rdbms/lbfactory/LBFactory.php - About 1 hr to fix

          Method commitPrimaryChanges has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              final public function commitPrimaryChanges( $fname = __METHOD__, int $maxWriteDuration = 0 ) {
                  $this->assertTransactionRoundStage( self::ROUND_CURSORY );
                  /** @noinspection PhpUnusedLocalVariableInspection */
                  $scope = ScopedCallback::newScopedIgnoreUserAbort();
          
          
          Severity: Minor
          Found in includes/libs/rdbms/lbfactory/LBFactory.php - About 1 hr to fix

            Function getMappedDatabase has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                private function getMappedDatabase( $index, $groups, $domain ) {
                    if ( $domain !== false && in_array( $domain, $this->virtualDomains ) ) {
                        if ( isset( $this->virtualDomainsMapping[$domain] ) ) {
                            $config = $this->virtualDomainsMapping[$domain];
                            if ( isset( $config['cluster'] ) ) {
            Severity: Minor
            Found in includes/libs/rdbms/lbfactory/LBFactory.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

            Function commitPrimaryChanges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                final public function commitPrimaryChanges( $fname = __METHOD__, int $maxWriteDuration = 0 ) {
                    $this->assertTransactionRoundStage( self::ROUND_CURSORY );
                    /** @noinspection PhpUnusedLocalVariableInspection */
                    $scope = ScopedCallback::newScopedIgnoreUserAbort();
            
            
            Severity: Minor
            Found in includes/libs/rdbms/lbfactory/LBFactory.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

            Function shutdown has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function shutdown(
                    $flags = self::SHUTDOWN_NORMAL,
                    callable $workCallback = null,
                    &$cpIndex = null,
                    &$cpClientId = null
            Severity: Minor
            Found in includes/libs/rdbms/lbfactory/LBFactory.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

            Function logIfMultiDbTransaction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private function logIfMultiDbTransaction() {
                    $callersByDB = [];
                    foreach ( $this->getLBsForOwner() as $lb ) {
                        $primaryName = $lb->getServerName( $lb->getWriterIndex() );
                        $callers = $lb->pendingPrimaryChangeCallers();
            Severity: Minor
            Found in includes/libs/rdbms/lbfactory/LBFactory.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