CORE-POS/IS4C

View on GitHub
common/SQLManager.php

Summary

Maintainability
F
1 wk
Test Coverage
C
77%

File SQLManager.php has 1127 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*******************************************************************************

    Copyright 2009 Whole Foods Co-op

Severity: Major
Found in common/SQLManager.php - About 2 days to fix

    SQLManager has 100 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class SQLManager 
    {
        /**
         Logging object (PSR-3)
        */
    Severity: Major
    Found in common/SQLManager.php - About 1 day to fix

      Method transfer has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function transfer($source_db,$select_query,$dest_db,$insert_query)
          {
              $result = $this->query($select_query,$source_db);
              if (!$result) {
                  return false;
      Severity: Minor
      Found in common/SQLManager.php - About 1 hr to fix

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

            public function addConnection($server,$type,$database,$username,$password='',$persistent=false,$new=false)
            {
                if (empty($type)) {
                    throw new Exception("Database type is required");
                } elseif (strtolower($type) == 'postgres9') {
        Severity: Minor
        Found in common/SQLManager.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 transfer has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function transfer($source_db,$select_query,$dest_db,$insert_query)
            {
                $result = $this->query($select_query,$source_db);
                if (!$result) {
                    return false;
        Severity: Minor
        Found in common/SQLManager.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 addConnection has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function addConnection($server,$type,$database,$username,$password='',$persistent=false,$new=false)
            {
                if (empty($type)) {
                    throw new Exception("Database type is required");
                } elseif (strtolower($type) == 'postgres9') {
        Severity: Minor
        Found in common/SQLManager.php - About 1 hr to fix

          Method fieldType has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function fieldType($result_object,$index,$which_connection='')
              {
                  if ($which_connection == '') {
                      $which_connection = $this->default_db;
                  }
          Severity: Minor
          Found in common/SQLManager.php - About 1 hr to fix

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

                public function query($query_text,$which_connection='',$params=false)
                {
                    $con = $this->getNamedConnection($which_connection);
            
                    $result = (!is_object($con)) ? false : $con->Execute($query_text,$params);
            Severity: Minor
            Found in common/SQLManager.php - About 1 hr to fix

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

                  public function query($query_text,$which_connection='',$params=false)
                  {
                      $con = $this->getNamedConnection($which_connection);
              
                      $result = (!is_object($con)) ? false : $con->Execute($query_text,$params);
              Severity: Minor
              Found in common/SQLManager.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 __construct has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function __construct($server,$type,$database,$username,$password='',$persistent=false, $new=false)
              Severity: Major
              Found in common/SQLManager.php - About 50 mins to fix

                Method addConnection has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function addConnection($server,$type,$database,$username,$password='',$persistent=false,$new=false)
                Severity: Major
                Found in common/SQLManager.php - About 50 mins to fix

                  Function fieldType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function fieldType($result_object,$index,$which_connection='')
                      {
                          if ($which_connection == '') {
                              $which_connection = $this->default_db;
                          }
                  Severity: Minor
                  Found in common/SQLManager.php - About 45 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 columnToArray has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function columnToArray($col)
                      {
                          $info = array();
                          $type = strtoupper($col->type);
                          if (property_exists($col, 'max_length') && $col->max_length != -1 && substr($type, -3) != 'INT') {
                  Severity: Minor
                  Found in common/SQLManager.php - About 45 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 getDSN has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function getDSN($server, $type, $database)
                      {
                          if ($this->isPDO($type)) {
                              $dsn = substr(strtolower($type), 4) . ':';
                              if (strstr($server, ':')) {
                  Severity: Minor
                  Found in common/SQLManager.php - About 45 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 saveConnection has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      private function saveConnection($server, $type, $username, $password, $database)
                  Severity: Minor
                  Found in common/SQLManager.php - About 35 mins to fix

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

                        private function connectAndCreate($server, $type, $username, $password, $database)
                    Severity: Minor
                    Found in common/SQLManager.php - About 35 mins to fix

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

                          public function getValue($sql, $input_array=array(), $which_connection='')
                          {
                              $res = $this->execute($sql, $input_array, $which_connection);
                              if ($res && $this->numRows($res) > 0) {
                                  $row = $this->fetchRow($res);
                      Severity: Minor
                      Found in common/SQLManager.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 smartUpdate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function smartUpdate($table_name,$values,$where_clause,$which_connection='')
                          {
                              $which_connection = ($which_connection === '') ? $this->default_db : $which_connection;
                      
                              $t_def = $this->tableDefinition($table_name, $which_connection);
                      Severity: Minor
                      Found in common/SQLManager.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 setDefaultDB has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function setDefaultDB($db_name)
                          {
                              /** verify connection **/
                              if (!is_string($db_name) || !isset($this->connections[$db_name])) {
                                  return false;
                      Severity: Minor
                      Found in common/SQLManager.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 smartInsert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function smartInsert($table_name,$values,$which_connection='')
                          {
                              $which_connection = ($which_connection === '') ? $this->default_db : $which_connection;
                      
                              $t_def = $this->tableDefinition($table_name, $which_connection);
                      Severity: Minor
                      Found in common/SQLManager.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 getRow has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function getRow($sql, $input_array=array(), $which_connection='')
                          {
                              $res = $this->execute($sql, $input_array, $which_connection);
                              if ($res && $this->numRows($res) > 0) {
                                  $row = $this->fetchRow($res);
                      Severity: Minor
                      Found in common/SQLManager.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 fetchArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function fetchArray($result_object,$which_connection='')
                          {
                              if (is_null($result_object)) return false;
                              if ($result_object === false) return false;
                      
                      
                      Severity: Minor
                      Found in common/SQLManager.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

                      Function executeAsTransaction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function executeAsTransaction($query, $arg_sets, $which_connection='')
                          {
                              $which_connection = $which_connection === '' ? $this->default_db : $which_connection;
                              $ret = true;
                              $statement = $this->prepare($query, $which_connection);
                      Severity: Minor
                      Found in common/SQLManager.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

                      Function columnBooleanProperty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function columnBooleanProperty($col, $prop)
                          {
                              if (property_exists($col, $prop) && $col->$prop) {
                                  return true;
                              } else if (property_exists($col, $prop) && !$col->$prop) {
                      Severity: Minor
                      Found in common/SQLManager.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