CORE-POS/IS4C

View on GitHub
pos/is4c-nf/lib/DeptLib.php

Summary

Maintainability
D
2 days
Test Coverage
F
44%

Function memberOnlyDept has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    private function memberOnlyDept($dept, $ret)
    {
        /**
          Enforce memberOnly flag
        */
Severity: Minor
Found in pos/is4c-nf/lib/DeptLib.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 DeptLib.php has 264 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Copyright 2016 Whole Foods Co-op

Severity: Minor
Found in pos/is4c-nf/lib/DeptLib.php - About 2 hrs to fix

    Method deptOpenRing has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function deptOpenRing($dept, $price, $discount, $ret)
        {
            list($ret, $memberOnly) = $this->memberOnlyDept($dept, $ret);
            if ($memberOnly === true) {
                return $ret;
    Severity: Major
    Found in pos/is4c-nf/lib/DeptLib.php - About 2 hrs to fix

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

          public function deptkey($price, $dept,$ret=array()) 
          {
              if ($this->session->get("quantity") == 0 && $this->session->get("multiple") == 0) {
                  $this->session->set("quantity",1);
              }
      Severity: Minor
      Found in pos/is4c-nf/lib/DeptLib.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 memberOnlyDept has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function memberOnlyDept($dept, $ret)
          {
              /**
                Enforce memberOnly flag
              */
      Severity: Major
      Found in pos/is4c-nf/lib/DeptLib.php - About 2 hrs to fix

        Method deptkey has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function deptkey($price, $dept,$ret=array()) 
            {
                if ($this->session->get("quantity") == 0 && $this->session->get("multiple") == 0) {
                    $this->session->set("quantity",1);
                }
        Severity: Minor
        Found in pos/is4c-nf/lib/DeptLib.php - About 2 hrs to fix

          Method deptCouponRing has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function deptCouponRing($dept, $price, $ret)
              {
                  $query2 = "select department, sum(total) as total from localtemptrans where department = "
                      .$dept['dept_no']." group by department";
          
          
          Severity: Minor
          Found in pos/is4c-nf/lib/DeptLib.php - About 1 hr to fix

            Function getDepartment has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                private function getDepartment($dbc, $dept)
                {
                    $query = "SELECT dept_no,
                        dept_name,
                        dept_tax,
            Severity: Minor
            Found in pos/is4c-nf/lib/DeptLib.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 getDepartment has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getDepartment($dbc, $dept)
                {
                    $query = "SELECT dept_no,
                        dept_name,
                        dept_tax,
            Severity: Minor
            Found in pos/is4c-nf/lib/DeptLib.php - About 1 hr to fix

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

                  private function deptOpenRing($dept, $price, $discount, $ret)
                  {
                      list($ret, $memberOnly) = $this->memberOnlyDept($dept, $ret);
                      if ($memberOnly === true) {
                          return $ret;
              Severity: Minor
              Found in pos/is4c-nf/lib/DeptLib.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

              There are no issues that match your filters.

              Category
              Status