awsmug/torro-forms

View on GitHub
src/db-objects/forms/form-frontend-output-handler.php

Summary

Maintainability
D
1 day
Test Coverage

Method render_form_content has 102 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function render_form_content( $form, $submission = null ) {
        $prefix = $this->form_manager->get_prefix();

        /**
         * Filters whether a user can access a specific form, and optionally submission.
Severity: Major
Found in src/db-objects/forms/form-frontend-output-handler.php - About 4 hrs to fix

    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

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

          protected function render_form_content( $form, $submission = null ) {
              $prefix = $this->form_manager->get_prefix();
      
              /**
               * Filters whether a user can access a specific form, and optionally submission.
      Severity: Minor
      Found in src/db-objects/forms/form-frontend-output-handler.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_print_form_error has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function maybe_print_form_error( $form ) {
              $key = $this->form_manager->get_prefix() . 'form_errors';
      
              if ( is_user_logged_in() ) {
                  $errors = get_user_meta( get_current_user_id(), $key, true );
      Severity: Minor
      Found in src/db-objects/forms/form-frontend-output-handler.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 get_shortcode_content has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function get_shortcode_content( $atts ) {
              $atts = shortcode_atts(
                  array(
                      'id'            => '',
                      'show'          => 'direct',
      Severity: Minor
      Found in src/db-objects/forms/form-frontend-output-handler.php - About 1 hr to fix

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

            public function get_shortcode_content( $atts ) {
                $atts = shortcode_atts(
                    array(
                        'id'            => '',
                        'show'          => 'direct',
        Severity: Minor
        Found in src/db-objects/forms/form-frontend-output-handler.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

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

            protected function maybe_print_submission_errors( $submission ) {
                if ( $submission->has_errors( 0 ) ) {
                    $global_errors = $submission->get_errors( 0 );
                    if ( 1 === count( $global_errors ) ) {
                        $error_key = key( $global_errors );
        Severity: Minor
        Found in src/db-objects/forms/form-frontend-output-handler.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

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

            public function maybe_get_form_content( $content ) {
                $form = $this->form_manager->get( get_the_ID() );
                if ( ! $form ) {
                    return $content;
                }
        Severity: Minor
        Found in src/db-objects/forms/form-frontend-output-handler.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