CORE-POS/IS4C

View on GitHub
fannie/modules/plugins2.0/DeliInventory/DIPage2.php

Summary

Maintainability
F
5 days
Test Coverage

File DIPage2.php has 470 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use COREPOS\Fannie\API\lib\Store;
use COREPOS\Fannie\API\lib\FannieUI;

Severity: Minor
Found in fannie/modules/plugins2.0/DeliInventory/DIPage2.php - About 7 hrs to fix

    Method get_view has 170 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function get_view()
        {
            $authorized = false;
            if (FannieAuth::validateUserQuiet('ordering_edit')) {
                $authorized = true;
    Severity: Major
    Found in fannie/modules/plugins2.0/DeliInventory/DIPage2.php - About 6 hrs to fix

      Function get_view has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function get_view()
          {
              $authorized = false;
              if (FannieAuth::validateUserQuiet('ordering_edit')) {
                  $authorized = true;
      Severity: Minor
      Found in fannie/modules/plugins2.0/DeliInventory/DIPage2.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 addItemForm has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function addItemForm($storeID)
          {
              $vendors = new VendorsModel($this->connection);
              $vOpts = $vendors->toOptions();
              $catP = $this->connection->prepare("SELECT deliCategoryID, name FROM DeliCategories WHERE storeID=? ORDER BY name");
      Severity: Major
      Found in fannie/modules/plugins2.0/DeliInventory/DIPage2.php - About 2 hrs to fix

        Method get_print_view has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function get_print_view()
            {
                $catP = $this->connection->prepare("SELECT name FROM DeliCategories WHERE deliCategoryID=?");
                $name = $this->connection->getValue($catP, array($this->print));
                $itemP = $this->connection->prepare("SELECT i.*, v.vendorName
        Severity: Minor
        Found in fannie/modules/plugins2.0/DeliInventory/DIPage2.php - About 1 hr to fix

          Method post_id_handler has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function post_id_handler()
              {
                  $now = $this->connection->now();
                  if (FormLib::get('name', false) !== false) {
                      $upP = $this->connection->prepare("UPDATE deliInventoryCat SET item=?, modified={$now} WHERE id=?");
          Severity: Minor
          Found in fannie/modules/plugins2.0/DeliInventory/DIPage2.php - About 1 hr to fix

            Method addCategoryForm has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function addCategoryForm()
                {
                    return <<<HTML
            <div class="panel panel-default">
                <div class="panel panel-heading">Add Category</div>
            Severity: Minor
            Found in fannie/modules/plugins2.0/DeliInventory/DIPage2.php - About 1 hr to fix

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

                  protected function post_id_handler()
                  {
                      $now = $this->connection->now();
                      if (FormLib::get('name', false) !== false) {
                          $upP = $this->connection->prepare("UPDATE deliInventoryCat SET item=?, modified={$now} WHERE id=?");
              Severity: Minor
              Found in fannie/modules/plugins2.0/DeliInventory/DIPage2.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

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                  protected function get_print_view()
                  {
                      $catP = $this->connection->prepare("SELECT name FROM DeliCategories WHERE deliCategoryID=?");
                      $name = $this->connection->getValue($catP, array($this->print));
                      $itemP = $this->connection->prepare("SELECT i.*, v.vendorName
              Severity: Major
              Found in fannie/modules/plugins2.0/DeliInventory/DIPage2.php and 1 other location - About 4 hrs to fix
              fannie/modules/plugins2.0/DeliInventory/DIPage.php on lines 281..322

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 179.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  protected function post_newItem_handler()
                  {
                      $storeID = Store::getIdByIp();
                      $storeID=2;
                      $catP = $this->connection->prepare("SELECT name FROM DeliCategories WHERE deliCategoryID=?");
              Severity: Major
              Found in fannie/modules/plugins2.0/DeliInventory/DIPage2.php and 1 other location - About 4 hrs to fix
              fannie/modules/plugins2.0/DeliInventory/DIPage.php on lines 96..119

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 179.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                  protected function post_seq_catID_handler()
                  {
                      $catP = $this->connection->prepare("SELECT name FROM DeliCategories WHERE deliCategoryID=?");
                      $catName = $this->connection->getValue($catP, array($this->catID));
                      $upP = $this->connection->prepare("UPDATE deliInventoryCat SET seq=?, categoryID=?, category=? WHERE id=?");
              Severity: Major
              Found in fannie/modules/plugins2.0/DeliInventory/DIPage2.php and 1 other location - About 2 hrs to fix
              fannie/modules/plugins2.0/DeliInventory/DIPage.php on lines 45..60

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 136.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  private function addItemForm($storeID)
                  {
                      $vendors = new VendorsModel($this->connection);
                      $vOpts = $vendors->toOptions();
                      $catP = $this->connection->prepare("SELECT deliCategoryID, name FROM DeliCategories WHERE storeID=? ORDER BY name");
              Severity: Major
              Found in fannie/modules/plugins2.0/DeliInventory/DIPage2.php and 1 other location - About 2 hrs to fix
              fannie/modules/plugins2.0/DeliInventory/DIPage.php on lines 222..279

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 133.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                  protected function get_catDown_handler()
                  {
                      $upP = $this->connection->prepare("UPDATE DeliCategories SET seq=seq+1 WHERE deliCategoryID=?");
                      $this->connection->execute($upP, array($this->catDown));
                      $nameP = $this->connection->prepare('SELECT name FROM DeliCategories WHERE deliCategoryID=?');
              Severity: Major
              Found in fannie/modules/plugins2.0/DeliInventory/DIPage2.php and 3 other locations - About 1 hr to fix
              fannie/modules/plugins2.0/DeliInventory/DIPage.php on lines 121..130
              fannie/modules/plugins2.0/DeliInventory/DIPage.php on lines 132..141
              fannie/modules/plugins2.0/DeliInventory/DIPage2.php on lines 121..130

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 108.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                  protected function get_catUp_handler()
                  {
                      $upP = $this->connection->prepare("UPDATE DeliCategories SET seq=seq-1 WHERE deliCategoryID=?");
                      $this->connection->execute($upP, array($this->catUp));
                      $nameP = $this->connection->prepare('SELECT name FROM DeliCategories WHERE deliCategoryID=?');
              Severity: Major
              Found in fannie/modules/plugins2.0/DeliInventory/DIPage2.php and 3 other locations - About 1 hr to fix
              fannie/modules/plugins2.0/DeliInventory/DIPage.php on lines 121..130
              fannie/modules/plugins2.0/DeliInventory/DIPage.php on lines 132..141
              fannie/modules/plugins2.0/DeliInventory/DIPage2.php on lines 132..141

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 108.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  protected function get_clear_handler()
                  {
                      $storeID=2;
                      $saveP = $this->connection->prepare("INSERT INTO DeliSnapshots
                          (snapShotDate, id, item, orderno, units, cases, fraction,
              Severity: Major
              Found in fannie/modules/plugins2.0/DeliInventory/DIPage2.php and 1 other location - About 1 hr to fix
              fannie/modules/plugins2.0/DeliInventory/DIPage.php on lines 25..43

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 102.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              There are no issues that match your filters.

              Category
              Status