detain/db_abstraction

View on GitHub

Showing 90 of 90 total issues

Function query has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

    public function query($queryString, $line = '', $file = '')
    {
        /* No empty queries, please, since PHP4 chokes on them. */
        /* The empty query string is passed on from the constructor,
        * when calling the class without a query, e.g. in situations
Severity: Minor
Found in src/Mysqli/Db.php - About 5 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

File Db.php has 305 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * MySQL Related Functionality
 * @author Joe Huss <detain@interserver.net>
 * @copyright 2019
Severity: Minor
Found in src/Mysqli/Db.php - About 3 hrs to fix

    Db has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Db extends Generic implements Db_Interface
    {
        /* public: this is an api revision, not a CVS revision. */
        public $type = 'pgsql';
        public $port = '';
    Severity: Minor
    Found in src/Pgsql/Db.php - About 2 hrs to fix

      Method query has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function query($queryString, $line = '', $file = '')
          {
              /* No empty queries, please, since PHP4 chokes on them. */
              /* The empty query string is passed on from the constructor,
              * when calling the class without a query, e.g. in situations
      Severity: Major
      Found in src/Mysqli/Db.php - About 2 hrs to fix

        Db has 23 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Db extends Generic implements Db_Interface
        {
            /**
             * @var string
             */
        Severity: Minor
        Found in src/Mysqli/Db.php - About 2 hrs to fix

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

              public function connect($database = '', $host = '', $user = '', $password = '', $port = '')
              {
                  /* Handle defaults */
                  if ($database == '') {
                      $database = $this->database;
          Severity: Minor
          Found in src/Mysqli/Db.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 connect has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function connect($database = '', $host = '', $user = '', $password = '', $port = '')
              {
                  /* Handle defaults */
                  if ($database == '') {
                      $database = $this->database;
          Severity: Minor
          Found in src/Mysqli/Db.php - About 1 hr to fix

            Method __construct has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function __construct($Type = '', $database = '', $user = '', $password = '', $host = 'localhost', $query = '')
                {
                    $this->Type = $Type;
                    if (!defined('db')) {
                        switch ($this->Type) {
            Severity: Minor
            Found in src/Loader.php - About 1 hr to fix

              Avoid using undefined variables such as '$mysqli' which will lead to PHP notices.
              Open

                              $this->halt("connect($host, $user, \$password) failed. ".$mysqli->connect_error);
              Severity: Minor
              Found in src/Mysqli/Db.php by phpmd

              UndefinedVariable

              Since: 2.8.0

              Detects when a variable is used that has not been defined before.

              Example

              class Foo
              {
                  private function bar()
                  {
                      // $message is undefined
                      echo $message;
                  }
              }

              Source https://phpmd.org/rules/cleancode.html#undefinedvariable

              Avoid using undefined variables such as '$mysqli' which will lead to PHP notices.
              Open

                              $this->halt("connect($host, $user, \$password) failed. ".$mysqli->connect_error);
              Severity: Minor
              Found in src/Mysqli/Db.php by phpmd

              UndefinedVariable

              Since: 2.8.0

              Detects when a variable is used that has not been defined before.

              Example

              class Foo
              {
                  private function bar()
                  {
                      // $message is undefined
                      echo $message;
                  }
              }

              Source https://phpmd.org/rules/cleancode.html#undefinedvariable

              Avoid using undefined variables such as '$success' which will lead to PHP notices.
              Open

                      $this->log("ADOdb Query $queryString (S:$success) - ".count($this->Rows).' Rows', __LINE__, __FILE__);
              Severity: Minor
              Found in src/Adodb/Db.php by phpmd

              UndefinedVariable

              Since: 2.8.0

              Detects when a variable is used that has not been defined before.

              Example

              class Foo
              {
                  private function bar()
                  {
                      // $message is undefined
                      echo $message;
                  }
              }

              Source https://phpmd.org/rules/cleancode.html#undefinedvariable

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

                  public function connect($database = '', $host = '', $user = '', $password = '', $driver = 'mysql')
                  {
                      /* Handle defaults */
                      if ('' == $database) {
                          $database = $this->database;
              Severity: Minor
              Found in src/Pdo/Db.php - About 1 hr to fix

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

                    public function logBackTrace($msg, $line = '', $file = '')
                    {
                        $backtrace = (function_exists('debug_backtrace') ? debug_backtrace() : []);
                        $this->log(
                            ('' !== getenv('REQUEST_URI') ? ' '.getenv('REQUEST_URI') : '').
                Severity: Minor
                Found in src/Generic.php - About 1 hr to fix

                  Function lock has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function lock($table, $mode = 'write')
                      {
                          $this->connect();
                          $query = 'lock tables ';
                          if (is_array($table)) {
                  Severity: Minor
                  Found in src/Mysqli/Db.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

                  Function __construct has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function __construct($Type = '', $database = '', $user = '', $password = '', $host = 'localhost', $query = '')
                      {
                          $this->Type = $Type;
                          if (!defined('db')) {
                              switch ($this->Type) {
                  Severity: Minor
                  Found in src/Loader.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

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

                      public function connect($database = '', $host = '', $user = '', $password = '', $driver = 'mysql')
                      {
                          /* Handle defaults */
                          if ('' == $database) {
                              $database = $this->database;
                  Severity: Minor
                  Found in src/Pdo/Db.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

                  Avoid classes with short names like Db. Configured minimum length is 3.
                  Open

                  class Db extends MysqliDb implements Db_Interface
                  {
                      public $host = 'localhost';
                      public $user = 'pdns';
                      public $password = '';
                  Severity: Minor
                  Found in src/Mdb2/Db.php by phpmd

                  ShortClassName

                  Since: 2.9

                  Detects when classes or interfaces have a very short name.

                  Example

                  class Fo {
                  
                  }
                  
                  interface Fo {
                  
                  }

                  Source https://phpmd.org/rules/naming.html#shortclassname

                  Avoid classes with short names like Db. Configured minimum length is 3.
                  Open

                  class Db extends Generic implements Db_Interface
                  {
                      /**
                       * @var string
                       */
                  Severity: Minor
                  Found in src/Mysqli/Db.php by phpmd

                  ShortClassName

                  Since: 2.9

                  Detects when classes or interfaces have a very short name.

                  Example

                  class Fo {
                  
                  }
                  
                  interface Fo {
                  
                  }

                  Source https://phpmd.org/rules/naming.html#shortclassname

                  Avoid classes with short names like Db. Configured minimum length is 3.
                  Open

                  class Db extends Generic implements Db_Interface
                  {
                      /* public: connection parameters */
                      public $driver = 'mysql';
                      public $Rows = [];
                  Severity: Minor
                  Found in src/Pdo/Db.php by phpmd

                  ShortClassName

                  Since: 2.9

                  Detects when classes or interfaces have a very short name.

                  Example

                  class Fo {
                  
                  }
                  
                  interface Fo {
                  
                  }

                  Source https://phpmd.org/rules/naming.html#shortclassname

                  Avoid classes with short names like Db. Configured minimum length is 3.
                  Open

                  class Db extends Generic implements Db_Interface
                  {
                      public $driver = 'mysql';
                      public $Rows = [];
                      public $type = 'adodb';
                  Severity: Minor
                  Found in src/Adodb/Db.php by phpmd

                  ShortClassName

                  Since: 2.9

                  Detects when classes or interfaces have a very short name.

                  Example

                  class Fo {
                  
                  }
                  
                  interface Fo {
                  
                  }

                  Source https://phpmd.org/rules/naming.html#shortclassname

                  Severity
                  Category
                  Status
                  Source
                  Language