awsmug/torro-forms

View on GitHub
src/modules/actions/email-notifications.php

Summary

Maintainability
F
4 days
Test Coverage

File email-notifications.php has 443 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Email notifications action class
 *
 * @package TorroForms
Severity: Minor
Found in src/modules/actions/email-notifications.php - About 6 hrs to fix

    Method register_template_tag_handlers has 161 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function register_template_tag_handlers() {
            $tags = array(
                'sitetitle'          => array(
                    'group'       => 'global',
                    'label'       => __( 'Site Title', 'torro-forms' ),
    Severity: Major
    Found in src/modules/actions/email-notifications.php - About 6 hrs to fix

      Function handle has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

          public function handle( $submission, $form ) {
              $notifications = $this->get_form_option( $form->id, 'notifications', array() );
              if ( empty( $notifications ) ) {
                  return true;
              }
      Severity: Minor
      Found in src/modules/actions/email-notifications.php - About 4 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 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

        Function get_dynamic_template_tags has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function get_dynamic_template_tags( $form, $back_compat = false ) {
                $tags = array();
        
                foreach ( $form->get_elements() as $element ) {
                    $element_type = $element->get_element_type();
        Severity: Minor
        Found in src/modules/actions/email-notifications.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 get_meta_fields has 63 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/email-notifications.php - About 2 hrs to fix

          Method get_dynamic_template_tags has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function get_dynamic_template_tags( $form, $back_compat = false ) {
                  $tags = array();
          
                  foreach ( $form->get_elements() as $element ) {
                      $element_type = $element->get_element_type();
          Severity: Minor
          Found in src/modules/actions/email-notifications.php - About 1 hr to fix

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

                protected function register_template_tag_handlers() {
                    $tags = array(
                        'sitetitle'          => array(
                            'group'       => 'global',
                            'label'       => __( 'Site Title', 'torro-forms' ),
            Severity: Minor
            Found in src/modules/actions/email-notifications.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

            Avoid too many return statements within this method.
            Open

                                return add_query_arg( 'torro_submission_id', $submission->id, get_permalink( $form->id ) );
            Severity: Major
            Found in src/modules/actions/email-notifications.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                                  return add_query_arg(
                                      array(
                                          'post_type' => torro()->post_types()->get_prefix() . 'form',
                                          'page'      => torro()->admin_pages()->get_prefix() . 'edit_submission',
                                          'id'        => $submission->id,
              Severity: Major
              Found in src/modules/actions/email-notifications.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return sprintf( _x( '%1$s at %2$s', 'concatenating date and time', 'torro-forms' ), $date, $time );
                Severity: Major
                Found in src/modules/actions/email-notifications.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                      return $validated_ip;
                  Severity: Major
                  Found in src/modules/actions/email-notifications.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                        return $form->title;
                    Severity: Major
                    Found in src/modules/actions/email-notifications.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                          return $output;
                      Severity: Major
                      Found in src/modules/actions/email-notifications.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                            return wp_get_referer();
                        Severity: Major
                        Found in src/modules/actions/email-notifications.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                                  return '0.0.0.0';
                          Severity: Major
                          Found in src/modules/actions/email-notifications.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                            return $element_type->format_values_for_export( $values, $element, 'html' );
                            Severity: Major
                            Found in src/modules/actions/email-notifications.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                  return get_permalink( $form->id );
                              Severity: Major
                              Found in src/modules/actions/email-notifications.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                        return $tags;
                                Severity: Major
                                Found in src/modules/actions/email-notifications.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                      return get_edit_post_link( $form->id );
                                  Severity: Major
                                  Found in src/modules/actions/email-notifications.php - About 30 mins to fix

                                    There are no issues that match your filters.

                                    Category
                                    Status