CORE-POS/IS4C

View on GitHub
fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php

Summary

Maintainability
F
1 wk
Test Coverage

File AlertIncident.php has 832 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use COREPOS\Fannie\Plugin\IncidentTracker\notifiers\Email;
use COREPOS\Fannie\Plugin\IncidentTracker\notifiers\Basecamp;

Severity: Major
Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php - About 2 days to fix

    Method get_id_view has 180 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function get_id_view()
        {
            try {
                $row = $this->getIncident($this->id);
            } catch (Exception $ex) {
    Severity: Major
    Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php - About 7 hrs to fix

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

          protected function get_view()
          {
              $settings = $this->config->get('PLUGIN_SETTINGS');
              $table = $settings['IncidentDB'] . $this->connection->sep();
              $query = "SELECT i.*, 
      Severity: Major
      Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php - About 4 hrs to fix

        Method get_new_view has 105 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function get_new_view()
            {
                $settings = $this->config->get('PLUGIN_SETTINGS');
                $prefix = $settings['IncidentDB'] . $this->connection->sep();
        
        
        Severity: Major
        Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php - About 4 hrs to fix

          Method post_handler has 87 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function post_handler()
              {
                  $uid = FannieAuth::getUID($this->current_user);
                  $settings = $this->config->get('PLUGIN_SETTINGS');
                  $this->connection->selectDB($settings['IncidentDB']);
          Severity: Major
          Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php - About 3 hrs to fix

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

                protected function post_handler()
                {
                    $uid = FannieAuth::getUID($this->current_user);
                    $settings = $this->config->get('PLUGIN_SETTINGS');
                    $this->connection->selectDB($settings['IncidentDB']);
            Severity: Minor
            Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.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 get_search_view has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function get_search_view()
                {
                    $settings = $this->config->get('PLUGIN_SETTINGS');
                    $prefix = $settings['IncidentDB'] . $this->connection->sep();
                    $commentP = $this->connection->prepare("
            Severity: Minor
            Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php - About 1 hr to fix

              Method sendNotifications has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function sendNotifications($id)
                  {
                      $this->connection->selectDB($this->config->get('OP_DB'));
                      try {
                          $incident = $this->getIncident($id);
              Severity: Minor
              Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php - About 1 hr to fix

                Method post_id_field_value_handler has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function post_id_field_value_handler()
                    {
                        $settings = $this->config->get('PLUGIN_SETTINGS');
                        $this->connection->selectDB($settings['IncidentDB']);
                        $model = new IncidentsModel($this->connection);
                Severity: Minor
                Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php - About 1 hr to fix

                  Function sendNotifications has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function sendNotifications($id)
                      {
                          $this->connection->selectDB($this->config->get('OP_DB'));
                          try {
                              $incident = $this->getIncident($id);
                  Severity: Minor
                  Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.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 post_id_handler has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function post_id_handler()
                      {
                          $uid = FannieAuth::getUID($this->current_user);
                          $settings = $this->config->get('PLUGIN_SETTINGS');
                          $this->connection->selectDB($settings['IncidentDB']);
                  Severity: Minor
                  Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php - About 1 hr to fix

                    Method post_escalate_handler has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function post_escalate_handler()
                        {
                            $msg = "Alert needing attention\n";
                            $msg .= 'http://key/git/fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php?id=' . $this->escalate . "\n\n";
                    
                    
                    Severity: Minor
                    Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php - About 1 hr to fix

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

                          protected function post_id_field_value_handler()
                          {
                              $settings = $this->config->get('PLUGIN_SETTINGS');
                              $this->connection->selectDB($settings['IncidentDB']);
                              $model = new IncidentsModel($this->connection);
                      Severity: Minor
                      Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.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 get_view has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function get_view()
                          {
                              $settings = $this->config->get('PLUGIN_SETTINGS');
                              $table = $settings['IncidentDB'] . $this->connection->sep();
                              $query = "SELECT i.*, 
                      Severity: Minor
                      Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.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

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

                          protected function post_id_handler()
                          {
                              $uid = FannieAuth::getUID($this->current_user);
                              $settings = $this->config->get('PLUGIN_SETTINGS');
                              $this->connection->selectDB($settings['IncidentDB']);
                      Severity: Minor
                      Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.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

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

                          protected function get_id_view()
                          {
                              try {
                                  $row = $this->getIncident($this->id);
                              } catch (Exception $ex) {
                      Severity: Minor
                      Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.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

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

                          protected function get_new_view()
                          {
                              $settings = $this->config->get('PLUGIN_SETTINGS');
                              $prefix = $settings['IncidentDB'] . $this->connection->sep();
                      
                      
                      Severity: Major
                      Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php and 1 other location - About 6 hrs to fix
                      fannie/modules/plugins2.0/IncidentTracker/PosIncident.php on lines 173..245

                      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 209.

                      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

                              if (!empty($_FILES['img2']['tmp_name']) && file_exists($_FILES['img2']['tmp_name'])) {
                                  $ext = pathinfo($_FILES['img2']['name'], PATHINFO_EXTENSION);
                                  $file = md5(rand());
                                  while (file_exists(__DIR__  . "/image/{$file}.{$ext}")) {
                                      $file = md5(rand());
                      Severity: Major
                      Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php and 3 other locations - About 4 hrs to fix
                      fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php on lines 188..196
                      fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php on lines 197..205
                      fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php on lines 316..324

                      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 167.

                      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

                              if (!empty($_FILES['img1']['tmp_name']) && file_exists($_FILES['img1']['tmp_name'])) {
                                  $ext = pathinfo($_FILES['img1']['name'], PATHINFO_EXTENSION);
                                  $file = md5(rand());
                                  while (file_exists(__DIR__  . "/image/{$file}.{$ext}")) {
                                      $file = md5(rand());
                      Severity: Major
                      Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php and 3 other locations - About 4 hrs to fix
                      fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php on lines 188..196
                      fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php on lines 197..205
                      fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php on lines 325..333

                      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 167.

                      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

                              if (!empty($_FILES['img2']['tmp_name']) && file_exists($_FILES['img2']['tmp_name'])) {
                                  $ext = pathinfo($_FILES['img2']['name'], PATHINFO_EXTENSION);
                                  $file = md5(rand());
                                  while (file_exists(__DIR__  . "/image/{$file}.{$ext}")) {
                                      $file = md5(rand());
                      Severity: Major
                      Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php and 3 other locations - About 4 hrs to fix
                      fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php on lines 188..196
                      fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php on lines 316..324
                      fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php on lines 325..333

                      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 167.

                      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

                              if (!empty($_FILES['img1']['tmp_name']) && file_exists($_FILES['img1']['tmp_name'])) {
                                  $ext = pathinfo($_FILES['img1']['name'], PATHINFO_EXTENSION);
                                  $file = md5(rand());
                                  while (file_exists(__DIR__  . "/image/{$file}.{$ext}")) {
                                      $file = md5(rand());
                      Severity: Major
                      Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php and 3 other locations - About 4 hrs to fix
                      fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php on lines 197..205
                      fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php on lines 316..324
                      fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php on lines 325..333

                      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 167.

                      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

                                                  $body = "**Date**: {$incident['tdate']}\n\n"
                                                      . "**Type**: {$incident['incidentSubType']}\n\n"
                                                      . "**Store**: {$incident['storeName']}\n\n"
                                                      . "**Location**: {$incident['incidentLocation']}\n\n"
                                                      . "**Entered By**: {$incident['userName']}\n\n"
                      Severity: Minor
                      Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php and 1 other location - About 55 mins to fix
                      fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php on lines 241..249

                      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 99.

                      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

                                                  $body = "**Date**: {$incident['tdate']}\n\n"
                                                      . "**Type**: {$incident['incidentSubType']}\n\n"
                                                      . "**Store**: {$incident['storeName']}\n\n"
                                                      . "**Location**: {$incident['incidentLocation']}\n\n"
                                                      . "**Entered By**: {$incident['userName']}\n\n"
                      Severity: Minor
                      Found in fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php and 1 other location - About 55 mins to fix
                      fannie/modules/plugins2.0/IncidentTracker/AlertIncident.php on lines 358..366

                      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 99.

                      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