aristath/kirki

View on GitHub
packages/kirki-framework/util/src/Helper.php

Summary

Maintainability
D
1 day
Test Coverage

Function compare_values has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public static function compare_values( $value1, $value2, $operator ) {
        if ( '===' === $operator ) {
            return $value1 === $value2;
        }
        if ( '!==' === $operator ) {
Severity: Minor
Found in packages/kirki-framework/util/src/Helper.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 init_filesystem has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public static function init_filesystem() {
        $credentials = [];

        if ( ! defined( 'FS_METHOD' ) ) {
            define( 'FS_METHOD', 'direct' );
Severity: Minor
Found in packages/kirki-framework/util/src/Helper.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 compare_values has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function compare_values( $value1, $value2, $operator ) {
        if ( '===' === $operator ) {
            return $value1 === $value2;
        }
        if ( '!==' === $operator ) {
Severity: Minor
Found in packages/kirki-framework/util/src/Helper.php - About 1 hr to fix

Method init_filesystem has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function init_filesystem() {
        $credentials = [];

        if ( ! defined( 'FS_METHOD' ) ) {
            define( 'FS_METHOD', 'direct' );
Severity: Minor
Found in packages/kirki-framework/util/src/Helper.php - About 1 hr to fix

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

    public static function recurse( $array, $array1 ) {
        foreach ( $array1 as $key => $value ) {

            // Create new key in $array, if it is empty or not an array.
            if ( ! isset( $array[ $key ] ) || ( isset( $array[ $key ] ) && ! is_array( $array[ $key ] ) ) ) {
Severity: Minor
Found in packages/kirki-framework/util/src/Helper.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

Avoid too many return statements within this method.
Open

                return in_array( $value1, $value2 ); // phpcs:ignore WordPress.PHP.StrictInArray
Severity: Major
Found in packages/kirki-framework/util/src/Helper.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return $value2 > $value1;
Severity: Major
Found in packages/kirki-framework/util/src/Helper.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                        return true;
Severity: Major
Found in packages/kirki-framework/util/src/Helper.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return false;
Severity: Major
Found in packages/kirki-framework/util/src/Helper.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return ( false !== strrpos( $value1, $value2 ) || false !== strpos( $value2, $value1 ) );
Severity: Major
Found in packages/kirki-framework/util/src/Helper.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return $value2 <= $value1;
Severity: Major
Found in packages/kirki-framework/util/src/Helper.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return $value2 < $value1;
Severity: Major
Found in packages/kirki-framework/util/src/Helper.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return in_array( $value2, $value1 ); // phpcs:ignore WordPress.PHP.StrictInArray
Severity: Major
Found in packages/kirki-framework/util/src/Helper.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return ! self::compare_values( $value1, $value2, $operator );
Severity: Major
Found in packages/kirki-framework/util/src/Helper.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return $value1 == $value2; // phpcs:ignore WordPress.PHP.StrictComparisons
Severity: Major
Found in packages/kirki-framework/util/src/Helper.php - About 30 mins to fix

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

    public static function array_replace_recursive( $array, $array1 ) {
        if ( function_exists( 'array_replace_recursive' ) ) {
            return array_replace_recursive( $array, $array1 );
        }

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