piotrpolak/pepiscms

View on GitHub
pepiscms/application/libraries/DataGrid.php

Summary

Maintainability
F
1 wk
Test Coverage

Function generate has a Cognitive Complexity of 138 (exceeds 5 allowed). Consider refactoring.
Open

    public function generate($extra_param = false)
    {
        $output = '';

        $page = $this->input->getParam('page');
Severity: Minor
Found in pepiscms/application/libraries/DataGrid.php - About 2 days 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

File DataGrid.php has 811 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * PepisCMS
 *
Severity: Major
Found in pepiscms/application/libraries/DataGrid.php - About 1 day to fix

    Function generateFilters has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
    Open

        public function generateFilters($page = false, $order_by = false, $order = false, $applied_filter_values = -1)
        {
            $filters_output = '';
    
            if ($applied_filter_values == -1) {
    Severity: Minor
    Found in pepiscms/application/libraries/DataGrid.php - About 1 day 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

    DataGrid has 48 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class DataGrid extends ContainerAware
    {
        /**
         * Basic search filter
         */
    Severity: Minor
    Found in pepiscms/application/libraries/DataGrid.php - About 6 hrs to fix

      Method generate has 159 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function generate($extra_param = false)
          {
              $output = '';
      
              $page = $this->input->getParam('page');
      Severity: Major
      Found in pepiscms/application/libraries/DataGrid.php - About 6 hrs to fix

        Method generateFilters has 82 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function generateFilters($page = false, $order_by = false, $order = false, $applied_filter_values = -1)
            {
                $filters_output = '';
        
                if ($applied_filter_values == -1) {
        Severity: Major
        Found in pepiscms/application/libraries/DataGrid.php - About 3 hrs to fix

          Function generatePagination has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              private function generatePagination($no_of_pages, $order_by, $order, $applied_filter_values, $page)
              {
                  if ($no_of_pages < 1) {
                      return '';
                  }
          Severity: Minor
          Found in pepiscms/application/libraries/DataGrid.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

          Function encodeFiltersString has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function encodeFiltersString($filters)
              {
                  if (!is_array($filters)) {
                      return false;
                  }
          Severity: Minor
          Found in pepiscms/application/libraries/DataGrid.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 getFiltersForDataFeed has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getFiltersForDataFeed()
              {
                  $pairs = $this->getFilterPairs();
          
                  $applied_filter_values = array(); // For links and user interface
          Severity: Minor
          Found in pepiscms/application/libraries/DataGrid.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 generatePagination has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function generatePagination($no_of_pages, $order_by, $order, $applied_filter_values, $page)
              {
                  if ($no_of_pages < 1) {
                      return '';
                  }
          Severity: Minor
          Found in pepiscms/application/libraries/DataGrid.php - About 1 hr to fix

            Method addColumnByDefinition has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function addColumnByDefinition($column, $key = false)
                {
                    $defaults = $this->getFieldDefaults();
                    if (!isset($column['filter_condition']) && isset($column['filter_type'])) {
                        $defaults['filter_condition'] = $this->getDefaultFilterConditionByFilterType($column['filter_type']);
            Severity: Minor
            Found in pepiscms/application/libraries/DataGrid.php - About 1 hr to fix

              Method getFieldDefaults has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getFieldDefaults()
                  {
                      $defaults = array();
                      $defaults['field'] = false; // Field name
                      $defaults['label'] = false; // Field label
              Severity: Minor
              Found in pepiscms/application/libraries/DataGrid.php - About 1 hr to fix

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

                    public function addColumnByDefinition($column, $key = false)
                    {
                        $defaults = $this->getFieldDefaults();
                        if (!isset($column['filter_condition']) && isset($column['filter_type'])) {
                            $defaults['filter_condition'] = $this->getDefaultFilterConditionByFilterType($column['filter_type']);
                Severity: Minor
                Found in pepiscms/application/libraries/DataGrid.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 generateLink has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    private static function generateLink($base_url, $page = 1, $order_by = false, $order = false, $filters = false)
                    {
                        $url = $base_url;
                        if ($page > 1) {
                            $url .= '/page-' . $page;
                Severity: Minor
                Found in pepiscms/application/libraries/DataGrid.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 addFilter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function addFilter($label, $field = false, $filter_type = self::FILTER_BASIC, $filter_values = false, $filter_condition = false)
                    {
                        if (!is_array($label)) {
                            if (!$filter_condition) {
                                $filter_condition = $this->getDefaultFilterConditionByFilterType($filter_type);
                Severity: Minor
                Found in pepiscms/application/libraries/DataGrid.php - About 55 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

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

                    private static function generateLink($base_url, $page = 1, $order_by = false, $order = false, $filters = false)
                Severity: Minor
                Found in pepiscms/application/libraries/DataGrid.php - About 35 mins to fix

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

                      public function addFilter($label, $field = false, $filter_type = self::FILTER_BASIC, $filter_values = false, $filter_condition = false)
                  Severity: Minor
                  Found in pepiscms/application/libraries/DataGrid.php - About 35 mins to fix

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

                        private function generatePagination($no_of_pages, $order_by, $order, $applied_filter_values, $page)
                    Severity: Minor
                    Found in pepiscms/application/libraries/DataGrid.php - About 35 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status