webcol/Calima

View on GitHub
Sistema/Ayudantes/CFPHPFormularios.php

Summary

Maintainability
F
4 days
Test Coverage

File CFPHPFormularios.php has 438 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/*
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Severity: Minor
Found in Sistema/Ayudantes/CFPHPFormularios.php - About 6 hrs to fix

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

    class CFPHPFormularios
    {
        /*
         * Form configuration. It don't need description
         */
    Severity: Minor
    Found in Sistema/Ayudantes/CFPHPFormularios.php - About 2 hrs to fix

      Method validateInput has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function validateInput($data) {
              // Obtaining value send by user
              $readValue = $this->getData($data['name']);
      
              // Empty/not send and required?
      Severity: Major
      Found in Sistema/Ayudantes/CFPHPFormularios.php - About 2 hrs to fix

        Function validateInput has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            private function validateInput($data) {
                // Obtaining value send by user
                $readValue = $this->getData($data['name']);
        
                // Empty/not send and required?
        Severity: Minor
        Found in Sistema/Ayudantes/CFPHPFormularios.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 log has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            private function log($message, $data = array()) {
                if ($this->logErrors) {
                    // Try to get a name (label or name)
                    if (class_exists('kw')) {
                        if (isset($data['label'])) $this->errors .= 'Found an error in field' . ': "' . $data['label'] . '": ';
        Severity: Minor
        Found in Sistema/Ayudantes/CFPHPFormularios.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 showForm has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function showForm() {
                // Loading all arrays
                $toShow = $this->content;
                
                // Showing form
        Severity: Minor
        Found in Sistema/Ayudantes/CFPHPFormularios.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 showForm has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function showForm() {
                // Loading all arrays
                $toShow = $this->content;
                
                // Showing form
        Severity: Minor
        Found in Sistema/Ayudantes/CFPHPFormularios.php - About 1 hr to fix

          Method addNumber has 10 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function addNumber($label = '', $name = '', $value = '', $range = false, $required = false, $min = '', $max = '', $step = '',  $placeholder = '',  $attributes = array()) {
          Severity: Major
          Found in Sistema/Ayudantes/CFPHPFormularios.php - About 1 hr to fix

            Method addDate has 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function addDate($label = '', $name = '', $value = '', $required = false, $min = '', $max = '', $step = '',  $placeholder = '',  $attributes = array()) {
            Severity: Major
            Found in Sistema/Ayudantes/CFPHPFormularios.php - About 1 hr to fix

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

                  private function showSelect($data, $values, $selected = null) {
                      $r = '<select ';
                          // Convert array to input string
                          foreach ($data as $attr=>$value) {
                              $r .= $attr.'="'.$value.'" ';
              Severity: Minor
              Found in Sistema/Ayudantes/CFPHPFormularios.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 validateArray has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function validateArray($values, $value, $data = array()) {
                      if (is_array($values)) {
                          // Is array (serach all "$value" in "$values"
                          if (!array_key_exists($value, $values)) {
                              if (is_array($value)) {
              Severity: Minor
              Found in Sistema/Ayudantes/CFPHPFormularios.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 validate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function validate() {
                      $this->error_list = ''; // Clean error list
                      $total = 0; // Total counted params
                      $success = 0; // Total correct
                      
              Severity: Minor
              Found in Sistema/Ayudantes/CFPHPFormularios.php - About 1 hr to fix

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

                    public function validate() {
                        $this->error_list = ''; // Clean error list
                        $total = 0; // Total counted params
                        $success = 0; // Total correct
                        
                Severity: Minor
                Found in Sistema/Ayudantes/CFPHPFormularios.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 addInput has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function addInput($label = '', $type = 'text', $name = '', $value = '', $required = false, $placeholder = '',  $attributes = array()) {
                Severity: Major
                Found in Sistema/Ayudantes/CFPHPFormularios.php - About 50 mins to fix

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

                      public function addSelect($label = '', $name = '', $values = '', $selected = null, $required = false, $multiple = false, $attributes = array()) {
                  Severity: Major
                  Found in Sistema/Ayudantes/CFPHPFormularios.php - About 50 mins to fix

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

                        public function addRadio($label = '', $name = '', $values = array(), $selected = null, $required = false, $attributes = array()) {
                    Severity: Minor
                    Found in Sistema/Ayudantes/CFPHPFormularios.php - About 45 mins to fix

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

                          public function addCheck($label = '', $name = '', $value = '', $required = false, $attributes = array()) {
                      Severity: Minor
                      Found in Sistema/Ayudantes/CFPHPFormularios.php - About 35 mins to fix

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

                            public function addTextArea($label = '', $name = '', $value = '', $required = false, $attributes = array()) {
                        Severity: Minor
                        Found in Sistema/Ayudantes/CFPHPFormularios.php - About 35 mins to fix

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

                              public function addDate($label = '', $name = '', $value = '', $required = false, $min = '', $max = '', $step = '',  $placeholder = '',  $attributes = array()) {
                                  // Creating main data
                                  $data = array(
                                      'type' => 'date',
                                      'name' => $name,
                          Severity: Minor
                          Found in Sistema/Ayudantes/CFPHPFormularios.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 showRadio has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private function showRadio($data, $values, $selected) {        
                                  // Primero generamos un esquema
                                  $base = '<label><input type="radio"';
                                  
                                  // Asignamos las claves conviritiendo el array
                          Severity: Minor
                          Found in Sistema/Ayudantes/CFPHPFormularios.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 addNumber has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function addNumber($label = '', $name = '', $value = '', $range = false, $required = false, $min = '', $max = '', $step = '',  $placeholder = '',  $attributes = array()) {
                                  // Creating main data
                                  $data = array(
                                      'type' => (! $range) ? 'number' : 'range',
                                      'name' => $name,
                          Severity: Minor
                          Found in Sistema/Ayudantes/CFPHPFormularios.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

                          Avoid too many return statements within this method.
                          Open

                                              return false;
                          Severity: Major
                          Found in Sistema/Ayudantes/CFPHPFormularios.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    return false;
                            Severity: Major
                            Found in Sistema/Ayudantes/CFPHPFormularios.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                  return false;
                              Severity: Major
                              Found in Sistema/Ayudantes/CFPHPFormularios.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                    return false;
                                Severity: Major
                                Found in Sistema/Ayudantes/CFPHPFormularios.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                      return false;
                                  Severity: Major
                                  Found in Sistema/Ayudantes/CFPHPFormularios.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                            return true;
                                    Severity: Major
                                    Found in Sistema/Ayudantes/CFPHPFormularios.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                          return false;
                                      Severity: Major
                                      Found in Sistema/Ayudantes/CFPHPFormularios.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                            return false;
                                        Severity: Major
                                        Found in Sistema/Ayudantes/CFPHPFormularios.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                              return false;
                                          Severity: Major
                                          Found in Sistema/Ayudantes/CFPHPFormularios.php - About 30 mins to fix

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

                                                private function showStartForm() {
                                                    $r = '<form ';
                                                    if ($this->action!= '') $r .= 'action="'.$this->action.'" ';
                                                    if ($this->method != '') $r .= 'method="'.$this->method .'" ';
                                                    if ($this->name != '') $r .= 'name="'.$this->name .'" ';
                                            Severity: Minor
                                            Found in Sistema/Ayudantes/CFPHPFormularios.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

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

                                                public function addSubmit($name = '', $value = '', $attributes = array()) {
                                                    $data = array(
                                                        'type' => 'submit',
                                                        'name' => $name,
                                                        'value' => $value
                                            Severity: Minor
                                            Found in Sistema/Ayudantes/CFPHPFormularios.php and 1 other location - About 30 mins to fix
                                            Sistema/Ayudantes/CFPHPFormularios.php on lines 833..845

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

                                            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

                                                public function addButton($value = '', $onClick = '', $attributes = array()) {
                                                    $data = array(
                                                        'type' => 'button',
                                                        'value' => $value,
                                                        'onClick' => $onClick
                                            Severity: Minor
                                            Found in Sistema/Ayudantes/CFPHPFormularios.php and 1 other location - About 30 mins to fix
                                            Sistema/Ayudantes/CFPHPFormularios.php on lines 810..824

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

                                            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