wikimedia/mediawiki-core

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

Summary

Maintainability
F
3 days
Test Coverage

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

    DatabaseSqlite has 51 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class DatabaseSqlite extends Database {
        /** @var string|null Directory for SQLite database files listed under their DB name */
        protected $dbDir;
        /** @var string|null Explicit path for the SQLite database file */
        protected $dbPath;
    Severity: Major
    Found in includes/libs/rdbms/database/DatabaseSqlite.php - About 7 hrs to fix

      Method duplicateTableStructure has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function duplicateTableStructure(
              $oldName, $newName, $temporary = false, $fname = __METHOD__
          ) {
              $query = new Query(
                  "SELECT sql FROM sqlite_master WHERE tbl_name=" .
      Severity: Major
      Found in includes/libs/rdbms/database/DatabaseSqlite.php - About 3 hrs to fix

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

            protected function open( $server, $user, $password, $db, $schema, $tablePrefix ) {
                $this->close( __METHOD__ );
        
                // Note that for SQLite, $server, $user, and $pass are ignored
        
        
        Severity: Minor
        Found in includes/libs/rdbms/database/DatabaseSqlite.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 open has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function open( $server, $user, $password, $db, $schema, $tablePrefix ) {
                $this->close( __METHOD__ );
        
                // Note that for SQLite, $server, $user, and $pass are ignored
        
        
        Severity: Major
        Found in includes/libs/rdbms/database/DatabaseSqlite.php - About 2 hrs to fix

          Function duplicateTableStructure has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              public function duplicateTableStructure(
                  $oldName, $newName, $temporary = false, $fname = __METHOD__
              ) {
                  $query = new Query(
                      "SELECT sql FROM sqlite_master WHERE tbl_name=" .
          Severity: Minor
          Found in includes/libs/rdbms/database/DatabaseSqlite.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 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/DatabaseSqlite.php - About 45 mins to fix

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

                public function listTables( $prefix = null, $fname = __METHOD__ ) {
                    $query = new Query(
                        "SELECT name FROM sqlite_master WHERE type = 'table'",
                        self::QUERY_IGNORE_DBO_TRX | self::QUERY_CHANGE_NONE,
                        'SELECT'
            Severity: Minor
            Found in includes/libs/rdbms/database/DatabaseSqlite.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

            Avoid too many return statements within this method.
            Open

                        return $this->getBindingHandle()->quote( (string)$s );
            Severity: Major
            Found in includes/libs/rdbms/database/DatabaseSqlite.php - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status