CORE-POS/IS4C

View on GitHub
fannie/item/modules/LikeCodeModule.php

Summary

Maintainability
D
2 days
Test Coverage
F
42%

File LikeCodeModule.php has 359 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Copyright 2013 Whole Foods Co-op, Duluth, MN

Severity: Minor
Found in fannie/item/modules/LikeCodeModule.php - About 4 hrs to fix

    Method getFormJavascript has 78 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getFormJavascript($upc)
        {
            $FANNIE_URL = FannieConfig::config('URL');
            ob_start();
            ?>
    Severity: Major
    Found in fannie/item/modules/LikeCodeModule.php - About 3 hrs to fix

      Method SaveFormData has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function SaveFormData($upc)
          {
              try {
                  $likecode = $this->form->likeCode;
              } catch (Exception $ex) {
      Severity: Major
      Found in fannie/item/modules/LikeCodeModule.php - About 2 hrs to fix

        Function AjaxCallback has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            function AjaxCallback()
            {
                $likecode = FormLib::get('lc',-1);
                $newLC = FormLib::get('newLC', false);
                $json = array();
        Severity: Minor
        Found in fannie/item/modules/LikeCodeModule.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 AjaxCallback has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function AjaxCallback()
            {
                $likecode = FormLib::get('lc',-1);
                $newLC = FormLib::get('newLC', false);
                $json = array();
        Severity: Minor
        Found in fannie/item/modules/LikeCodeModule.php - About 1 hr to fix

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

              public function SaveFormData($upc)
              {
                  try {
                      $likecode = $this->form->likeCode;
                  } catch (Exception $ex) {
          Severity: Minor
          Found in fannie/item/modules/LikeCodeModule.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 showEditForm has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function showEditForm($upc, $display_mode=1, $expand_mode=1)
              {
                  $dbc = $this->db();
                  $myLC = $this->getLikeCode($dbc, $upc);
                  $ret = '<div id="LikeCodeFieldSet" class="panel panel-default">';
          Severity: Minor
          Found in fannie/item/modules/LikeCodeModule.php - About 1 hr to fix

            Method LikeCodeItems has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function LikeCodeItems($likecode, $upc='nomatch')
                {
                    if ($likecode == -1) return '';
                    $ret = "<b>Like Code Linked Items</b><div id=lctable>";
                    $ret .= "<table class=\"alert alert-warning table\">";
            Severity: Minor
            Found in fannie/item/modules/LikeCodeModule.php - About 1 hr to fix

              Avoid too many return statements within this method.
              Open

                          return false;
              Severity: Major
              Found in fannie/item/modules/LikeCodeModule.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return true;
                Severity: Major
                Found in fannie/item/modules/LikeCodeModule.php - About 30 mins to fix

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

                      public function showEditForm($upc, $display_mode=1, $expand_mode=1)
                      {
                          $dbc = $this->db();
                          $myLC = $this->getLikeCode($dbc, $upc);
                          $ret = '<div id="LikeCodeFieldSet" class="panel panel-default">';
                  Severity: Minor
                  Found in fannie/item/modules/LikeCodeModule.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