felixarntz/site-icon-extended

View on GitHub

Showing 10 of 10 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

var readmeheader =    'Plugin Name:       ' + config.pluginName + '\n' +
                    'Plugin URI:        ' + config.pluginURI + '\n' +
                    'Author:            ' + config.author + '\n' +
                    'Author URI:        ' + config.authorURI + '\n' +
                    'Contributors:      ' + config.contributors + '\n' +
Severity: Major
Found in gulpfile.js and 1 other location - About 2 hrs to fix
gulpfile.js on lines 45..50

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 78.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

var pluginheader =     'Plugin Name: ' + config.pluginName + '\n' +
                    'Plugin URI:  ' + config.pluginURI + '\n' +
                    'Description: ' + config.description + '\n' +
                    'Version:     ' + config.version + '\n' +
                    'Author:      ' + config.author + '\n' +
Severity: Major
Found in gulpfile.js and 1 other location - About 2 hrs to fix
gulpfile.js on lines 58..63

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 78.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method get_sizes has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        protected function get_sizes( $mode = '' ) {
            $sizes = array(
                'default'            => array(
                    16,
                    32,
Severity: Minor
Found in inc/WPSIE/App.php - About 1 hr to fix

    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

    Method customize_register_pinned_tab_icon has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public function customize_register_pinned_tab_icon( $wp_customize ) {
                $site_icon_control = $wp_customize->get_control( 'site_icon' );
                if ( ! $site_icon_control ) {
                    return;
                }
    Severity: Minor
    Found in inc/WPSIE/PinnedTabIconHandler.php - About 1 hr to fix

      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

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

              private function get_browserconfig() {
                  $content = '<browserconfig>' . "\n";
                  $content .= '<msapplication>' . "\n";
                  $content .= '<tile>' . "\n";
      
      
      Severity: Minor
      Found in inc/WPSIE/XMLHandler.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 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

        Severity
        Category
        Status
        Source
        Language