CORE-POS/IS4C

View on GitHub
pos/is4c-nf/parser/parse/VoidCmd.php

Summary

Maintainability
F
3 days
Test Coverage
D
67%

File VoidCmd.php has 557 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Copyright 2007 Whole Foods Co-op

Severity: Major
Found in pos/is4c-nf/parser/parse/VoidCmd.php - About 1 day to fix

    Method voidupc has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function voidupc($upc, $json, $itemNum=-1)
        {
            $deliflag = false;
            $quantity = 0;
    
    
    Severity: Major
    Found in pos/is4c-nf/parser/parse/VoidCmd.php - About 3 hrs to fix

      Method voidid has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function voidid($itemNum, $json)
          {
              $row = $this->getLine($itemNum);
      
              $upc = $row["upc"];
      Severity: Major
      Found in pos/is4c-nf/parser/parse/VoidCmd.php - About 3 hrs to fix

        VoidCmd has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class VoidCmd extends Parser implements AdminLoginInterface
        {
            private $scaleprice = 0;
        
            public function check($str)
        Severity: Minor
        Found in pos/is4c-nf/parser/parse/VoidCmd.php - About 2 hrs to fix

          Method findUpcLine has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function findUpcLine($upc, $scaleprice, $deliflag, $itemNum)
              {
                  $dbc = Database::tDataConnect();
                  //----------------------Void Item------------------
                  $queryUPC = "SELECT 
          Severity: Minor
          Found in pos/is4c-nf/parser/parse/VoidCmd.php - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                    if (($this->session->get("isMember") != 1 && $row["discounttype"] == 2) || 
                        ($this->session->get("isStaff") == 0 && $row["discounttype"] == 4)) {
                        $unitPrice = $row["regPrice"];
                    } elseif ((($this->session->get("isMember") == 1 && $row["discounttype"] == 2) || 
                        ($this->session->get("isStaff") != 0 && $row["discounttype"] == 4)) && 
            Severity: Critical
            Found in pos/is4c-nf/parser/parse/VoidCmd.php - About 1 hr to fix

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

                  public function voidid($itemNum, $json)
                  {
                      $row = $this->getLine($itemNum);
              
                      $upc = $row["upc"];
              Severity: Minor
              Found in pos/is4c-nf/parser/parse/VoidCmd.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 voidupc has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function voidupc($upc, $json, $itemNum=-1)
                  {
                      $deliflag = false;
                      $quantity = 0;
              
              
              Severity: Minor
              Found in pos/is4c-nf/parser/parse/VoidCmd.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 checkUpcQuantities has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function checkUpcQuantities($voidable, $quantity, $scale, $row)
                  {
                      if ($voidable == 0 && $quantity == 1) {
                          throw new Exception(DisplayLib::boxMsg(
                              _("Item already voided"),
              Severity: Minor
              Found in pos/is4c-nf/parser/parse/VoidCmd.php - About 1 hr to fix

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

                    public function voiditem($itemNum, $json)
                    {
                        if ($itemNum) {
                            $row = $this->getLine($itemNum);
                
                
                Severity: Minor
                Found in pos/is4c-nf/parser/parse/VoidCmd.php - About 1 hr to fix

                  Method parse has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function parse($str)
                      {
                          $ret = $this->default_json();
                      
                          try {
                  Severity: Minor
                  Found in pos/is4c-nf/parser/parse/VoidCmd.php - About 1 hr to fix

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

                        public function voiditem($itemNum, $json)
                        {
                            if ($itemNum) {
                                $row = $this->getLine($itemNum);
                    
                    
                    Severity: Minor
                    Found in pos/is4c-nf/parser/parse/VoidCmd.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 branchByVoided has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function branchByVoided($voided, $transID, $status, $ret)
                        {
                            /**
                              Voided values:
                                2 => "you saved" line
                    Severity: Minor
                    Found in pos/is4c-nf/parser/parse/VoidCmd.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 parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function parse($str)
                        {
                            $ret = $this->default_json();
                        
                            try {
                    Severity: Minor
                    Found in pos/is4c-nf/parser/parse/VoidCmd.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 adjustUnitPrice has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function adjustUnitPrice($upc, $row)
                        {
                            $unitPrice = $row['unitPrice'];
                            /**
                              11Jun14 Andy
                    Severity: Minor
                    Found in pos/is4c-nf/parser/parse/VoidCmd.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 checkUpcQuantities has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function checkUpcQuantities($voidable, $quantity, $scale, $row)
                        {
                            if ($voidable == 0 && $quantity == 1) {
                                throw new Exception(DisplayLib::boxMsg(
                                    _("Item already voided"),
                    Severity: Minor
                    Found in pos/is4c-nf/parser/parse/VoidCmd.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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                            } elseif ($voidable < $quantity) {
                                $message = _("Void request exceeds")."<br />"._("number of items rung in")."<p><b>".
                                    sprintf(_("You can void up to %d"),$row['voidable'])."</b>";
                                throw new Exception(DisplayLib::boxMsg($message, '', false, DisplayLib::standardClearButton()));
                            }
                    Severity: Minor
                    Found in pos/is4c-nf/parser/parse/VoidCmd.php and 1 other location - About 45 mins to fix
                    pos/is4c-nf/parser/parse/VoidCmd.php on lines 386..390

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 96.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                            } elseif ($voidable < $quantity && $scale == 1) {
                                $message = _("Void request exceeds")."<br />"._("weight of item rung in")."<p><b>".
                                    sprintf(_("You can void up to %.2f lb"),$row['voidable'])."</b>";
                                throw new Exception(DisplayLib::boxMsg($message, '', false, DisplayLib::standardClearButton()));
                            } elseif ($voidable < $quantity) {
                    Severity: Minor
                    Found in pos/is4c-nf/parser/parse/VoidCmd.php and 1 other location - About 45 mins to fix
                    pos/is4c-nf/parser/parse/VoidCmd.php on lines 390..394

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 96.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    There are no issues that match your filters.

                    Category
                    Status