deep-web-solutions/wordpress-framework-helpers

View on GitHub

Showing 10 of 11 total issues

Function class_uses_deep_list has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public static function class_uses_deep_list( $class, bool $autoload = true ): ?array {
        static $results = array();

        $class = \is_object( $class ) ? \get_class( $class ) : (string) $class;

Severity: Minor
Found in src/includes/DataTypes/Objects.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 trait_uses_deep_list has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public static function trait_uses_deep_list( string $trait, bool $autoload = true ): ?array {
        static $results = array();

        if ( isset( $results[ $trait ] ) ) {
            $traits = $results[ $trait ];
Severity: Minor
Found in src/includes/DataTypes/Objects.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 class_uses_deep has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public static function class_uses_deep( $class, bool $autoload = true ): ?array {
        static $results = array();

        $class = \is_object( $class ) ? \get_class( $class ) : (string) $class;

Severity: Minor
Found in src/includes/DataTypes/Objects.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 trait_uses_deep has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public static function trait_uses_deep( string $trait, bool $autoload = true ): ?array {
        static $results = array();

        if ( isset( $results[ $trait ] ) ) {
            $traits = $results[ $trait ];
Severity: Minor
Found in src/includes/DataTypes/Objects.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 is_rest_api_request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected static function is_rest_api_request(): bool {
        if ( \function_exists( 'wp_doing_rest' ) ) {
            return \wp_doing_rest();
        }

Severity: Minor
Found in src/includes/Request.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

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

    public static function is_type( string $type ): bool {
        switch ( $type ) {
            case 'admin':
                $result = \is_admin();
                break;
Severity: Minor
Found in src/includes/Request.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

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

    public static function remove_anonymous_object_hook( string $hook, string $class, string $method ): void {
        $filters = $GLOBALS['wp_filter'][ $hook ];
        if ( empty( $filters ) ) {
            return;
        }
Severity: Minor
Found in src/includes/Hooks.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

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

    public function get_wp_filesystem( ?string $form_url = null, string $context = '', ?array $extra_fields = null ): ?\WP_Filesystem_Base {
        global $wp_filesystem;

        if ( ! \function_exists( '\request_filesystem_credentials' ) ) {
            include_once ABSPATH . 'wp-admin/includes/file.php';
Severity: Minor
Found in src/includes/FileSystem/FilesystemAwareTrait.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 search_values has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function search_values( array $array, $needle, ?callable $callback = null, bool $strict = true ): ?array {
        $comparison_array = \is_callable( $callback ) ? \array_map( $callback, $array ) : $array;

        foreach ( $comparison_array as $key => $value ) {
            if ( ( $strict && $needle === $value ) || ( ! $strict && $needle == $value ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
Severity: Minor
Found in src/includes/DataTypes/Arrays.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 maybe_get_minified_path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function maybe_get_minified_path( string $relative_path, string $constant_name = 'SCRIPT_DEBUG', ?\WP_Filesystem_Base $wp_filesystem = null ): string {
        $maybe_minified_path = $relative_path;
        $minified_suffix     = self::maybe_get_minified_suffix( $constant_name );

        if ( ! empty( $minified_suffix ) && true !== Strings::contains( $relative_path, $minified_suffix ) ) {
Severity: Minor
Found in src/includes/Assets.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

Severity
Category
Status
Source
Language