awsmug/torro-forms

View on GitHub

Showing 375 of 503 total issues

File rest-element-types-controller.php has 316 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * REST element types controller class
 *
 * @package TorroForms

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

        private function handle_save_request( $form ) {
            $this->current_form = $form;
    
            $mappings = array(
                'forms'            => array(
    Severity: Minor
    Found in src/db-objects/forms/form-edit-page-handler.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 show_results has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        public function show_results( $results, $form, $args = array() ) {
            $tabs = array();
    
            $elements = $this->module->manager()->forms()->get_child_manager( 'containers' )->get_child_manager( 'elements' );
    
    
    Severity: Minor
    Found in src/modules/evaluators/element-responses.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 upgrade_legacy_settings has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function upgrade_legacy_settings() {
            $prefix = $this->get_prefix();
    
            $general_mappings = array(
                'modules'        => array( $prefix . 'settings_general_modules', 'modules' ),
    Severity: Major
    Found in src/components/legacy-upgrades.php - About 3 hrs to fix

      Function get_meta_fields has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function get_meta_fields() {
              $fields = array();
      
              foreach ( $this->submodules as $slug => $submodule ) {
                  if ( ! is_a( $submodule, Meta_Submodule_Interface::class ) ) {
      Severity: Minor
      Found in src/modules/submodule-registry-trait.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 get_meta_fields has 85 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function get_meta_fields() {
              $meta_fields = $this->_get_meta_fields();
      
              unset( $meta_fields['enabled'] );
      
      
      Severity: Major
      Found in src/modules/actions/redirection.php - About 3 hrs to fix

        Element_Type has 28 functions (exceeds 20 allowed). Consider refactoring.
        Open

        abstract class Element_Type {
        
            /**
             * Error code to use when the error says the field is required.
             *
        Severity: Minor
        Found in src/db-objects/elements/element-types/element-type.php - About 3 hrs to fix

          Method handle has 82 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function handle( $submission, $form ) {
                  $notifications = $this->get_form_option( $form->id, 'notifications', array() );
                  if ( empty( $notifications ) ) {
                      return true;
                  }
          Severity: Major
          Found in src/modules/actions/email-notifications.php - About 3 hrs to fix

            Method can_access has 82 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function can_access( $form, $submission = null ) {
                    if ( $this->get_form_option( $form->id, 'prevent_edit_others_submission', true ) && $submission ) {
                        $others_submission_error = new WP_Error( 'others_submission', __( 'You do not have access to this form submission.', 'torro-forms' ) );
                        
                        $skip_further_checks = false;
            Severity: Major
            Found in src/modules/access-controls/user-identification.php - About 3 hrs to fix

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

                  protected function maybe_clean_count_cache( $new_db_object, $old_db_object ) {
                      $delete_user_count = false;
                      $delete_form_count = false;
              
                      if ( null === $new_db_object || null === $old_db_object || $new_db_object->status !== $old_db_object->status ) {
              Severity: Minor
              Found in src/db-objects/submissions/submission-manager.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 get_chart_json has 78 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function get_chart_json( $form, $id, $x_values, $y_values ) {
                      $display_mode = $this->get_form_option( $form->id, 'display_mode', 'bar' );
              
                      if ( 'bar' === $display_mode ) {
                          $data_point_labels = $this->get_form_option( $form->id, 'data_point_labels', 'none' );
              Severity: Major
              Found in src/modules/evaluators/element-responses.php - About 3 hrs to fix

                Method get_settings_fields has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function get_settings_fields() {
                        $settings_fields = parent::get_settings_fields();
                
                        $domain = wp_parse_url( home_url( '/' ), PHP_URL_HOST );
                        if ( ! $domain ) {
                Severity: Major
                Found in src/modules/access-controls/members.php - About 3 hrs to fix

                  File submission-manager.php has 292 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  /**
                   * Submission manager class
                   *
                   * @package TorroForms
                  Severity: Minor
                  Found in src/db-objects/submissions/submission-manager.php - About 3 hrs to fix

                    Method maybe_show_evaluation_results has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function maybe_show_evaluation_results( $submissions ) {
                            if ( empty( $_GET['form_id'] ) ) { // WPCS: CSRF OK.
                                return;
                            }
                    
                    
                    Severity: Major
                    Found in src/modules/evaluators/module.php - About 2 hrs to fix

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

                          public function validate_field( $value, $element, $submission ) {
                              $settings = $this->get_settings( $element );
                      
                              $value = trim( (string) $value );
                      
                      
                      Severity: Minor
                      Found in src/db-objects/elements/element-types/base/textfield.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 show_results has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function show_results( $results, $form, $args = array() ) {
                              $args = wp_parse_args(
                                  $args,
                                  array(
                                      'total' => true,
                      Severity: Minor
                      Found in src/modules/evaluators/participation.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 parse_where has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function parse_where() {
                              list( $where, $args ) = parent::parse_where();
                      
                              list( $where, $args ) = $this->parse_default_where_field( $where, $args, 'form_id', 'form_id', '%d', 'absint', true );
                      
                      
                      Severity: Minor
                      Found in src/db-objects/containers/container-query.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 maybe_start_session has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function maybe_start_session() {
                              global $wp_the_query;
                      
                              // No need to start a session twice or in case we cannot start it anyway.
                              if ( isset( $_SESSION ) || headers_sent() ) {
                      Severity: Minor
                      Found in src/db-objects/forms/form-manager.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

                      File form-frontend-output-handler.php has 281 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      <?php
                      /**
                       * Form frontend output handler class
                       *
                       * @package TorroForms
                      Severity: Minor
                      Found in src/db-objects/forms/form-frontend-output-handler.php - About 2 hrs to fix

                        Method get_fields has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function get_fields() {
                                $fields = array(
                                    'form_id'     => array(
                                        'section'      => 'associated_data',
                                        'type'         => 'autocomplete',
                        Severity: Major
                        Found in src/db-objects/submissions/submission-edit-page.php - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language