CORE-POS/IS4C

View on GitHub
fannie/classlib2.0/item/EpScaleLib.php

Summary

Maintainability
D
2 days
Test Coverage
F
41%

Function getUpdateItemLine has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    static private function getUpdateItemLine($item_info, $labelInfo)
    {
        $line = 'CCOSPIC' . chr(253); 
        foreach (ServiceScaleLib::$WRITE_ITEM_FIELDS as $key => $field_info) {
            if (isset($item_info[$key])) {
Severity: Minor
Found in fannie/classlib2.0/item/EpScaleLib.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

File EpScaleLib.php has 294 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Copyright 2014 Whole Foods Co-op, Duluth, MN

Severity: Minor
Found in fannie/classlib2.0/item/EpScaleLib.php - About 3 hrs to fix

    Function deleteItemsFromScales has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        static public function deleteItemsFromScales($items, $scales=array())
        {
            $config = \FannieConfig::factory(); 
            $dbc = \FannieDB::get($config->get('OP_DB'));
    
    
    Severity: Minor
    Found in fannie/classlib2.0/item/EpScaleLib.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 getUpdateItemLine has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        static private function getUpdateItemLine($item_info, $labelInfo)
        {
            $line = 'CCOSPIC' . chr(253); 
            foreach (ServiceScaleLib::$WRITE_ITEM_FIELDS as $key => $field_info) {
                if (isset($item_info[$key])) {
    Severity: Major
    Found in fannie/classlib2.0/item/EpScaleLib.php - About 2 hrs to fix

      Method getAddItemLine has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          static private function getAddItemLine($item_info, $labelInfo)
          {
              $line = 'CCOSPIA' . chr(253);
              $line .= 'PNO' . $item_info['PLU'] . chr(253);
              $line .= 'UPC' . ServiceScaleLib::pluToUPC($item_info['PLU']) . chr(253);
      Severity: Major
      Found in fannie/classlib2.0/item/EpScaleLib.php - About 2 hrs to fix

        Method deleteItemsFromScales has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static public function deleteItemsFromScales($items, $scales=array())
            {
                $config = \FannieConfig::factory(); 
                $dbc = \FannieDB::get($config->get('OP_DB'));
        
        
        Severity: Major
        Found in fannie/classlib2.0/item/EpScaleLib.php - About 2 hrs to fix

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

              static public function writeItemsToScales($items, $scales=array(), $asNew=true)
              {
                  $config = \FannieConfig::factory(); 
                  if (!isset($items[0])) {
                      $items = array($items);
          Severity: Minor
          Found in fannie/classlib2.0/item/EpScaleLib.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 writeItemsToScales has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              static public function writeItemsToScales($items, $scales=array(), $asNew=true)
              {
                  $config = \FannieConfig::factory(); 
                  if (!isset($items[0])) {
                      $items = array($items);
          Severity: Minor
          Found in fannie/classlib2.0/item/EpScaleLib.php - About 1 hr to fix

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

                static public function getItemLine($item_info, $scale_model, $asNew)
                {
                    $scale_fields = '';
                    if ($scale_model->epStoreNo() != 0) {
                        $scale_fields .= 'SNO' . $scale_model->epStoreNo() . chr(253);
            Severity: Minor
            Found in fannie/classlib2.0/item/EpScaleLib.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

            There are no issues that match your filters.

            Category
            Status