CORE-POS/IS4C

View on GitHub
fannie/item/ItemEditorPage.php

Summary

Maintainability
F
6 days
Test Coverage
F
55%

File ItemEditorPage.php has 765 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Copyright 2013 Whole Foods Community Co-op

Severity: Major
Found in fannie/item/ItemEditorPage.php - About 1 day to fix

    Function getConfiguredModules has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getConfiguredModules()
        {
            $FANNIE_PRODUCT_MODULES = $this->config->get('PRODUCT_MODULES');
            if (!is_array($FANNIE_PRODUCT_MODULES)) {
                $FANNIE_PRODUCT_MODULES = array('BaseItemModule' => array('seq'=>0, 'show'=>1, 'expand'=>1));
    Severity: Minor
    Found in fannie/item/ItemEditorPage.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

    Method editForm has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function editForm($upc,$isNew)
        {
            $FANNIE_PRODUCT_MODULES = $this->getConfiguredModules();
            $FANNIE_URL = $this->config->get('URL');
            $shown = array();
    Severity: Major
    Found in fannie/item/ItemEditorPage.php - About 3 hrs to fix

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

          private function searchForm()
          {
              $FANNIE_URL = $this->config->get('URL');
              $ret = '';
              $vars = array(
      Severity: Major
      Found in fannie/item/ItemEditorPage.php - About 2 hrs to fix

        Method searchResults has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function searchResults()
            {
                $authorized = false;
                if (FannieAuth::validateUserQuiet('admin')) {
                    $authorized = true;
        Severity: Major
        Found in fannie/item/ItemEditorPage.php - About 2 hrs to fix

          Method javascript_content has 65 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function javascript_content()
              {
                  return <<<JAVASCRIPT
          $(document).ready(function(){
              alterTable();
          Severity: Major
          Found in fannie/item/ItemEditorPage.php - About 2 hrs to fix

            Function editForm has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                private function editForm($upc,$isNew)
                {
                    $FANNIE_PRODUCT_MODULES = $this->getConfiguredModules();
                    $FANNIE_URL = $this->config->get('URL');
                    $shown = array();
            Severity: Minor
            Found in fannie/item/ItemEditorPage.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

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

                private function searchResults()
                {
                    $authorized = false;
                    if (FannieAuth::validateUserQuiet('admin')) {
                        $authorized = true;
            Severity: Minor
            Found in fannie/item/ItemEditorPage.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 searchQuery has 56 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function searchQuery($upc, $numType, $inUseFlag, $store_id)
                {
                    $query = '';
                    $args = array();
                    if (is_numeric($upc)) {
            Severity: Major
            Found in fannie/item/ItemEditorPage.php - About 2 hrs to fix

              Method editorLinksArea has 54 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function editorLinksArea($upc, $isNew, $authorized)
                  {
                      $url = $this->config->get('URL');
                      $self = filter_input(INPUT_SERVER, 'PHP_SELF');
                      $ret = '<p>';
              Severity: Major
              Found in fannie/item/ItemEditorPage.php - About 2 hrs to fix

                Method helpContent has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function helpContent()
                    {
                        $ret = '<p>This tool is for adding or editing an item</p>';
                        if ($this->mode == 'search') {
                            $ret .= '<p>
                Severity: Minor
                Found in fannie/item/ItemEditorPage.php - About 1 hr to fix

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

                      private function saveItem($isNew)
                      {
                          $FANNIE_PRODUCT_MODULES = $this->getConfiguredModules();
                          $FANNIE_URL = $this->config->get('URL');
                  
                  
                  Severity: Minor
                  Found in fannie/item/ItemEditorPage.php - About 1 hr to fix

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

                        private function getConfiguredModules()
                        {
                            $FANNIE_PRODUCT_MODULES = $this->config->get('PRODUCT_MODULES');
                            if (!is_array($FANNIE_PRODUCT_MODULES)) {
                                $FANNIE_PRODUCT_MODULES = array('BaseItemModule' => array('seq'=>0, 'show'=>1, 'expand'=>1));
                    Severity: Minor
                    Found in fannie/item/ItemEditorPage.php - About 1 hr to fix

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

                          private function searchQuery($upc, $numType, $inUseFlag, $store_id)
                          {
                              $query = '';
                              $args = array();
                              if (is_numeric($upc)) {
                      Severity: Minor
                      Found in fannie/item/ItemEditorPage.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 saveItem has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function saveItem($isNew)
                          {
                              $FANNIE_PRODUCT_MODULES = $this->getConfiguredModules();
                              $FANNIE_URL = $this->config->get('URL');
                      
                      
                      Severity: Minor
                      Found in fannie/item/ItemEditorPage.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 multipleResults has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function multipleResults($results)
                          {
                              $FANNIE_URL = $this->config->get('URL');
                              $ret = '<table id="itemSearchResults" class="tablesorter">';
                              $ret .= '<thead><tr>
                      Severity: Minor
                      Found in fannie/item/ItemEditorPage.php - About 1 hr to fix

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

                            private function userCanEdit($upc, $isNew)
                            {
                                $authorized = false;
                                if (FannieAuth::validateUserQuiet('pricechange') || FannieAuth::validateUserQuiet('audited_pricechange')) {
                                    $authorized = true;
                        Severity: Minor
                        Found in fannie/item/ItemEditorPage.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 readinessCheck has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function readinessCheck()
                            {
                                if ($this->config->get('STORE_MODE') != 'HQ') {
                                    return true;
                                } else {
                        Severity: Minor
                        Found in fannie/item/ItemEditorPage.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

                        Avoid too many return statements within this method.
                        Open

                                return $this->editForm($actualUPC, $this->mode === 'new' ? true : false);
                        Severity: Major
                        Found in fannie/item/ItemEditorPage.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return $this->multipleResults($items);
                          Severity: Major
                          Found in fannie/item/ItemEditorPage.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

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

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

                                  public function helpContent()
                                  {
                                      $ret = '<p>This tool is for adding or editing an item</p>';
                                      if ($this->mode == 'search') {
                                          $ret .= '<p>
                              Severity: Minor
                              Found in fannie/item/ItemEditorPage.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

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

                                  function preprocess()
                                  {
                                      $mods = $this->getConfiguredModules();
                              
                                      $this->title = _('Fannie') . ' - ' . _('Item Maintenance');
                              Severity: Minor
                              Found in fannie/item/ItemEditorPage.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