CORE-POS/IS4C

View on GitHub
pos/is4c-nf/lib/Database.php

Summary

Maintainability
F
3 days
Test Coverage
C
79%

File Database.php has 509 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Copyright 2012 Whole Foods Co-op

Severity: Major
Found in pos/is4c-nf/lib/Database.php - About 1 day to fix

    Database has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Database 
    {
    
    /***********************************************************************************************
    
    
    Severity: Minor
    Found in pos/is4c-nf/lib/Database.php - About 3 hrs to fix

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

      static public function getsubtotals() 
      {
          $query = "SELECT * FROM subtotals";
          $connection = self::tDataConnect();
          $result = $connection->query($query);
      Severity: Major
      Found in pos/is4c-nf/lib/Database.php - About 2 hrs to fix

        Method uploadtoServer has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        static private function uploadtoServer()
        {
            $uploaded = 0;
            CoreLocal::set("standalone",1);
        
        
        Severity: Minor
        Found in pos/is4c-nf/lib/Database.php - About 1 hr to fix

          Method lineItemTaxes has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          static public function lineItemTaxes()
          {
              $dbc = self::tDataConnect();
              $taxQ = "SELECT id, description, taxTotal, fsTaxable, fsTaxTotal, foodstampTender, taxrate
                  FROM taxView ORDER BY taxrate DESC";
          Severity: Minor
          Found in pos/is4c-nf/lib/Database.php - About 1 hr to fix

            Method getMatchingColumns has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            static public function getMatchingColumns($connection,$tableName,$table2="")
            {
                /**
                  Cache column information by table in the session
                  In standalone mode, a transfer query likely failed
            Severity: Minor
            Found in pos/is4c-nf/lib/Database.php - About 1 hr to fix

              Function getsubtotals has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              static public function getsubtotals() 
              {
                  $query = "SELECT * FROM subtotals";
                  $connection = self::tDataConnect();
                  $result = $connection->query($query);
              Severity: Minor
              Found in pos/is4c-nf/lib/Database.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 uploadCCdata has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              static private function uploadCCdata()
              {
                  if (!in_array("Paycards",CoreLocal::get("PluginList"))) {
                      // plugin not enabled; nothing to upload
                      return true;
              Severity: Minor
              Found in pos/is4c-nf/lib/Database.php - About 1 hr to fix

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

                static public function lineItemTaxes()
                {
                    $dbc = self::tDataConnect();
                    $taxQ = "SELECT id, description, taxTotal, fsTaxable, fsTaxTotal, foodstampTender, taxrate
                        FROM taxView ORDER BY taxrate DESC";
                Severity: Minor
                Found in pos/is4c-nf/lib/Database.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 getMatchingColumns has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                static public function getMatchingColumns($connection,$tableName,$table2="")
                {
                    /**
                      Cache column information by table in the session
                      In standalone mode, a transfer query likely failed
                Severity: Minor
                Found in pos/is4c-nf/lib/Database.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 getLocalConnection has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                static private function getLocalConnection($database1, $database2)
                {
                    if (self::$SQL_CONNECTION === null){
                        /**
                          Add both local databases to the connection object
                Severity: Minor
                Found in pos/is4c-nf/lib/Database.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

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

                static private function uploadCCdata()
                {
                    if (!in_array("Paycards",CoreLocal::get("PluginList"))) {
                        // plugin not enabled; nothing to upload
                        return true;
                Severity: Minor
                Found in pos/is4c-nf/lib/Database.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

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

                static private function uploadtoServer()
                {
                    $uploaded = 0;
                    CoreLocal::set("standalone",1);
                
                
                Severity: Minor
                Found in pos/is4c-nf/lib/Database.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 loadglobalvalue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                static private function loadglobalvalue($param,$val)
                {
                    switch (strtoupper($param)) {
                        case 'CASHIERNO':
                            CoreLocal::set("CashierNo",$val);    
                Severity: Minor
                Found in pos/is4c-nf/lib/Database.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

                Avoid too many return statements within this method.
                Open

                    return true;
                Severity: Major
                Found in pos/is4c-nf/lib/Database.php - About 30 mins to fix

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

                  static public function gettransno($cashierNo) 
                  {
                      $connection = self::tDataConnect();
                      $registerNo = CoreLocal::get("laneno");
                      $query = "SELECT max(trans_no) as maxtransno from localtranstoday where emp_no = "
                  Severity: Minor
                  Found in pos/is4c-nf/lib/Database.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