CORE-POS/IS4C

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

Summary

Maintainability
F
1 wk
Test Coverage
B
82%

File DisplayLib.php has 677 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Copyright 2012 Whole Foods Co-op

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

    Consider simplifying this complex logical expression.
    Open

        if ($row['trans_status'] == 'V' || $row['trans_type'] == 'T' || $row['trans_status'] == 'R' || $row['trans_status'] == 'M' || $row['voided'] == 17 || $row['trans_status'] == 'J') {
            return '800000';
        } elseif (($row['discounttype'] != 0 && ($row['matched'] > 0 || $row['volDiscType'] == 0)) 
            || $row['voided'] == 2 || $row['voided'] == 6 || $row['voided'] == 4 || $row['voided'] == 5 || $row['voided'] == 10 || $row['voided'] == 22) {
            return '408080';
    Severity: Critical
    Found in pos/is4c-nf/lib/DisplayLib.php - About 3 hrs to fix

      DisplayLib has 29 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class DisplayLib 
      {
      
      /**
        Get the standard footer with total and
      Severity: Minor
      Found in pos/is4c-nf/lib/DisplayLib.php - About 3 hrs to fix

        Function printfooter has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        static public function printfooter($readOnly=False) 
        {
            $FOOTER_MODULES = CoreLocal::get("FooterModules");
            // use defaults if modules haven't been configured
            // properly
        Severity: Minor
        Found in pos/is4c-nf/lib/DisplayLib.php - About 3 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 printfooter has 73 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        static public function printfooter($readOnly=False) 
        {
            $FOOTER_MODULES = CoreLocal::get("FooterModules");
            // use defaults if modules haven't been configured
            // properly
        Severity: Major
        Found in pos/is4c-nf/lib/DisplayLib.php - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

              if ($row['discounttype'] == 3 && $row['trans_status'] == 'V') {
                  return $row['ItemQtty'] . ' /' . $row['unitPrice'];
              } elseif ($row['voided'] == 5) {
                  return 'Discount';
              } elseif ($row['trans_status'] == 'M') {
          Severity: Critical
          Found in pos/is4c-nf/lib/DisplayLib.php - About 2 hrs to fix

            Function scaledisplaymsg has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

            static public function scaledisplaymsg($input="")
            {
                $reginput = trim(strtoupper($input));
            
                $scans = '';
            Severity: Minor
            Found in pos/is4c-nf/lib/DisplayLib.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 touchScreenKeyboard has 64 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            static public function touchScreenKeyboard($selector='#reginput')
            {
                return '
                    <button type="button" class="pos-button" style="width: 25px;"
                        onclick="s=$(\'' . $selector . '\').val(); $(\'' . $selector . '\').val(s + \'Q\');">Q</button>
            Severity: Major
            Found in pos/is4c-nf/lib/DisplayLib.php - About 2 hrs to fix

              Function screenDisplayComment has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

              static private function screenDisplayComment($row)
              {
                  if ($row['discounttype'] == 3 && $row['trans_status'] == 'V') {
                      return $row['ItemQtty'] . ' /' . $row['unitPrice'];
                  } elseif ($row['voided'] == 5) {
              Severity: Minor
              Found in pos/is4c-nf/lib/DisplayLib.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 scaledisplaymsg has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              static public function scaledisplaymsg($input="")
              {
                  $reginput = trim(strtoupper($input));
              
                  $scans = '';
              Severity: Minor
              Found in pos/is4c-nf/lib/DisplayLib.php - About 1 hr to fix

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

                static public function printheaderb() 
                {
                
                    $strmemberID = "";
                    if (CoreLocal::get("memberID") != "0") {
                Severity: Minor
                Found in pos/is4c-nf/lib/DisplayLib.php - About 1 hr to fix

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

                  static public function drawItems($topItem, $rows, $highlight) 
                  {
                      $ret = self::printheaderb();
                  
                      $query = "select count(*) as count from localtemptrans";
                  Severity: Minor
                  Found in pos/is4c-nf/lib/DisplayLib.php - About 1 hr to fix

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

                    static public function drawItems($topItem, $rows, $highlight) 
                    {
                        $ret = self::printheaderb();
                    
                        $query = "select count(*) as count from localtemptrans";
                    Severity: Minor
                    Found in pos/is4c-nf/lib/DisplayLib.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 msgbox has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    static public function msgbox($strmsg, $icon, $noBeep=false, $buttons=array()) 
                    {
                        $ret = self::printheaderb();
                        $ret .= "<div id=\"boxMsg\" class=\"centeredDisplay\">";
                        $ret .= "<div class=\"boxMsgAlert coloredArea\">";
                    Severity: Minor
                    Found in pos/is4c-nf/lib/DisplayLib.php - About 1 hr to fix

                      Method screenDisplayComment has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      static private function screenDisplayComment($row)
                      {
                          if ($row['discounttype'] == 3 && $row['trans_status'] == 'V') {
                              return $row['ItemQtty'] . ' /' . $row['unitPrice'];
                          } elseif ($row['voided'] == 5) {
                      Severity: Minor
                      Found in pos/is4c-nf/lib/DisplayLib.php - About 1 hr to fix

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

                        static private function screenDisplayStatus($row)
                        {
                            if ($row['trans_status'] == 'V') {
                                return 'VD';
                            } elseif ($row['trans_status'] == 'R') {
                        Severity: Minor
                        Found in pos/is4c-nf/lib/DisplayLib.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

                        Consider simplifying this complex logical expression.
                        Open

                            if ($row['trans_status'] == 'V') {
                                return 'VD';
                            } elseif ($row['trans_status'] == 'R') {
                                return 'RF';
                            } elseif ($row['trans_status'] == 'C') {
                        Severity: Major
                        Found in pos/is4c-nf/lib/DisplayLib.php - About 1 hr to fix

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

                          static private function screenDisplayColor($row)
                          {
                              if ($row['trans_status'] == 'V' || $row['trans_type'] == 'T' || $row['trans_status'] == 'R' || $row['trans_status'] == 'M' || $row['voided'] == 17 || $row['trans_status'] == 'J') {
                                  return '800000';
                              } elseif (($row['discounttype'] != 0 && ($row['matched'] > 0 || $row['volDiscType'] == 0)) 
                          Severity: Minor
                          Found in pos/is4c-nf/lib/DisplayLib.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 msgbox has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          static public function msgbox($strmsg, $icon, $noBeep=false, $buttons=array()) 
                          {
                              $ret = self::printheaderb();
                              $ret .= "<div id=\"boxMsg\" class=\"centeredDisplay\">";
                              $ret .= "<div class=\"boxMsgAlert coloredArea\">";
                          Severity: Minor
                          Found in pos/is4c-nf/lib/DisplayLib.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 $row['volume'] . ' for ' . $row['unitPrice'];
                          Severity: Major
                          Found in pos/is4c-nf/lib/DisplayLib.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    return _('Discount');
                            Severity: Major
                            Found in pos/is4c-nf/lib/DisplayLib.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

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

                                Avoid too many return statements within this method.
                                Open

                                    return array('', "style=\"background:#$color;color:#ffffff;\"");
                                Severity: Major
                                Found in pos/is4c-nf/lib/DisplayLib.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                          return $row['quantity'] . ' @ ' . $row['unitPrice'];
                                  Severity: Major
                                  Found in pos/is4c-nf/lib/DisplayLib.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                            return $row['description'];
                                    Severity: Major
                                    Found in pos/is4c-nf/lib/DisplayLib.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                              return substr($row['tax_description'], 0 , 1);
                                      Severity: Major
                                      Found in pos/is4c-nf/lib/DisplayLib.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                return $row['upc'];
                                        Severity: Major
                                        Found in pos/is4c-nf/lib/DisplayLib.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

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

                                            Avoid too many return statements within this method.
                                            Open

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

                                              Avoid too many return statements within this method.
                                              Open

                                                      return array('', "style=\"color:#$color;\"");
                                              Severity: Major
                                              Found in pos/is4c-nf/lib/DisplayLib.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                        return $row['quantity'] . ' @ ' . $row['volume'] . ' for ' . $row['unitPrice'];
                                                Severity: Major
                                                Found in pos/is4c-nf/lib/DisplayLib.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                          return _('1 w/ vol adj');
                                                  Severity: Major
                                                  Found in pos/is4c-nf/lib/DisplayLib.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

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

                                                      Avoid too many return statements within this method.
                                                      Open

                                                              return $row['ItemQtty'] . ' / ' . $row['unitPrice'];
                                                      Severity: Major
                                                      Found in pos/is4c-nf/lib/DisplayLib.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

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

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                  return $row['ItemQtty'] . ' @ ' . $row['unitPrice'];
                                                          Severity: Major
                                                          Found in pos/is4c-nf/lib/DisplayLib.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                    return _('Total ');
                                                            Severity: Major
                                                            Found in pos/is4c-nf/lib/DisplayLib.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

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

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                        return substr($row['tax_description'], 0 , 1) . 'F';
                                                                Severity: Major
                                                                Found in pos/is4c-nf/lib/DisplayLib.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

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

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                            return $row['ItemQtty'] . ' @ ' . $row['regPrice'];
                                                                    Severity: Major
                                                                    Found in pos/is4c-nf/lib/DisplayLib.php - About 30 mins to fix

                                                                      There are no issues that match your filters.

                                                                      Category
                                                                      Status