piotrpolak/pepiscms

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

Summary

Maintainability
F
6 days
Test Coverage

File FormBuilder.php has 871 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * PepisCMS
 *
Severity: Major
Found in pepiscms/application/libraries/FormBuilder.php - About 2 days to fix

    FormBuilder has 81 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class FormBuilder extends ContainerAware
    {
        const POST_ID_FIELD_NAME = 'form_builder_id';
    
        /**
    Severity: Major
    Found in pepiscms/application/libraries/FormBuilder.php - About 1 day to fix

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

          public function generate()
          {
              $this->generateSetNoCacheHeaders();
      
              // Default value
      Severity: Minor
      Found in pepiscms/application/libraries/FormBuilder.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 addFieldByDefinition has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public function addFieldByDefinition($field)
          {
              if (!isset($field['field']) || !$field['field']) {
                  return false;
              }
      Severity: Minor
      Found in pepiscms/application/libraries/FormBuilder.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 generate has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function generate()
          {
              $this->generateSetNoCacheHeaders();
      
              // Default value
      Severity: Minor
      Found in pepiscms/application/libraries/FormBuilder.php - About 1 hr to fix

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

            private function generateHandleFileUpload(&$save_array)
            {
                if (count($this->file_upload_fields) == 0) {
                    return;
                }
        Severity: Minor
        Found in pepiscms/application/libraries/FormBuilder.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 addFieldByDefinition has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function addFieldByDefinition($field)
            {
                if (!isset($field['field']) || !$field['field']) {
                    return false;
                }
        Severity: Minor
        Found in pepiscms/application/libraries/FormBuilder.php - About 1 hr to fix

          Method getFieldDefaults has 37 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/FormBuilder.php - About 1 hr to fix

            Function generateForeignKeyFetchObjectValues has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                private function generateForeignKeyFetchObjectValues($field)
                {
                    // Resolving FOREIGN_KEY_MANY_TO_MANY relationship for a valid definition
                    if ($field['foreign_key_relationship_type'] == FormBuilder::FOREIGN_KEY_MANY_TO_MANY
                        && $field['foreign_key_junction_table']
            Severity: Minor
            Found in pepiscms/application/libraries/FormBuilder.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 deleteFileIfUserFlagSelected has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                private function deleteFileIfUserFlagSelected(&$save_array, $upload_field_name)
                {
                    $wish_to_delete_file = $this->doesUserWishToDeleteFile($upload_field_name);
                    if ($wish_to_delete_file) {
                        $file_name_to_delete = $this->generateComputeFileField($upload_field_name);
            Severity: Minor
            Found in pepiscms/application/libraries/FormBuilder.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 generateHandleFileUpload has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function generateHandleFileUpload(&$save_array)
                {
                    if (count($this->file_upload_fields) == 0) {
                        return;
                    }
            Severity: Minor
            Found in pepiscms/application/libraries/FormBuilder.php - About 1 hr to fix

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

                  public function addField($field, $label = false, $type = false, $default_value = false, $rules = false, $values = false)
              Severity: Minor
              Found in pepiscms/application/libraries/FormBuilder.php - About 45 mins to fix

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

                    private function generateRecreateObjectFromSaveArray($save_array)
                    {
                        // If there were no object, lets generate it from a dummy class to prevent useless errors
                        if (!$this->object) {
                            $this->object = new stdClass();
                Severity: Minor
                Found in pepiscms/application/libraries/FormBuilder.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 generateHandleForeignKeyManyToManyUpdate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function generateHandleForeignKeyManyToManyUpdate(&$save_array)
                    {
                        foreach ($this->fields as $field) {
                            // As we are already looping, lets do some magic
                            if ($field['foreign_key_table']
                Severity: Minor
                Found in pepiscms/application/libraries/FormBuilder.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 generateForeignKeyFillFieldPossibleValues has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function generateForeignKeyFillFieldPossibleValues(&$field)
                    {
                        $should_fetch = false;
                        if (!$field['input_is_editable']) {
                            // is_array is required for multiple checkbox fields, etc - avoiding errors
                Severity: Minor
                Found in pepiscms/application/libraries/FormBuilder.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 handleForeignKeys has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function handleForeignKeys()
                    {
                        foreach ($this->fields as &$field) {
                            if ($field['foreign_key_table']) {
                                if ($this->getId()) {
                Severity: Minor
                Found in pepiscms/application/libraries/FormBuilder.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 generateForeignKeyManyToManyDoInsert has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function generateForeignKeyManyToManyDoInsert($save_id_values, $field, $where_conditions)
                    {
                        foreach ($save_id_values as $right_id) {
                            // There is no value specified, skip the cycle
                            if (!$right_id) {
                Severity: Minor
                Found in pepiscms/application/libraries/FormBuilder.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