bcit-ci/CodeIgniter

View on GitHub
system/database/DB_forge.php

Summary

Maintainability
F
3 days
Test Coverage

File DB_forge.php has 550 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP
Severity: Major
Found in system/database/DB_forge.php - About 1 day to fix

    Function _process_fields has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function _process_fields($create_table = FALSE)
        {
            $fields = array();
    
            foreach ($this->fields as $key => $attributes)
    Severity: Minor
    Found in system/database/DB_forge.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 _process_fields has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function _process_fields($create_table = FALSE)
        {
            $fields = array();
    
            foreach ($this->fields as $key => $attributes)
    Severity: Major
    Found in system/database/DB_forge.php - About 3 hrs to fix

      CI_DB_forge has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      abstract class CI_DB_forge {
      
          /**
           * Database object
           *
      Severity: Minor
      Found in system/database/DB_forge.php - About 2 hrs to fix

        Function create_table has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function create_table($table, $if_not_exists = FALSE, array $attributes = array())
            {
                if ($table === '')
                {
                    show_error('A table name is required for that operation.');
        Severity: Minor
        Found in system/database/DB_forge.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 _process_indexes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function _process_indexes($table)
            {
                $sqls = array();
        
                for ($i = 0, $c = count($this->keys); $i < $c; $i++)
        Severity: Minor
        Found in system/database/DB_forge.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 create_table has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function create_table($table, $if_not_exists = FALSE, array $attributes = array())
            {
                if ($table === '')
                {
                    show_error('A table name is required for that operation.');
        Severity: Minor
        Found in system/database/DB_forge.php - About 1 hr to fix

          Method _create_table has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function _create_table($table, $if_not_exists, $attributes)
              {
                  if ($if_not_exists === TRUE && $this->_create_table_if === FALSE)
                  {
                      if ($this->db->table_exists($table))
          Severity: Minor
          Found in system/database/DB_forge.php - About 1 hr to fix

            Method add_field has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function add_field($field)
                {
                    if (is_string($field))
                    {
                        if ($field === 'id')
            Severity: Minor
            Found in system/database/DB_forge.php - About 1 hr to fix

              Function _attr_unsigned has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function _attr_unsigned(&$attributes, &$field)
                  {
                      if (empty($attributes['UNSIGNED']) OR $attributes['UNSIGNED'] !== TRUE)
                      {
                          return;
              Severity: Minor
              Found in system/database/DB_forge.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

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

                  public function add_column($table, $field, $_after = NULL)
                  {
                      // Work-around for literal column definitions
                      is_array($field) OR $field = array($field);
              
              
              Severity: Minor
              Found in system/database/DB_forge.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 add_field has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function add_field($field)
                  {
                      if (is_string($field))
                      {
                          if ($field === 'id')
              Severity: Minor
              Found in system/database/DB_forge.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 _drop_table has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function _drop_table($table, $if_exists)
                  {
                      $sql = 'DROP TABLE';
              
                      if ($if_exists)
              Severity: Minor
              Found in system/database/DB_forge.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 add_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function add_key($key, $primary = FALSE)
                  {
                      // DO NOT change this! This condition is only applicable
                      // for PRIMARY keys because you can only have one such,
                      // and therefore all fields you add to it will be included
              Severity: Minor
              Found in system/database/DB_forge.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

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

                  protected function _create_table($table, $if_not_exists, $attributes)
                  {
                      if ($if_not_exists === TRUE && $this->_create_table_if === FALSE)
                      {
                          if ($this->db->table_exists($table))
              Severity: Minor
              Found in system/database/DB_forge.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

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

                  public function rename_table($table_name, $new_table_name)
                  {
                      if ($table_name === '' OR $new_table_name === '')
                      {
                          show_error('A table name is required for that operation.');
              Severity: Minor
              Found in system/database/DB_forge.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

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

                  public function drop_table($table_name, $if_exists = FALSE)
                  {
                      if ($table_name === '')
                      {
                          return ($this->db->db_debug) ? $this->db->display_error('db_table_name_required') : FALSE;
              Severity: Minor
              Found in system/database/DB_forge.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

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

                  public function modify_column($table, $field)
                  {
                      // Work-around for literal column definitions
                      is_array($field) OR $field = array($field);
              
              
              Severity: Minor
              Found in system/database/DB_forge.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