piotrpolak/pepiscms

View on GitHub
pepiscms/application/models/Generic_model.php

Summary

Maintainability
F
6 days
Test Coverage

File Generic_model.php has 622 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

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

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

    class Generic_model extends PEPISCMS_Model implements EntitableInterface, MoveableInterface, AdvancedDataFeedableInterface
    {
        /**
         * Database table name
         *
    Severity: Minor
    Found in pepiscms/application/models/Generic_model.php - About 6 hrs to fix

      Function move has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

          public function move($id, $direction, $table = false, $constraint_field_name = false,
                               $item_order_field_name = 'item_order', $id_field_name = 'id')
          {
              // When no table is specified, taking table from the object
              if (!$table) {
      Severity: Minor
      Found in pepiscms/application/models/Generic_model.php - About 5 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 move has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function move($id, $direction, $table = false, $constraint_field_name = false,
                               $item_order_field_name = 'item_order', $id_field_name = 'id')
          {
              // When no table is specified, taking table from the object
              if (!$table) {
      Severity: Major
      Found in pepiscms/application/models/Generic_model.php - About 3 hrs to fix

        Function applyFilters has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function applyFilters($db, $filters)
            {
                $allowed_conditions = array(
                    'eq' => '=',
                    'ne' => '!=',
        Severity: Minor
        Found in pepiscms/application/models/Generic_model.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 journalingPersistPreSave has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function journalingPersistPreSave($id, $data)
            {
                if (!$id || !$this->getJournalingIsEnabled()) {
                    return false;
                }
        Severity: Minor
        Found in pepiscms/application/models/Generic_model.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 getDistinctAssoc has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getDistinctAssoc($column, $table = false, $pairs = false, $where_conditions = false)
            {
                if (!$table) {
                    $table = $this->getTable();
                }
        Severity: Minor
        Found in pepiscms/application/models/Generic_model.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 applyFilters has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function applyFilters($db, $filters)
            {
                $allowed_conditions = array(
                    'eq' => '=',
                    'ne' => '!=',
        Severity: Major
        Found in pepiscms/application/models/Generic_model.php - About 2 hrs to fix

          Method journalingPersistPreSave has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function journalingPersistPreSave($id, $data)
              {
                  if (!$id || !$this->getJournalingIsEnabled()) {
                      return false;
                  }
          Severity: Minor
          Found in pepiscms/application/models/Generic_model.php - About 1 hr to fix

            Method getAdvancedFeed has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getAdvancedFeed($columns, $offset, $rowcount, $order_by_column, $order, $filters, $extra_param)
                {
                    if (!$columns || $columns == '*') { // TODO Check if $columns == '*' is ok
                        $columns = $this->getTable() . '.*';
                    }
            Severity: Minor
            Found in pepiscms/application/models/Generic_model.php - About 1 hr to fix

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

                  protected function applyWhere($db, $where_conditions)
                  {
                      if ($where_conditions) {
                          foreach ($where_conditions as $key => $condition) {
                              if (!$key || is_numeric($key)) {
              Severity: Minor
              Found in pepiscms/application/models/Generic_model.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 getDistinctAssoc has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getDistinctAssoc($column, $table = false, $pairs = false, $where_conditions = false)
                  {
                      if (!$table) {
                          $table = $this->getTable();
                      }
              Severity: Minor
              Found in pepiscms/application/models/Generic_model.php - About 1 hr to fix

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

                    public function getAdvancedFeed($columns, $offset, $rowcount, $order_by_column, $order, $filters, $extra_param)
                    {
                        if (!$columns || $columns == '*') { // TODO Check if $columns == '*' is ok
                            $columns = $this->getTable() . '.*';
                        }
                Severity: Minor
                Found in pepiscms/application/models/Generic_model.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 getAdvancedFeed has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function getAdvancedFeed($columns, $offset, $rowcount, $order_by_column, $order, $filters, $extra_param)
                Severity: Major
                Found in pepiscms/application/models/Generic_model.php - About 50 mins to fix

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

                      public function move($id, $direction, $table = false, $constraint_field_name = false,
                                           $item_order_field_name = 'item_order', $id_field_name = 'id')
                  Severity: Minor
                  Found in pepiscms/application/models/Generic_model.php - About 45 mins to fix

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

                        public function getAssocPairs($key_column_name, $value_column_name, $table = false, $imitial_array = false,
                                                      $possible_keys = false, $where_conditions = false)
                    Severity: Minor
                    Found in pepiscms/application/models/Generic_model.php - About 45 mins to fix

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

                          public function enableJournaling($journaling_table = false, $include_fields = array(), $exclude_fields = array(),
                                                           $tag = null, $serialization_method = null, $unserialization_method = null)
                      Severity: Minor
                      Found in pepiscms/application/models/Generic_model.php - About 45 mins to fix

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

                            public function journalingGetById($id, $revision_id = false)
                            {
                                $row = $this->getById($id);
                                if ($revision_id && $this->getJournalingIsEnabled()) {
                                    $row_archived = $this->db->select('data_serialized')
                        Severity: Minor
                        Found in pepiscms/application/models/Generic_model.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

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

                            private function _saveByIdFilterData($data, $accepted_post_fields)
                            {
                                // Reading fields that should be nullified when empty
                                $nullify_on_empty_post_fields = $this->getNullifyOnEmptyPostFields();
                        
                        
                        Severity: Minor
                        Found in pepiscms/application/models/Generic_model.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

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

                            public function getAssocPairs($key_column_name, $value_column_name, $table = false, $imitial_array = false,
                                                          $possible_keys = false, $where_conditions = false)
                            {
                                if (!$table) {
                                    $table = $this->getTable();
                        Severity: Minor
                        Found in pepiscms/application/models/Generic_model.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

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

                            public function setMappedFilterFields($fields_array)
                            {
                                if (!$fields_array || count($fields_array) == 0) {
                                    $this->mapped_filter_fields = array();
                                    return true;
                        Severity: Minor
                        Found in pepiscms/application/models/Generic_model.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