aristath/kirki

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

Summary

Maintainability
B
5 hrs
Test Coverage

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

    public static function get_variables() {

        $variables = [];
        $fields    = self::$variables_fields;

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

Method http_request has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function http_request( $request = [], $url = '' ) {

        // Early exit if installed as a plugin or not a request to wordpress.org,
        // or finally if we don't have everything we need.
        if (
Severity: Minor
Found in packages/kirki-framework/util/src/Util.php - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

        if (
            self::is_plugin() ||
            false === strpos( $url, 'wordpress.org' ) || (
                ! isset( $request['body'] ) ||
                ! isset( $request['body']['plugins'] ) ||
Severity: Major
Found in packages/kirki-framework/util/src/Util.php - About 1 hr to fix

Function is_plugin has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function is_plugin() {
        $is_plugin = false;
        if ( ! function_exists( 'get_plugins' ) ) {
            require_once ABSPATH . 'wp-admin/includes/plugin.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude
        }
Severity: Minor
Found in packages/kirki-framework/util/src/Util.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

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

    public function http_request( $request = [], $url = '' ) {

        // Early exit if installed as a plugin or not a request to wordpress.org,
        // or finally if we don't have everything we need.
        if (
Severity: Minor
Found in packages/kirki-framework/util/src/Util.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