wikimedia/mediawiki-core

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

Summary

Maintainability
F
3 days
Test Coverage

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

    DatabaseMySQL has 43 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class DatabaseMySQL extends Database {
        /** @var string|null */
        private $sslKeyPath;
        /** @var string|null */
        private $sslCertPath;
    Severity: Minor
    Found in includes/libs/rdbms/database/DatabaseMySQL.php - About 5 hrs to fix

      Method mysqlConnect has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function mysqlConnect( $server, $user, $password, $db ) {
              if ( !function_exists( 'mysqli_init' ) ) {
                  throw $this->newExceptionAfterConnectError(
                      "MySQLi functions missing, have you compiled PHP with the --with-mysqli option?"
                  );
      Severity: Minor
      Found in includes/libs/rdbms/database/DatabaseMySQL.php - About 1 hr to fix

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

            protected function open( $server, $user, $password, $db, $schema, $tablePrefix ) {
                $this->close( __METHOD__ );
        
                if ( $schema !== null ) {
                    throw $this->newExceptionAfterConnectError( "Got schema '$schema'; not supported." );
        Severity: Minor
        Found in includes/libs/rdbms/database/DatabaseMySQL.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 open has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function open( $server, $user, $password, $db, $schema, $tablePrefix ) {
                $this->close( __METHOD__ );
        
                if ( $schema !== null ) {
                    throw $this->newExceptionAfterConnectError( "Got schema '$schema'; not supported." );
        Severity: Minor
        Found in includes/libs/rdbms/database/DatabaseMySQL.php - About 1 hr to fix

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

              private function mysqlConnect( $server, $user, $password, $db ) {
                  if ( !function_exists( 'mysqli_init' ) ) {
                      throw $this->newExceptionAfterConnectError(
                          "MySQLi functions missing, have you compiled PHP with the --with-mysqli option?"
                      );
          Severity: Minor
          Found in includes/libs/rdbms/database/DatabaseMySQL.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 doSelectDomain has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function doSelectDomain( DatabaseDomain $domain ) {
                  if ( $domain->getSchema() !== null ) {
                      throw new DBExpectedError(
                          $this,
                          __CLASS__ . ": domain '{$domain->getId()}' has a schema component"
          Severity: Minor
          Found in includes/libs/rdbms/database/DatabaseMySQL.php - About 1 hr to fix

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

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

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

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

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

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

                  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/DatabaseMySQL.php - About 35 mins to fix

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

                        protected function checkInsertWarnings( Query $query, $fname ) {
                            if ( $this->conn && $this->conn->warning_count ) {
                                // Yeah it's weird. It's not iterable.
                                $warnings = $this->conn->get_warnings();
                                $done = $warnings === false;
                    Severity: Minor
                    Found in includes/libs/rdbms/database/DatabaseMySQL.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

                    There are no issues that match your filters.

                    Category
                    Status