CORE-POS/IS4C

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

Summary

Maintainability
F
4 days
Test Coverage
F
41%

Function setAltMemMsg has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
Open

    static public function setAltMemMsg($store, $member, $row)
    {
        if ($store == 'WEFC_Toronto') {
            $chargeOk = self::chargeOk();
            /* Doesn't quite allow for StoreCharge/PrePay for regular members
Severity: Minor
Found in pos/is4c-nf/lib/MemberLib.php - About 1 day 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 setAltMemMsg has 99 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    static public function setAltMemMsg($store, $member, $row)
    {
        if ($store == 'WEFC_Toronto') {
            $chargeOk = self::chargeOk();
            /* Doesn't quite allow for StoreCharge/PrePay for regular members
Severity: Major
Found in pos/is4c-nf/lib/MemberLib.php - About 3 hrs to fix

    File MemberLib.php has 320 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /*******************************************************************************
    
        Copyright 2016 Whole Foods Co-op
    
    
    Severity: Minor
    Found in pos/is4c-nf/lib/MemberLib.php - About 3 hrs to fix

      Method setMember has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          static public function setMember($member, $personNumber, $row=array())
          {
              $conn = Database::pDataConnect();
      
              /**
      Severity: Major
      Found in pos/is4c-nf/lib/MemberLib.php - About 2 hrs to fix

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

            static public function checkUnpaidAR($cardno)
            {
                // only attempt if server is available
                // and not the default non-member
                if ($cardno == \CoreLocal::get('defaultNonMem') || \CoreLocal::get('balance') == 0) {
        Severity: Minor
        Found in pos/is4c-nf/lib/MemberLib.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 memberID has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static public function memberID($memberNumber) 
            { 
                $query = "
                    SELECT CardNo,
                        personNum
        Severity: Minor
        Found in pos/is4c-nf/lib/MemberLib.php - About 1 hr to fix

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

              static public function checkUnpaidAR($cardno)
              {
                  // only attempt if server is available
                  // and not the default non-member
                  if ($cardno == \CoreLocal::get('defaultNonMem') || \CoreLocal::get('balance') == 0) {
          Severity: Minor
          Found in pos/is4c-nf/lib/MemberLib.php - About 1 hr to fix

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

                static public function setMember($member, $personNumber, $row=array())
                {
                    $conn = Database::pDataConnect();
            
                    /**
            Severity: Minor
            Found in pos/is4c-nf/lib/MemberLib.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 deeply nested control flow statements.
            Open

                                    if ($ccR === False) {
                                        \CoreLocal::set("memMsg", $memMsg . "Query failed");
                                        return;
                                    }
            Severity: Major
            Found in pos/is4c-nf/lib/MemberLib.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if ($ccS === False) {
                                          \CoreLocal::set("memMsg", $memMsg . "Prep failed");
                                          return;
                                      }
              Severity: Major
              Found in pos/is4c-nf/lib/MemberLib.php - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        while ($row = $conn->fetchRow($ccR)) {
                                            $programOK = \CoopCredLib::programOK($row['tenderType'], $conn);
                                            if ($programOK === True) {
                                                $programCode = 'CCred' . \CoreLocal::get("CCredProgramID");
                                                $tenderKeyCap = (\CoreLocal::get("{$programCode}tenderKeyCap") != "")
                Severity: Major
                Found in pos/is4c-nf/lib/MemberLib.php - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if ($message != "") {
                                              \CoreLocal::set("memMsg", $memMsg . "$message");
                                              return;
                                          }
                  Severity: Major
                  Found in pos/is4c-nf/lib/MemberLib.php - About 45 mins to fix

                    Function defaultMemMsg has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        static private function defaultMemMsg($member, $row)
                        {
                            /**
                              Determine what string is shown in the upper
                              left of the screen to indicate the current member
                    Severity: Minor
                    Found in pos/is4c-nf/lib/MemberLib.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

                    Avoid deeply nested control flow statements.
                    Open

                                            if ($conn->numRows($ccR) == 0) {
                                                \CoreLocal::set("memMsg", $memMsg);
                                                return;
                                            }
                    Severity: Major
                    Found in pos/is4c-nf/lib/MemberLib.php - About 45 mins to fix

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

                          static public function memberID($memberNumber) 
                          { 
                              $query = "
                                  SELECT CardNo,
                                      personNum
                      Severity: Minor
                      Found in pos/is4c-nf/lib/MemberLib.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

                      Avoid too many return statements within this method.
                      Open

                                                  return;
                      Severity: Major
                      Found in pos/is4c-nf/lib/MemberLib.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return false;
                        Severity: Major
                        Found in pos/is4c-nf/lib/MemberLib.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return true;
                          Severity: Major
                          Found in pos/is4c-nf/lib/MemberLib.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    return false;
                            Severity: Major
                            Found in pos/is4c-nf/lib/MemberLib.php - About 30 mins to fix

                              There are no issues that match your filters.

                              Category
                              Status