aristath/kirki

View on GitHub
packages/kirki-framework/compatibility/src/Field.php

Summary

Maintainability
D
2 days
Test Coverage

Function set_js_vars has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    protected function set_js_vars() {
        if ( ! is_array( $this->js_vars ) ) {
            $this->js_vars = [];
        }

Severity: Minor
Found in packages/kirki-framework/compatibility/src/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

File Field.php has 265 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Creates and validates field parameters.
 *
 * @package     Kirki
Severity: Minor
Found in packages/kirki-framework/compatibility/src/Field.php - About 2 hrs to fix

Function set_active_callback has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    protected function set_active_callback() {
        if ( is_array( $this->active_callback ) ) {
            if ( ! is_callable( $this->active_callback ) ) {

                // Bugfix for https://github.com/aristath/kirki/issues/1961.
Severity: Minor
Found in packages/kirki-framework/compatibility/src/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

Function set_output has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    protected function set_output() {
        if ( empty( $this->output ) ) {
            return;
        }
        if ( ! is_array( $this->output ) ) {
Severity: Minor
Found in packages/kirki-framework/compatibility/src/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

Function __construct has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( $config_id = 'global', $args = [] ) {

        // In case the user only provides 1 argument,
        // assume that the provided argument is $args and set $config_id = 'global'.
        if ( is_array( $config_id ) && empty( $args ) ) {
Severity: Minor
Found in packages/kirki-framework/compatibility/src/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 set_output has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function set_output() {
        if ( empty( $this->output ) ) {
            return;
        }
        if ( ! is_array( $this->output ) ) {
Severity: Minor
Found in packages/kirki-framework/compatibility/src/Field.php - About 1 hr to fix

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

    public function __construct( $config_id = 'global', $args = [] ) {

        // In case the user only provides 1 argument,
        // assume that the provided argument is $args and set $config_id = 'global'.
        if ( is_array( $config_id ) && empty( $args ) ) {
Severity: Minor
Found in packages/kirki-framework/compatibility/src/Field.php - About 1 hr to fix

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

    protected function set_js_vars() {
        if ( ! is_array( $this->js_vars ) ) {
            $this->js_vars = [];
        }

Severity: Minor
Found in packages/kirki-framework/compatibility/src/Field.php - About 1 hr to fix

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

    protected function set_field() {

        $properties = get_class_vars( __CLASS__ );

        // Some things must run before the others.
Severity: Minor
Found in packages/kirki-framework/compatibility/src/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 set_partial_refresh has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function set_partial_refresh() {
        if ( ! is_array( $this->partial_refresh ) ) {
            $this->partial_refresh = [];
        }
        foreach ( $this->partial_refresh as $id => $args ) {
Severity: Minor
Found in packages/kirki-framework/compatibility/src/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 set_settings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function set_settings() {

        // If settings is not an array, temporarily convert it to an array.
        // This is just to allow us to process everything the same way and avoid code duplication.
        // if settings is not an array then it will not be set as an array in the end.
Severity: Minor
Found in packages/kirki-framework/compatibility/src/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

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

    protected function set_css_vars() {
        if ( is_string( $this->css_vars ) ) {
            $this->css_vars = [ $this->css_vars ];
        }
        if ( isset( $this->css_vars[0] ) && is_string( $this->css_vars[0] ) ) {
Severity: Minor
Found in packages/kirki-framework/compatibility/src/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