CORE-POS/IS4C

View on GitHub
fannie/item/modules/BaseItemModule.php

Summary

Maintainability
F
1 wk
Test Coverage
C
74%

File BaseItemModule.php has 1175 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Copyright 2013 Whole Foods Co-op, Duluth, MN

Severity: Major
Found in fannie/item/modules/BaseItemModule.php - About 3 days to fix

    Method showEditForm has 489 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function showEditForm($upc, $display_mode=1, $expand_mode=1)
        {
            $FANNIE_PRODUCT_MODULES = FannieConfig::config('PRODUCT_MODULES', array());
            $upc = BarcodeLib::padUPC($upc);
    
    
    Severity: Major
    Found in fannie/item/modules/BaseItemModule.php - About 2 days to fix

      Function showEditForm has a Cognitive Complexity of 80 (exceeds 5 allowed). Consider refactoring.
      Open

          public function showEditForm($upc, $display_mode=1, $expand_mode=1)
          {
              $FANNIE_PRODUCT_MODULES = FannieConfig::config('PRODUCT_MODULES', array());
              $upc = BarcodeLib::padUPC($upc);
      
      
      Severity: Minor
      Found in fannie/item/modules/BaseItemModule.php - About 1 day 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 saveFormData has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
      Open

          function saveFormData($upc)
          {
              $FANNIE_PRODUCT_MODULES = FannieConfig::config('PRODUCT_MODULES', array());
              $upc = BarcodeLib::padUPC($upc);
              $dbc = $this->db();
      Severity: Minor
      Found in fannie/item/modules/BaseItemModule.php - About 6 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 saveFormData has 132 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function saveFormData($upc)
          {
              $FANNIE_PRODUCT_MODULES = FannieConfig::config('PRODUCT_MODULES', array());
              $upc = BarcodeLib::padUPC($upc);
              $dbc = $this->db();
      Severity: Major
      Found in fannie/item/modules/BaseItemModule.php - About 5 hrs to fix

        Method getNewItem has 111 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function getNewItem($upc)
            {
                $dbc = $this->db();
                // default values for form fields
                $rowItem = array(
        Severity: Major
        Found in fannie/item/modules/BaseItemModule.php - About 4 hrs to fix

          Method getExistingItem has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function getExistingItem($upc)
              {
                  $dbc = $this->db();
                  $itemQ = '
                      SELECT
          Severity: Major
          Found in fannie/item/modules/BaseItemModule.php - About 2 hrs to fix

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

            class BaseItemModule extends \COREPOS\Fannie\API\item\ItemModule 
            {
                private function getBarcodeType($upc)
                {
                    $trimmed = ltrim($upc, '0');
            Severity: Minor
            Found in fannie/item/modules/BaseItemModule.php - About 2 hrs to fix

              Function getNewItem has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function getNewItem($upc)
                  {
                      $dbc = $this->db();
                      // default values for form fields
                      $rowItem = array(
              Severity: Minor
              Found in fannie/item/modules/BaseItemModule.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 deptMaps has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function deptMaps($rowItem, $range_limit)
                  {
                      $supers = array();
                      $depts = array();
                      $subs = array();
              Severity: Major
              Found in fannie/item/modules/BaseItemModule.php - About 2 hrs to fix

                Method saveVendorItem has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function saveVendorItem($product, $vendorID)
                    {
                        $dbc = $this->db();
                        $upc = $product->upc();
                        /**
                Severity: Minor
                Found in fannie/item/modules/BaseItemModule.php - About 1 hr to fix

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

                      private function deptMaps($rowItem, $range_limit)
                      {
                          $supers = array();
                          $depts = array();
                          $subs = array();
                  Severity: Minor
                  Found in fannie/item/modules/BaseItemModule.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 summaryRows has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      function summaryRows($upc)
                      {
                          $dbc = $this->db();
                  
                          $model = new ProductsModel($dbc);
                  Severity: Minor
                  Found in fannie/item/modules/BaseItemModule.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 summaryRows has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function summaryRows($upc)
                      {
                          $dbc = $this->db();
                  
                          $model = new ProductsModel($dbc);
                  Severity: Minor
                  Found in fannie/item/modules/BaseItemModule.php - About 1 hr to fix

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

                        private function saveVendorItem($product, $vendorID)
                        {
                            $dbc = $this->db();
                            $upc = $product->upc();
                            /**
                    Severity: Minor
                    Found in fannie/item/modules/BaseItemModule.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 getExistingItem has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function getExistingItem($upc)
                        {
                            $dbc = $this->db();
                            $itemQ = '
                                SELECT
                    Severity: Minor
                    Found in fannie/item/modules/BaseItemModule.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 getBarcodeType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function getBarcodeType($upc)
                        {
                            $trimmed = ltrim($upc, '0');
                            $barcode_type = '';
                            if (strlen($trimmed) == '12') {
                    Severity: Minor
                    Found in fannie/item/modules/BaseItemModule.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