EMSL-MSC/pacifica-reporting

View on GitHub
application/controllers/Group.php

Summary

Maintainability
F
3 days
Test Coverage

File Group.php has 363 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Pacifica
 *
 * Pacifica is an open-source data management framework designed
Severity: Minor
Found in application/controllers/Group.php - About 4 hrs to fix

    Method view has 117 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function view(
            $object_type = false,
            $time_range = false,
            $start_date = false,
            $end_date = false,
    Severity: Major
    Found in application/controllers/Group.php - About 4 hrs to fix

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

          private function _get_reporting_info_list_base(
              $object_type,
              $group_id,
              $time_basis,
              $time_range,
      Severity: Minor
      Found in application/controllers/Group.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 _get_reporting_info_list_base has 91 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function _get_reporting_info_list_base(
              $object_type,
              $group_id,
              $time_basis,
              $time_range,
      Severity: Major
      Found in application/controllers/Group.php - About 3 hrs to fix

        Function view has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            public function view(
                $object_type = false,
                $time_range = false,
                $start_date = false,
                $end_date = false,
        Severity: Minor
        Found in application/controllers/Group.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 __construct has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __construct()
            {
                parent::__construct();
                $this->load->model('Group_info_model', 'gm');
                $this->load->model('Summary_api_model', 'summary');
        Severity: Minor
        Found in application/controllers/Group.php - About 1 hr to fix

          Method _get_reporting_info_list_base has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  $object_type,
                  $group_id,
                  $time_basis,
                  $time_range,
                  $start_date = false,
          Severity: Major
          Found in application/controllers/Group.php - About 1 hr to fix

            Method get_reporting_info_list has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    $object_type,
                    $group_id,
                    $time_basis = false,
                    $time_range = false,
                    $start_date = false,
            Severity: Major
            Found in application/controllers/Group.php - About 50 mins to fix

              Method get_reporting_info_list_no_timeline has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      $object_type,
                      $group_id,
                      $time_basis = false,
                      $time_range = false,
                      $start_date = false,
              Severity: Minor
              Found in application/controllers/Group.php - About 45 mins to fix

                Consider simplifying this complex logical expression.
                Open

                        if (!empty($group_info) || !$group_info['time_list']['earliest'] || !$group_info['time_list']['latest']) {
                            $item_list    = $group_info['item_list'];
                            $options_list = $group_info['options_list'];
                            $available_time_range = $group_info['time_list'];
                            if ($time_range && $time_range !== $options_list['time_range']) {
                Severity: Major
                Found in application/controllers/Group.php - About 40 mins to fix

                  Method view has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          $object_type = false,
                          $time_range = false,
                          $start_date = false,
                          $end_date = false,
                          $time_basis = false
                  Severity: Minor
                  Found in application/controllers/Group.php - About 35 mins to fix

                    Function get_transaction_list_details has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function get_transaction_list_details()
                        {
                            if ($this->input->post()) {
                                $transaction_list = $this->input->post();
                            } else if ($this->input->is_ajax_request() || file_get_contents('php://input')) {
                    Severity: Minor
                    Found in application/controllers/Group.php - About 35 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

                                    $times = array(
                                              'start_date'                => $start_date_object->format('Y-m-d H:i:s'),
                                              'end_date'                  => $end_date_object->format('Y-m-d H:i:s'),
                                              'earliest'                  => $earliest_available_object->format('Y-m-d H:i:s'),
                                              'latest'                    => $latest_available_object->format('Y-m-d H:i:s'),
                    Severity: Minor
                    Found in application/controllers/Group.php and 1 other location - About 45 mins to fix
                    application/helpers/time_helper.php on lines 321..332

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

                    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