wikimedia/mediawiki-core

View on GitHub
includes/libs/rdbms/database/Database.php

Summary

Maintainability
F
2 wks
Test Coverage

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
Severity: Major
Found in includes/libs/rdbms/database/Database.php - About 6 days to fix

    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;
    Severity: Major
    Found in includes/libs/rdbms/database/Database.php - About 4 days to fix

      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__,
      Severity: Minor
      Found in includes/libs/rdbms/database/Database.php - About 4 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

      Function assessConnectionLoss has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          private function assessConnectionLoss(
              string $verb,
              float $walltime,
              CriticalSessionInfo $priorSessInfo
          ) {
      Severity: Minor
      Found in includes/libs/rdbms/database/Database.php - About 2 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 attemptQuery has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function attemptQuery(
              $sql,
              string $fname,
              bool $isPermWrite
          ) {
      Severity: Major
      Found in includes/libs/rdbms/database/Database.php - About 2 hrs to fix

        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;
                }
        Severity: Major
        Found in includes/libs/rdbms/database/Database.php - About 2 hrs to fix

          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();
          Severity: Minor
          Found in includes/libs/rdbms/database/Database.php - About 2 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 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 );
          Severity: Major
          Found in includes/libs/rdbms/database/Database.php - About 2 hrs to fix

            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']
            Severity: Major
            Found in includes/libs/rdbms/database/Database.php - About 2 hrs to fix

              Method assessConnectionLoss has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function assessConnectionLoss(
                      string $verb,
                      float $walltime,
                      CriticalSessionInfo $priorSessInfo
                  ) {
              Severity: Major
              Found in includes/libs/rdbms/database/Database.php - About 2 hrs to fix

                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__ );
                Severity: Minor
                Found in includes/libs/rdbms/database/Database.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 sourceStream has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function sourceStream(
                        $fp,
                        callable $lineCallback = null,
                        callable $resultCallback = null,
                        $fname = __METHOD__,
                Severity: Minor
                Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                  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 ) {
                  Severity: Minor
                  Found in includes/libs/rdbms/database/Database.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 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()
                  Severity: Minor
                  Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                    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();
                    Severity: Minor
                    Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                      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 ) {
                      Severity: Minor
                      Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                        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();
                        Severity: Minor
                        Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                          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__ );
                          Severity: Minor
                          Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                            Method doInsertSelectGeneric has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private function doInsertSelectGeneric(
                                    $destTable,
                                    $srcTable,
                                    array $varMap,
                                    $conds,
                            Severity: Minor
                            Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                              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()
                              Severity: Minor
                              Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                                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' );
                                        }
                                
                                
                                Severity: Minor
                                Found in includes/libs/rdbms/database/Database.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 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' );
                                        }
                                
                                
                                Severity: Minor
                                Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                                  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 );
                                  Severity: Minor
                                  Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                                    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;
                                            }
                                    Severity: Minor
                                    Found in includes/libs/rdbms/database/Database.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 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'" );
                                            }
                                    Severity: Minor
                                    Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                                      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" .
                                      Severity: Minor
                                      Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

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

                                            final public function insertSelect(
                                                $destTable,
                                                $srcTable,
                                                $varMap,
                                                $conds,
                                        Severity: Minor
                                        Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                                          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;
                                                  }
                                          Severity: Minor
                                          Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                                            Method doInsertSelectGeneric has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                                    $destTable,
                                                    $srcTable,
                                                    array $varMap,
                                                    $conds,
                                                    $fname,
                                            Severity: Major
                                            Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                                              Method insertSelect has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                              Open

                                                      $destTable,
                                                      $srcTable,
                                                      $varMap,
                                                      $conds,
                                                      $fname = __METHOD__,
                                              Severity: Major
                                              Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                                                Method doInsertSelectNative has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                                Open

                                                        $destTable,
                                                        $srcTable,
                                                        array $varMap,
                                                        $conds,
                                                        $fname,
                                                Severity: Major
                                                Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                                                  Function attemptQuery has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      private function attemptQuery(
                                                          $sql,
                                                          string $fname,
                                                          bool $isPermWrite
                                                      ) {
                                                  Severity: Minor
                                                  Found in includes/libs/rdbms/database/Database.php - About 55 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 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 );
                                                  Severity: Minor
                                                  Found in includes/libs/rdbms/database/Database.php - About 55 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 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.
                                                  Severity: Minor
                                                  Found in includes/libs/rdbms/database/Database.php - About 55 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 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 ) {
                                                  Severity: Minor
                                                  Found in includes/libs/rdbms/database/Database.php - About 55 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

                                                  Method selectRowCount has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                  Open

                                                          $tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
                                                  Severity: Minor
                                                  Found in includes/libs/rdbms/database/Database.php - About 45 mins to fix

                                                    Method select has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                    Open

                                                            $table, $vars, $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
                                                    Severity: Minor
                                                    Found in includes/libs/rdbms/database/Database.php - About 45 mins to fix

                                                      Method open has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                      Open

                                                          abstract protected function open( $server, $user, $password, $db, $schema, $tablePrefix );
                                                      Severity: Minor
                                                      Found in includes/libs/rdbms/database/Database.php - About 45 mins to fix

                                                        Method selectSQLText has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                        Open

                                                                $table, $vars, $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
                                                        Severity: Minor
                                                        Found in includes/libs/rdbms/database/Database.php - About 45 mins to fix

                                                          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
                                                          Severity: Minor
                                                          Found in includes/libs/rdbms/database/Database.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 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()
                                                          Severity: Minor
                                                          Found in includes/libs/rdbms/database/Database.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

                                                          Method buildSelectSubquery has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                          Open

                                                                  $table, $vars, $conds = '', $fname = __METHOD__,
                                                                  $options = [], $join_conds = []
                                                          Severity: Minor
                                                          Found in includes/libs/rdbms/database/Database.php - About 45 mins to fix

                                                            Method selectFieldValues has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                            Open

                                                                    $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
                                                            Severity: Minor
                                                            Found in includes/libs/rdbms/database/Database.php - About 45 mins to fix

                                                              Method selectField has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                              Open

                                                                      $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
                                                              Severity: Minor
                                                              Found in includes/libs/rdbms/database/Database.php - About 45 mins to fix

                                                                Method selectRow has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                                Open

                                                                    public function selectRow( $table, $vars, $conds, $fname = __METHOD__,
                                                                        $options = [], $join_conds = []
                                                                Severity: Minor
                                                                Found in includes/libs/rdbms/database/Database.php - About 45 mins to fix

                                                                  Method estimateRowCount has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                                  Open

                                                                          $tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
                                                                  Severity: Minor
                                                                  Found in includes/libs/rdbms/database/Database.php - About 45 mins to fix

                                                                    Method deleteJoin has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                                    Open

                                                                            $delTable,
                                                                            $joinTable,
                                                                            $delVar,
                                                                            $joinVar,
                                                                            $conds,
                                                                    Severity: Minor
                                                                    Found in includes/libs/rdbms/database/Database.php - About 45 mins to fix

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

                                                                          private function doInsertSelectGeneric(
                                                                              $destTable,
                                                                              $srcTable,
                                                                              array $varMap,
                                                                              $conds,
                                                                      Severity: Minor
                                                                      Found in includes/libs/rdbms/database/Database.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

                                                                      Method upsert has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                      Open

                                                                          public function upsert( $table, array $rows, $uniqueKeys, array $set, $fname = __METHOD__ ) {
                                                                      Severity: Minor
                                                                      Found in includes/libs/rdbms/database/Database.php - About 35 mins to fix

                                                                        Method sourceFile has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                        Open

                                                                                $filename,
                                                                                callable $lineCallback = null,
                                                                                callable $resultCallback = null,
                                                                                $fname = false,
                                                                                callable $inputCallback = null
                                                                        Severity: Minor
                                                                        Found in includes/libs/rdbms/database/Database.php - About 35 mins to fix

                                                                          Method handleErroredQuery has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                          Open

                                                                              private function handleErroredQuery( QueryStatus $status, $sql, $fname, $queryRuntime, $priorSessInfo ) {
                                                                          Severity: Minor
                                                                          Found in includes/libs/rdbms/database/Database.php - About 35 mins to fix

                                                                            Method update has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                            Open

                                                                                public function update( $table, $set, $conds, $fname = __METHOD__, $options = [] ) {
                                                                            Severity: Minor
                                                                            Found in includes/libs/rdbms/database/Database.php - About 35 mins to fix

                                                                              Method reportQueryError has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                              Open

                                                                                  public function reportQueryError( $error, $errno, $sql, $fname, $ignore = false ) {
                                                                              Severity: Minor
                                                                              Found in includes/libs/rdbms/database/Database.php - About 35 mins to fix

                                                                                Method lockForUpdate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                Open

                                                                                        $table, $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
                                                                                Severity: Minor
                                                                                Found in includes/libs/rdbms/database/Database.php - About 35 mins to fix

                                                                                  Method buildGroupConcatField has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                  Open

                                                                                          $delim, $table, $field, $conds = '', $join_conds = []
                                                                                  Severity: Minor
                                                                                  Found in includes/libs/rdbms/database/Database.php - About 35 mins to fix

                                                                                    Method sourceStream has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                    Open

                                                                                            $fp,
                                                                                            callable $lineCallback = null,
                                                                                            callable $resultCallback = null,
                                                                                            $fname = __METHOD__,
                                                                                            callable $inputCallback = null
                                                                                    Severity: Minor
                                                                                    Found in includes/libs/rdbms/database/Database.php - About 35 mins to fix

                                                                                      Avoid too many return statements within this method.
                                                                                      Open

                                                                                                  return "'" . $this->strencode( $s ) . "'";
                                                                                      Severity: Major
                                                                                      Found in includes/libs/rdbms/database/Database.php - About 30 mins to fix

                                                                                        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 );
                                                                                        Severity: Minor
                                                                                        Found in includes/libs/rdbms/database/Database.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 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'" );
                                                                                                }
                                                                                        Severity: Minor
                                                                                        Found in includes/libs/rdbms/database/Database.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 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 ) {
                                                                                        Severity: Minor
                                                                                        Found in includes/libs/rdbms/database/Database.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 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 ) {
                                                                                        Severity: Minor
                                                                                        Found in includes/libs/rdbms/database/Database.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 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()
                                                                                        Severity: Minor
                                                                                        Found in includes/libs/rdbms/database/Database.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