aristath/kirki

View on GitHub
lib/class-aricolor.php

Summary

Maintainability
F
5 days
Test Coverage

File class-aricolor.php has 548 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
// phpcs:ignoreFile

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
Severity: Major
Found in lib/class-aricolor.php - About 1 day to fix

Function get_mode has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

        public function get_mode( $color ) {

            // Check if value is an array.
            if ( is_array( $color ) ) {
                // Does the array have an 'rgba' key?
Severity: Minor
Found in lib/class-aricolor.php - About 6 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 get_word_colors has 149 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        protected function get_word_colors() {
            return array(
                'aliceblue'            => 'F0F8FF',
                'antiquewhite'         => 'FAEBD7',
                'aqua'                 => '00FFFF',
Severity: Major
Found in lib/class-aricolor.php - About 5 hrs to fix

Method get_mode has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function get_mode( $color ) {

            // Check if value is an array.
            if ( is_array( $color ) ) {
                // Does the array have an 'rgba' key?
Severity: Major
Found in lib/class-aricolor.php - About 2 hrs to fix

Function getNew has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

        public function getNew( $property = '', $value = '' ) {

            if ( in_array( $property, array( 'red', 'green', 'blue', 'alpha' ), true ) ) {
                // Check if we're changing any of the rgba values.
                $value = max( 0, min( 255, $value ) );
Severity: Minor
Found in lib/class-aricolor.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

ariColor has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

    class ariColor {

        /**
         * An array of our instances.
         *
Severity: Minor
Found in lib/class-aricolor.php - About 2 hrs to fix

Method from_hsl_array has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        protected function from_hsl_array() {
            $h = $this->hue / 360;
            $s = $this->saturation / 100;
            $l = $this->lightness / 100;

Severity: Major
Found in lib/class-aricolor.php - About 2 hrs to fix

Method getNew has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function getNew( $property = '', $value = '' ) {

            if ( in_array( $property, array( 'red', 'green', 'blue', 'alpha' ), true ) ) {
                // Check if we're changing any of the rgba values.
                $value = max( 0, min( 255, $value ) );
Severity: Minor
Found in lib/class-aricolor.php - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

                if ( 4 === count( $color ) && isset( $color[0] ) && isset( $color[1] ) && isset( $color[2] ) && isset( $color[3] ) ) {
                    $this->color = 'rgba(' . intval( $color[0] ) . ',' . intval( $color[1] ) . ',' . intval( $color[2] ) . ',' . intval( $color[3] ) . ')';
                    return 'rgba';
                } elseif ( 3 === count( $color ) && isset( $color[0] ) && isset( $color[1] ) && isset( $color[2] ) ) {
                    // Is this a simple array with 3 items?
Severity: Critical
Found in lib/class-aricolor.php - About 1 hr to fix

Method set_hsl has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        protected function set_hsl() {
            $red   = $this->red / 255;
            $green = $this->green / 255;
            $blue  = $this->blue / 255;

Severity: Minor
Found in lib/class-aricolor.php - About 1 hr to fix

Function set_hsl has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        protected function set_hsl() {
            $red   = $this->red / 255;
            $green = $this->green / 255;
            $blue  = $this->blue / 255;

Severity: Minor
Found in lib/class-aricolor.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 from_hsl_array has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        protected function from_hsl_array() {
            $h = $this->hue / 360;
            $s = $this->saturation / 100;
            $l = $this->lightness / 100;

Severity: Minor
Found in lib/class-aricolor.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 from_hex has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        protected function from_hex() {

            if ( ! function_exists( 'sanitize_hex_color' ) ) {
                require_once wp_normalize_path( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
            }
Severity: Minor
Found in lib/class-aricolor.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 __construct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        protected function __construct( $color = '', $mode = 'auto' ) {
            $this->color = $color;

            if ( is_array( $color ) && isset( $color['fallback'] ) ) {
                $this->fallback = $color['fallback'];
Severity: Minor
Found in lib/class-aricolor.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 self::new_color( 'hsla(' . $value . ',' . $this->saturation . '%,' . $this->lightness . '%,' . $this->alpha . ')', 'hsla' );
Severity: Major
Found in lib/class-aricolor.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return null;
Severity: Major
Found in lib/class-aricolor.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                    return self::new_color( 'hsla(' . $this->hue . ',' . $value . '%,' . $this->lightness . '%,' . $this->alpha . ')', 'hsla' );
Severity: Major
Found in lib/class-aricolor.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                    return 'rgba';
Severity: Major
Found in lib/class-aricolor.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return 'rgba';
Severity: Major
Found in lib/class-aricolor.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                    return self::new_color( 'hsla(' . $this->hue . ',' . $this->saturation . '%,' . $value . '%,' . $this->alpha . ')', 'hsla' );
Severity: Major
Found in lib/class-aricolor.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return 'hex';
Severity: Major
Found in lib/class-aricolor.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return self::new_color( 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $this->alpha . ')', 'rgba' );
Severity: Major
Found in lib/class-aricolor.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                    return $keeper;
Severity: Major
Found in lib/class-aricolor.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return 'hex';
Severity: Major
Found in lib/class-aricolor.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                    return $this;
Severity: Major
Found in lib/class-aricolor.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                    return $this->mode;
Severity: Major
Found in lib/class-aricolor.php - About 30 mins to fix

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

        public function toCSS( $mode = 'hex' ) {

            $value = '';

            switch ( $mode ) {
Severity: Minor
Found in lib/class-aricolor.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