CORE-POS/IS4C

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

Summary

Maintainability
D
2 days
Test Coverage
F
45%

File ItemMarginModule.php has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Copyright 2013 Whole Foods Co-op, Duluth, MN

Severity: Minor
Found in fannie/item/modules/ItemMarginModule.php - About 3 hrs to fix

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

        public function showEditForm($upc, $display_mode=1, $expand_mode=1)
        {
            $db = $this->db();
            $product = new ProductsModel($db);
            $product->upc($upc);
    Severity: Major
    Found in fannie/item/modules/ItemMarginModule.php - About 3 hrs to fix

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

          private function calculateMargin($price, $cost, $deptID, $upc)
          {
              $dbc = $this->db();
      
              $desired_margin = 'Unknown';
      Severity: Major
      Found in fannie/item/modules/ItemMarginModule.php - About 3 hrs to fix

        Function saveFormData has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public function saveFormData($upc)
            {
                $dbc = $this->db();
                try {
                    $new_rule = $this->form->price_rule_id;
        Severity: Minor
        Found in fannie/item/modules/ItemMarginModule.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

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

            private function calculateMargin($price, $cost, $deptID, $upc)
            {
                $dbc = $this->db();
        
                $desired_margin = 'Unknown';
        Severity: Minor
        Found in fannie/item/modules/ItemMarginModule.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 saveFormData has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function saveFormData($upc)
            {
                $dbc = $this->db();
                try {
                    $new_rule = $this->form->price_rule_id;
        Severity: Minor
        Found in fannie/item/modules/ItemMarginModule.php - About 1 hr to fix

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

              public function avgSales($upc)
              {
                  $config = FannieConfig::factory();
                  $dbc = FannieDB::get($config->get('OP_DB'));
                  $store = Store::getIdByIp();
          Severity: Minor
          Found in fannie/item/modules/ItemMarginModule.php - About 1 hr to fix

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

                public function avgSales($upc)
                {
                    $config = FannieConfig::factory();
                    $dbc = FannieDB::get($config->get('OP_DB'));
                    $store = Store::getIdByIp();
            Severity: Minor
            Found in fannie/item/modules/ItemMarginModule.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 showEditForm has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function showEditForm($upc, $display_mode=1, $expand_mode=1)
                {
                    $db = $this->db();
                    $product = new ProductsModel($db);
                    $product->upc($upc);
            Severity: Minor
            Found in fannie/item/modules/ItemMarginModule.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

            There are no issues that match your filters.

            Category
            Status