wikimedia/mediawiki-core

View on GitHub
includes/libs/rdbms/TransactionProfiler.php

Summary

Maintainability
D
2 days
Test Coverage

File TransactionProfiler.php has 318 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/TransactionProfiler.php - About 3 hrs to fix

    Function recordQueryCompletion has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        public function recordQueryCompletion(
            $query,
            float $sTime,
            bool $isWrite,
            ?int $rowCount,
    Severity: Minor
    Found in includes/libs/rdbms/TransactionProfiler.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

    TransactionProfiler has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class TransactionProfiler implements LoggerAwareInterface {
        /** @var LoggerInterface */
        private $logger;
        /** @var StatsFactory */
        private $statsFactory;
    Severity: Minor
    Found in includes/libs/rdbms/TransactionProfiler.php - About 2 hrs to fix

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

          public function transactionWritingOut(
              $server,
              $db,
              string $id,
              float $writeTime,
      Severity: Major
      Found in includes/libs/rdbms/TransactionProfiler.php - About 2 hrs to fix

        Method recordQueryCompletion has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function recordQueryCompletion(
                $query,
                float $sTime,
                bool $isWrite,
                ?int $rowCount,
        Severity: Minor
        Found in includes/libs/rdbms/TransactionProfiler.php - About 1 hr to fix

          Function transactionWritingOut has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function transactionWritingOut(
                  $server,
                  $db,
                  string $id,
                  float $writeTime,
          Severity: Minor
          Found in includes/libs/rdbms/TransactionProfiler.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 reportExpectationViolated has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function reportExpectationViolated(
                  $event,
                  $query,
                  $actual,
                  ?string $trxId = null,
          Severity: Minor
          Found in includes/libs/rdbms/TransactionProfiler.php - About 1 hr to fix

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

                public function silenceForScope( string $type = self::EXPECTATION_ANY ) {
                    if ( $type === self::EXPECTATION_REPLICAS_ONLY ) {
                        $events = [];
                        foreach ( [ 'writes', 'masterConns' ] as $event ) {
                            if ( $this->expect[$event][self::FLD_LIMIT] === 0 ) {
            Severity: Minor
            Found in includes/libs/rdbms/TransactionProfiler.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 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    $query,
                    float $sTime,
                    bool $isWrite,
                    ?int $rowCount,
                    string $trxId,
            Severity: Minor
            Found in includes/libs/rdbms/TransactionProfiler.php - About 45 mins to fix

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

                      $event,
                      $query,
                      $actual,
                      ?string $trxId = null,
                      ?string $serverName = null
              Severity: Minor
              Found in includes/libs/rdbms/TransactionProfiler.php - About 35 mins to fix

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

                        $server,
                        $db,
                        string $id,
                        float $writeTime,
                        int $affected
                Severity: Minor
                Found in includes/libs/rdbms/TransactionProfiler.php - About 35 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status