aristath/kirki

View on GitHub
packages/kirki-framework/field-background/src/Background.php

Summary

Maintainability
D
1 day
Test Coverage

Method init has 173 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function init( $args ) {

        $args['required']     = isset( $args['required'] ) ? (array) $args['required'] : [];
        $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global';

Severity: Major
Found in packages/kirki-framework/field-background/src/Background.php - About 6 hrs to fix

File Background.php has 295 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Override field methods
 *
 * @package   kirki-framework/control-background
Severity: Minor
Found in packages/kirki-framework/field-background/src/Background.php - About 3 hrs to fix

Method sanitize has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function sanitize( $value ) {

        if ( ! is_array( $value ) ) {
            return [];
        }
Severity: Major
Found in packages/kirki-framework/field-background/src/Background.php - About 2 hrs to fix

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

    protected function set_js_vars() {

        // Typecast to array.
        $this->js_vars = (array) $this->js_vars;

Severity: Minor
Found in packages/kirki-framework/field-background/src/Background.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 sanitize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function sanitize( $value ) {

        if ( ! is_array( $value ) ) {
            return [];
        }
Severity: Minor
Found in packages/kirki-framework/field-background/src/Background.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

There are no issues that match your filters.

Category
Status