CORE-POS/IS4C

View on GitHub
pos/is4c-nf/plugins/Paycards/lib/paycardEntered.php

Summary

Maintainability
C
1 day
Test Coverage

Function paycard_entered has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    function paycard_entered($mode,$card,$manual,$type)
    {
        $ret = $this->default_json();
        // initialize
        $validate = true; // run Luhn's on PAN, check expiration date
Severity: Minor
Found in pos/is4c-nf/plugins/Paycards/lib/paycardEntered.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 paycard_entered has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function paycard_entered($mode,$card,$manual,$type)
    {
        $ret = $this->default_json();
        // initialize
        $validate = true; // run Luhn's on PAN, check expiration date
Severity: Major
Found in pos/is4c-nf/plugins/Paycards/lib/paycardEntered.php - About 2 hrs to fix

    Consider simplifying this complex logical expression.
    Open

            if (substr($str,-1,1) == "?"){
                return true;
            } elseif ($this->isE2E($str) || $this->isE2E(substr($str, 2))) {
                $this->swipetype = PaycardLib::PAYCARD_TYPE_ENCRYPTED;
                return true;
    Severity: Critical
    Found in pos/is4c-nf/plugins/Paycards/lib/paycardEntered.php - About 1 hr to fix

      Function initAmount has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          private function initAmount($type)
          {
              /* assign amount due. EBT food should use eligible amount */
              $this->conf->set("paycard_amount",$this->conf->get("amtdue"));
              if ($type == 'EBTFOOD'){
      Severity: Minor
      Found in pos/is4c-nf/plugins/Paycards/lib/paycardEntered.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

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

          function check($str)
          {
              $this->swipetype = PaycardLib::PAYCARD_TYPE_UNKNOWN;
              if (substr($str,-1,1) == "?"){
                  return true;
      Severity: Minor
      Found in pos/is4c-nf/plugins/Paycards/lib/paycardEntered.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 too many return statements within this method.
      Open

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

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

            function parse($str)
            {
                $ret = array();
                if ($this->interceptVoid) {
                    $ret['main_frame'] = $this->interceptVoid;
        Severity: Minor
        Found in pos/is4c-nf/plugins/Paycards/lib/paycardEntered.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