gocodebox/lifterlms

View on GitHub
includes/forms/class-llms-form-field.php

Summary

Maintainability
F
3 days
Test Coverage
A
97%

File class-llms-form-field.php has 461 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Setup and render form fields.
 *
 * @package LifterLMS/Classes
Severity: Minor
Found in includes/forms/class-llms-form-field.php - About 7 hrs to fix

    LLMS_Form_Field has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class LLMS_Form_Field {
    
        /**
         * Form Field Settings
         *
    Severity: Minor
    Found in includes/forms/class-llms-form-field.php - About 3 hrs to fix

      Function prepare_options has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function prepare_options( $raw ) {
      
              $prepared = array();
      
              foreach ( $raw as $key => $val ) {
      Severity: Minor
      Found in includes/forms/class-llms-form-field.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_field_html has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function get_field_html() {
      
              /**
               * Allow 3rd parties to create custom field types or their own field HTML methods.
               *
      Severity: Major
      Found in includes/forms/class-llms-form-field.php - About 2 hrs to fix

        Function get_field_html has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function get_field_html() {
        
                /**
                 * Allow 3rd parties to create custom field types or their own field HTML methods.
                 *
        Severity: Minor
        Found in includes/forms/class-llms-form-field.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 prepare_value has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function prepare_value() {
        
                // Never autoload passwords and or fields with an explicit value (except radio and checkbox).
                if ( 'password' === $this->settings['type'] || ! empty( $this->settings['value'] && ! in_array( $this->settings['type'], array( 'checkbox', 'radio' ), true ) ) ) {
                    return;
        Severity: Minor
        Found in includes/forms/class-llms-form-field.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 prepare_options has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function prepare_options( $raw ) {
        
                $prepared = array();
        
                foreach ( $raw as $key => $val ) {
        Severity: Minor
        Found in includes/forms/class-llms-form-field.php - About 1 hr to fix

          Method prepare has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function prepare() {
          
                  if ( empty( $this->settings['id'] ) ) {
                      $this->settings['id'] = uniqid( 'llms-field-' );
                  }
          Severity: Minor
          Found in includes/forms/class-llms-form-field.php - About 1 hr to fix

            Method explode_options_to_fields has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function explode_options_to_fields( $is_hidden = false ) {
            
                    $fields = array();
                    $value  = ! empty( $this->settings['value'] ) || is_array( $this->settings['value'] )
                        ? $this->settings['value']
            Severity: Minor
            Found in includes/forms/class-llms-form-field.php - About 1 hr to fix

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

                  protected function prepare() {
              
                      if ( empty( $this->settings['id'] ) ) {
                          $this->settings['id'] = uniqid( 'llms-field-' );
                      }
              Severity: Minor
              Found in includes/forms/class-llms-form-field.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 prepare_value has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function prepare_value() {
              
                      // Never autoload passwords and or fields with an explicit value (except radio and checkbox).
                      if ( 'password' === $this->settings['type'] || ! empty( $this->settings['value'] && ! in_array( $this->settings['type'], array( 'checkbox', 'radio' ), true ) ) ) {
                          return;
              Severity: Minor
              Found in includes/forms/class-llms-form-field.php - About 1 hr to fix

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

                    public function explode_options_to_fields( $is_hidden = false ) {
                
                        $fields = array();
                        $value  = ! empty( $this->settings['value'] ) || is_array( $this->settings['value'] )
                            ? $this->settings['value']
                Severity: Minor
                Found in includes/forms/class-llms-form-field.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 get_html_attributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function get_html_attributes() {
                
                        $check = array(
                            'id',
                            'disabled',
                Severity: Minor
                Found in includes/forms/class-llms-form-field.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 get_html has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function get_html() {
                
                        /**
                         * Short-circuit field HTML generation.
                         *
                Severity: Minor
                Found in includes/forms/class-llms-form-field.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 prepare_options_from_preset has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function prepare_options_from_preset() {
                
                        $preset_id = $this->settings['options_preset'];
                        switch ( $preset_id ) {
                            case 'countries':
                Severity: Minor
                Found in includes/forms/class-llms-form-field.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