wikimedia/mediawiki-core

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

Summary

Maintainability
F
3 days
Test Coverage

File TransactionManager.php has 644 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/TransactionManager.php - About 1 day to fix

    TransactionManager has 66 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class TransactionManager {
        /** @var int Transaction is in a error state requiring a full or savepoint rollback */
        public const STATUS_TRX_ERROR = 1;
        /** @var int Transaction is active and in a normal state */
        public const STATUS_TRX_OK = 2;
    Severity: Major
    Found in includes/libs/rdbms/database/TransactionManager.php - About 1 day to fix

      Function reassignCallbacksForSection has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function reassignCallbacksForSection(
              AtomicSectionIdentifier $old,
              AtomicSectionIdentifier $new
          ) {
              foreach ( $this->trxPreCommitOrIdleCallbacks as $key => $info ) {
      Severity: Minor
      Found in includes/libs/rdbms/database/TransactionManager.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 onCommit has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function onCommit( IDatabase $db, $fname, $flush ): bool {
              if ( $this->trxLevel() && $this->trxAtomicLevels ) {
                  // There are still atomic sections open; this cannot be ignored
                  $levels = $this->flatAtomicSectionList();
                  throw new DBUnexpectedError(
      Severity: Minor
      Found in includes/libs/rdbms/database/TransactionManager.php - About 1 hr to fix

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

            public function onFlushSnapshot( IDatabase $db, $fname, $flush, $trxRoundId ) {
                if ( $this->explicitTrxActive() ) {
                    // Committing this transaction would break callers that assume it is still open
                    throw new DBUnexpectedError(
                        $db,
        Severity: Minor
        Found in includes/libs/rdbms/database/TransactionManager.php - About 1 hr to fix

          Method modifyCallbacksForCancel has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function modifyCallbacksForCancel(
                  IDatabase $db,
                  array $sectionIds,
                  AtomicSectionIdentifier $newSectionId = null
              ) {
          Severity: Minor
          Found in includes/libs/rdbms/database/TransactionManager.php - About 1 hr to fix

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

                public function onCommit( IDatabase $db, $fname, $flush ): bool {
                    if ( $this->trxLevel() && $this->trxAtomicLevels ) {
                        // There are still atomic sections open; this cannot be ignored
                        $levels = $this->flatAtomicSectionList();
                        throw new DBUnexpectedError(
            Severity: Minor
            Found in includes/libs/rdbms/database/TransactionManager.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 recordQueryCompletion has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function recordQueryCompletion( $sql, $startTime, $isPermWrite, $rowCount, $serverName ) {
            Severity: Minor
            Found in includes/libs/rdbms/database/TransactionManager.php - About 35 mins to fix

              Function trxCheckBeforeClose has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function trxCheckBeforeClose( IDatabase $db, $fname ) {
                      $error = null;
                      if ( $this->trxAtomicLevels ) {
                          // Cannot let incomplete atomic sections be committed
                          $levels = $this->flatAtomicSectionList();
              Severity: Minor
              Found in includes/libs/rdbms/database/TransactionManager.php - About 35 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 getPositionFromSectionId has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getPositionFromSectionId( AtomicSectionIdentifier $sectionId = null ): ?int {
                      if ( $sectionId !== null ) {
                          // Find the (last) section with the given $sectionId
                          $pos = -1;
                          foreach ( $this->trxAtomicLevels as $i => [ , $asId, ] ) {
              Severity: Minor
              Found in includes/libs/rdbms/database/TransactionManager.php - About 35 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 runOnAtomicSectionCancelCallbacks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function runOnAtomicSectionCancelCallbacks( IDatabase $db, int $trigger, array $sectionIds ) {
                      // Drain the queue of matching "atomic section cancel" callbacks until there are none
                      $unrelatedCallbackEntries = [];
                      do {
                          $callbackEntries = $this->trxSectionCancelCallbacks;
              Severity: Minor
              Found in includes/libs/rdbms/database/TransactionManager.php - About 35 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 modifyCallbacksForCancel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function modifyCallbacksForCancel(
                      IDatabase $db,
                      array $sectionIds,
                      AtomicSectionIdentifier $newSectionId = null
                  ) {
              Severity: Minor
              Found in includes/libs/rdbms/database/TransactionManager.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