felixarntz/wpdlib

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

Summary

Maintainability
D
2 days
Test Coverage

Function format_item has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

        protected function format_item( $val, $args = array() ) {
            $skip_formatting = false;

            if ( isset( $this->args['options'][ $val ] ) ) {
                if ( is_array( $this->args['options'][ $val ] ) ) {
Severity: Minor
Found in inc/WPDLib/FieldTypes/Radio.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 parse_multi has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

        protected function parse_multi( $val, $formatted = false ) {
            $parsed = array();
            if ( $formatted ) {
                if ( ! is_array( $formatted ) ) {
                    $formatted = array();
Severity: Minor
Found in inc/WPDLib/FieldTypes/Radio.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 validate_multi has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

        protected function validate_multi( $val = null ) {
            if ( ! $val ) {
                return array();
            }

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

        protected function maybe_generate_additional_item_output( $id, $data, $checked = false ) {
            $output = $class = $label = '';
            if ( isset( $data['image'] ) || isset( $data['color'] ) ) {
                $output = '<div id="' . $id . '-asset"';

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

        protected function validate_single( $val = null ) {
            if ( ! $val ) {
                if ( count( $this->args['options'] ) > 0 ) {
                    return key( $this->args['options'] );
                }
Severity: Minor
Found in inc/WPDLib/FieldTypes/Radio.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 format_item has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        protected function format_item( $val, $args = array() ) {
            $skip_formatting = false;

            if ( isset( $this->args['options'][ $val ] ) ) {
                if ( is_array( $this->args['options'][ $val ] ) ) {
Severity: Minor
Found in inc/WPDLib/FieldTypes/Radio.php - About 1 hr to fix

    Method parse_multi has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            protected function parse_multi( $val, $formatted = false ) {
                $parsed = array();
                if ( $formatted ) {
                    if ( ! is_array( $formatted ) ) {
                        $formatted = array();
    Severity: Minor
    Found in inc/WPDLib/FieldTypes/Radio.php - About 1 hr to fix

      Method display_item has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              protected function display_item( $value, $label, $single_type, $id, $name, $current = '', $echo = true ) {
      Severity: Major
      Found in inc/WPDLib/FieldTypes/Radio.php - About 50 mins to fix

        Function display has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                public function display( $val, $echo = true ) {
                    $args = array(
                        'id'    => $this->args['id'],
                        'class' => $this->args['class'],
                    );
        Severity: Minor
        Found in inc/WPDLib/FieldTypes/Radio.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 __construct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                public function __construct( $type, $args ) {
                    $args = wp_parse_args( $args, array(
                        'options' => array(),
                    ) );
                    parent::__construct( $type, $args );
        Severity: Minor
        Found in inc/WPDLib/FieldTypes/Radio.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 display_item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                protected function display_item( $value, $label, $single_type, $id, $name, $current = '', $echo = true ) {
                    $option_atts = array(
                        'id'        => $id . '-' . $value,
                        'name'        => $name,
                        'value'        => $value,
        Severity: Minor
        Found in inc/WPDLib/FieldTypes/Radio.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

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

                protected function is_value_checked_or_selected( $val, $choice ) {
                    if ( isset( $this->args['multiple'] ) && $this->args['multiple'] ) {
                        if ( ! is_array( $val ) ) {
                            $val = array( $val );
                        }
        Severity: Minor
        Found in inc/WPDLib/FieldTypes/Radio.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

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

                protected function get_sanitized_name() {
                    $name = $this->args['name'];
                    if ( isset( $this->args['multiple'] ) && $this->args['multiple'] ) {
                        if ( '[]' != substr( $name, -2 ) ) {
                            $name .= '[]';
        Severity: Minor
        Found in inc/WPDLib/FieldTypes/Radio.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