felixarntz/wpdlib

View on GitHub
inc/WPDLib/FieldTypes/Repeatable.php

Summary

Maintainability
D
2 days
Test Coverage

Function parse has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

        public function parse( $val, $formatted = false ) {
            $parsed = array();
            $items_formatted = false;
            if ( $formatted ) {
                $items_formatted = array( 'mode' => 'text', 'list' => true );
Severity: Minor
Found in inc/WPDLib/FieldTypes/Repeatable.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 validate has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

        public function validate( $val = null ) {
            if ( ! $val || ! is_array( $val ) ) {
                return array();
            }

Severity: Minor
Found in inc/WPDLib/FieldTypes/Repeatable.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 __construct has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        public function __construct( $type, $args ) {
            $args = wp_parse_args( $args, array(
                'repeatable' => array(),
            ) );
            if ( ! is_array( $args['repeatable'] ) ) {
Severity: Minor
Found in inc/WPDLib/FieldTypes/Repeatable.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 display has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function display( $val, $echo = true ) {
            if ( ! is_array( $val ) ) {
                $val = array();
            }

Severity: Minor
Found in inc/WPDLib/FieldTypes/Repeatable.php - About 1 hr to fix

    Method display_item has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            protected function display_item( $key, $values = array(), $echo = true ) {
                $output = '<tr class="wpdlib-repeatable-row">';
    
                $output .= '<td class="wpdlib-repeatable-number">';
                if ( '{{' . 'KEY' . '}}' === $key ) {
    Severity: Minor
    Found in inc/WPDLib/FieldTypes/Repeatable.php - About 1 hr to fix

      Method parse has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public function parse( $val, $formatted = false ) {
                  $parsed = array();
                  $items_formatted = false;
                  if ( $formatted ) {
                      $items_formatted = array( 'mode' => 'text', 'list' => true );
      Severity: Minor
      Found in inc/WPDLib/FieldTypes/Repeatable.php - About 1 hr to fix

        Function display_item has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

                protected function display_item( $key, $values = array(), $echo = true ) {
                    $output = '<tr class="wpdlib-repeatable-row">';
        
                    $output .= '<td class="wpdlib-repeatable-number">';
                    if ( '{{' . 'KEY' . '}}' === $key ) {
        Severity: Minor
        Found in inc/WPDLib/FieldTypes/Repeatable.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 display has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

                public function display( $val, $echo = true ) {
                    if ( ! is_array( $val ) ) {
                        $val = array();
                    }
        
        
        Severity: Minor
        Found in inc/WPDLib/FieldTypes/Repeatable.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 parse_template has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

                protected function parse_template( $val, $template, $before = '', $after = '' ) {
                    $output = '';
        
                    if ( ! $this->is_empty( $val ) ) {
                        $output .= $before;
        Severity: Minor
        Found in inc/WPDLib/FieldTypes/Repeatable.php - About 55 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