CORE-POS/IS4C

View on GitHub
fannie/classlib2.0/lib/PriceLib.php

Summary

Maintainability
D
2 days
Test Coverage
F
38%

Function pricePerUnit has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    public static function pricePerUnit($price,$sizeStr)
    {
        $country = \FannieConfig::factory()->get('COUNTRY', 'US');

        $num = "";
Severity: Minor
Found in fannie/classlib2.0/lib/PriceLib.php - About 4 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 pricePerUnit has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function pricePerUnit($price,$sizeStr)
    {
        $country = \FannieConfig::factory()->get('COUNTRY', 'US');

        $num = "";
Severity: Major
Found in fannie/classlib2.0/lib/PriceLib.php - About 3 hrs to fix

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

        public static function effectiveSalePrice($dbc, $config, $upc)
        {
            if (!is_array($upc)) {
                $upc = array($upc);
            }
    Severity: Minor
    Found in fannie/classlib2.0/lib/PriceLib.php - About 1 hr to fix

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

          public static function effectiveSalePrice($dbc, $config, $upc)
          {
              if (!is_array($upc)) {
                  $upc = array($upc);
              }
      Severity: Minor
      Found in fannie/classlib2.0/lib/PriceLib.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

      Avoid too many return statements within this method.
      Open

                          return round($price/($num*473.18),3)."/ML";
      Severity: Major
      Found in fannie/classlib2.0/lib/PriceLib.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                            return round($price/($num*0.035),3)."/OZ";
        Severity: Major
        Found in fannie/classlib2.0/lib/PriceLib.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                              return round($price/$num,3)."/G";
          Severity: Major
          Found in fannie/classlib2.0/lib/PriceLib.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return "";
            Severity: Major
            Found in fannie/classlib2.0/lib/PriceLib.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                                  return round($price/$num,3)."/OZ";
              Severity: Major
              Found in fannie/classlib2.0/lib/PriceLib.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return round($price/($num*33.814),3)."/OZ";
                Severity: Major
                Found in fannie/classlib2.0/lib/PriceLib.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                      return round($price/$num,3)."/OZ";
                  Severity: Major
                  Found in fannie/classlib2.0/lib/PriceLib.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                        return round($price/($num*28.35),3)."/G"; 
                    Severity: Major
                    Found in fannie/classlib2.0/lib/PriceLib.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                          return round($price/($num*3785.41),3)."/ML";
                      Severity: Major
                      Found in fannie/classlib2.0/lib/PriceLib.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return round($price/$num,3)."/".$unit;
                        Severity: Major
                        Found in fannie/classlib2.0/lib/PriceLib.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                              return round($price/($num*128),3)."/OZ";
                          Severity: Major
                          Found in fannie/classlib2.0/lib/PriceLib.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                return round($price/($num*16),3)."/OZ";
                            Severity: Major
                            Found in fannie/classlib2.0/lib/PriceLib.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                  return round($price/1000,3)."/ML";
                              Severity: Major
                              Found in fannie/classlib2.0/lib/PriceLib.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                    return round($price/$num,3)."/ML";
                                Severity: Major
                                Found in fannie/classlib2.0/lib/PriceLib.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                      return round($price/($num*29.5735),3)."/ML"; 
                                  Severity: Major
                                  Found in fannie/classlib2.0/lib/PriceLib.php - About 30 mins to fix

                                    There are no issues that match your filters.

                                    Category
                                    Status