bcit-ci/CodeIgniter

View on GitHub
system/helpers/form_helper.php

Summary

Maintainability
F
1 wk
Test Coverage

File form_helper.php has 563 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Function form_dropdown has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

        function form_dropdown($data = '', $options = array(), $selected = array(), $extra = '')
        {
            $defaults = array();
    
            if (is_array($data))
    Severity: Minor
    Found in system/helpers/form_helper.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

    Function form_open has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        function form_open($action = '', $attributes = array(), $hidden = array())
        {
            $CI =& get_instance();
    
            // If no action is provided then set to the current url
    Severity: Minor
    Found in system/helpers/form_helper.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 _parse_form_attributes has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        function _parse_form_attributes($attributes, $default)
        {
            if (is_array($attributes))
            {
                foreach ($default as $key => $val)
    Severity: Minor
    Found in system/helpers/form_helper.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 form_dropdown has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function form_dropdown($data = '', $options = array(), $selected = array(), $extra = '')
        {
            $defaults = array();
    
            if (is_array($data))
    Severity: Major
    Found in system/helpers/form_helper.php - About 2 hrs to fix

      Method form_open has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function form_open($action = '', $attributes = array(), $hidden = array())
          {
              $CI =& get_instance();
      
              // If no action is provided then set to the current url
      Severity: Major
      Found in system/helpers/form_helper.php - About 2 hrs to fix

        Function form_hidden has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            function form_hidden($name, $value = '', $recursing = FALSE)
            {
                static $form;
        
                if ($recursing === FALSE)
        Severity: Minor
        Found in system/helpers/form_helper.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 set_radio has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            function set_radio($field, $value = '', $default = FALSE)
            {
                $CI =& get_instance();
        
                if (isset($CI->form_validation) && is_object($CI->form_validation) && $CI->form_validation->has_rule($field))
        Severity: Minor
        Found in system/helpers/form_helper.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 set_checkbox has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            function set_checkbox($field, $value = '', $default = FALSE)
            {
                $CI =& get_instance();
        
                if (isset($CI->form_validation) && is_object($CI->form_validation) && $CI->form_validation->has_rule($field))
        Severity: Minor
        Found in system/helpers/form_helper.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 set_select has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            function set_select($field, $value = '', $default = FALSE)
            {
                $CI =& get_instance();
        
                if (isset($CI->form_validation) && is_object($CI->form_validation) && $CI->form_validation->has_rule($field))
        Severity: Minor
        Found in system/helpers/form_helper.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 _attributes_to_string has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            function _attributes_to_string($attributes)
            {
                if (empty($attributes))
                {
                    return '';
        Severity: Minor
        Found in system/helpers/form_helper.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 _parse_form_attributes has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function _parse_form_attributes($attributes, $default)
            {
                if (is_array($attributes))
                {
                    foreach ($default as $key => $val)
        Severity: Minor
        Found in system/helpers/form_helper.php - About 1 hr to fix

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

              function form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '')
              {
                  $defaults = array('type' => 'checkbox', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value);
          
                  if (is_array($data) && array_key_exists('checked', $data))
          Severity: Minor
          Found in system/helpers/form_helper.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 form_hidden has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function form_hidden($name, $value = '', $recursing = FALSE)
              {
                  static $form;
          
                  if ($recursing === FALSE)
          Severity: Minor
          Found in system/helpers/form_helper.php - About 1 hr to fix

            Avoid too many return statements within this method.
            Open

                    return ($default === TRUE) ? ' checked="checked"' : '';
            Severity: Major
            Found in system/helpers/form_helper.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return ($default === TRUE) ? ' checked="checked"' : '';
              Severity: Major
              Found in system/helpers/form_helper.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return ($input === $value) ? ' selected="selected"' : '';
                Severity: Major
                Found in system/helpers/form_helper.php - About 30 mins to fix

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

                  if ( ! function_exists('set_checkbox'))
                  {
                      /**
                       * Set Checkbox
                       *
                  Severity: Major
                  Found in system/helpers/form_helper.php and 1 other location - About 7 hrs to fix
                  system/helpers/form_helper.php on lines 806..854

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

                  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 2 locations. Consider refactoring.
                  Open

                  if ( ! function_exists('set_radio'))
                  {
                      /**
                       * Set Radio
                       *
                  Severity: Major
                  Found in system/helpers/form_helper.php and 1 other location - About 7 hrs to fix
                  system/helpers/form_helper.php on lines 754..802

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

                  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 3 locations. Consider refactoring.
                  Open

                  if ( ! function_exists('form_submit'))
                  {
                      /**
                       * Submit Button
                       *
                  Severity: Major
                  Found in system/helpers/form_helper.php and 2 other locations - About 1 hr to fix
                  system/helpers/form_helper.php on lines 222..242
                  system/helpers/form_helper.php on lines 537..557

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

                  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 3 locations. Consider refactoring.
                  Open

                  if ( ! function_exists('form_reset'))
                  {
                      /**
                       * Reset Button
                       *
                  Severity: Major
                  Found in system/helpers/form_helper.php and 2 other locations - About 1 hr to fix
                  system/helpers/form_helper.php on lines 222..242
                  system/helpers/form_helper.php on lines 513..533

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

                  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 3 locations. Consider refactoring.
                  Open

                  if ( ! function_exists('form_input'))
                  {
                      /**
                       * Text Input Field
                       *
                  Severity: Major
                  Found in system/helpers/form_helper.php and 2 other locations - About 1 hr to fix
                  system/helpers/form_helper.php on lines 513..533
                  system/helpers/form_helper.php on lines 537..557

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

                  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