tuhin18003/WooCommerce-AltCoin-Payment-Gateway

View on GitHub
core/admin/builders/CsFormBuilder.php

Summary

Maintainability
D
2 days
Test Coverage

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

    private function generate_field( $field_name, $field, $field_id ) {
        $input  = '<div class="label"><label>';
        $input .= $this->generate_title( $field );
        $input .= '</label></div>';
        $input .= '<div class="input-group">';
Severity: Minor
Found in core/admin/builders/CsFormBuilder.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

CsFormBuilder has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

class CsFormBuilder {

    /**
     * Generate html form fields
     *
Severity: Minor
Found in core/admin/builders/CsFormBuilder.php - About 2 hrs to fix

    Function generate_html_fields has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public function generate_html_fields( $fields, $return_array = false ) {
            if ( empty( $fields ) ) {
                return false; }
    
            $html_fields = array();
    Severity: Minor
    Found in core/admin/builders/CsFormBuilder.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 generate_attribute has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        private function generate_attribute( $field_name, $field, $field_id ) {
            // pre_print($field);
            $input_item = '';
            foreach ( $field as $item_id => $item_val ) {
                if ( $field['type'] == 'select' && ( $item_id == 'placeholder' || $item_id == 'type' ) ) {
    Severity: Minor
    Found in core/admin/builders/CsFormBuilder.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 CsFormBuilder.php has 261 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php namespace WooGateWayCoreLib\admin\builders;
    
    /**
     * From Builder
     *
    Severity: Minor
    Found in core/admin/builders/CsFormBuilder.php - About 2 hrs to fix

      Method generate_field has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function generate_field( $field_name, $field, $field_id ) {
              $input  = '<div class="label"><label>';
              $input .= $this->generate_title( $field );
              $input .= '</label></div>';
              $input .= '<div class="input-group">';
      Severity: Minor
      Found in core/admin/builders/CsFormBuilder.php - About 1 hr to fix

        Function generate_hidden_div has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            private function generate_hidden_div( $field_name, $args, $fields_number ) {
                $attributes = '';
                if ( isset( $args['attributes'] ) ) {
                    foreach ( $args['attributes'] as $attr_key => $attr_val ) {
                        if ( $attr_key == 'id' ) {
        Severity: Minor
        Found in core/admin/builders/CsFormBuilder.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 generate_html_fields has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function generate_html_fields( $fields, $return_array = false ) {
                if ( empty( $fields ) ) {
                    return false; }
        
                $html_fields = array();
        Severity: Minor
        Found in core/admin/builders/CsFormBuilder.php - About 1 hr to fix

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

              private function generate_select_field( $field_name, $field, $field_id ) {
                  $value = '';
                  if ( isset( $field['value'] ) && ! empty( $field['value'] ) ) {
                      $value = $field['value'];
                      unset( $field['value'] );
          Severity: Minor
          Found in core/admin/builders/CsFormBuilder.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

          There are no issues that match your filters.

          Category
          Status