felixarntz/site-icon-extended

View on GitHub
inc/WPSIE/ICOHandler.php

Summary

Maintainability
B
4 hrs
Test Coverage

Function generate_ico_file has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        private function generate_ico_file( $attachment_id, $source_file ) {
            $destination_file = explode( '.', $source_file );
            $destination_file[ count( $destination_file ) - 1 ] = 'ico';
            $destination_file = implode( '.', $destination_file );

Severity: Minor
Found in inc/WPSIE/ICOHandler.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 maybe_generate_ico_attachment_check has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        public function maybe_generate_ico_attachment_check() {
            if ( ! current_user_can( 'upload_files' ) ) {
                return;
            }

Severity: Minor
Found in inc/WPSIE/ICOHandler.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 maybe_generate_ico_attachment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        private function maybe_generate_ico_attachment( $attachment_id ) {
            $attachment_context = get_post_meta( $attachment_id, '_wp_attachment_context', true );

            if ( 'site-icon' !== $attachment_context ) {
                return false;
Severity: Minor
Found in inc/WPSIE/ICOHandler.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

Avoid too many return statements within this method.
Open

            return true;
Severity: Major
Found in inc/WPSIE/ICOHandler.php - About 30 mins to fix

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

            public function maybe_delete_ico_file( $attachment_id ) {
                $site_icon_id = get_option( 'site_icon' );
                $ico_id = get_post_meta( $site_icon_id, 'wpsie_ico_id', true );
    
                if ( $site_icon_id && $attachment_id == $site_icon_id ) {
    Severity: Minor
    Found in inc/WPSIE/ICOHandler.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