CORE-POS/IS4C

View on GitHub
fannie/ordering/OrderItemLib.php

Summary

Maintainability
C
1 day
Test Coverage
C
74%

File OrderItemLib.php has 341 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
  @class OrderItemLib
  
Severity: Minor
Found in fannie/ordering/OrderItemLib.php - About 4 hrs to fix

    Method getItemBySKU has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static function getItemBySKU($sku)
        {
            $dbc = self::dbc();
            // legacy behavior. + forces entry to be treated
            // as a SKU instead of a UPC.
    Severity: Major
    Found in fannie/ordering/OrderItemLib.php - About 2 hrs to fix

      Method getItemByUPC has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function getItemByUPC($upc)
          {
              $dbc = self::dbc();
              $upc = BarcodeLib::padUPC($upc);
      
      
      Severity: Major
      Found in fannie/ordering/OrderItemLib.php - About 2 hrs to fix

        Method memPricing has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function memPricing($cardno)
            {
                $default = array(
                    'type' => 'markdown',
                    'amount' => 0,
        Severity: Minor
        Found in fannie/ordering/OrderItemLib.php - About 1 hr to fix

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

              public static function getItem($upc)
              {
                  if (trim($upc) !== '' && !preg_match('/^0+$/', trim($upc))) {
                      $item = self::getItemByUPC($upc);
                      if ($item !== false) {
          Severity: Minor
          Found in fannie/ordering/OrderItemLib.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

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

              private static function resultToItem($dbc, $prodR)
              {
                  $prodW = $dbc->fetchRow($prodR);
                  $ret = self::$generic_item;
                  foreach ($ret as $key => $val) {
          Severity: Minor
          Found in fannie/ordering/OrderItemLib.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