CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-includes/default-widgets.php

Summary

Maintainability
F
5 days
Test Coverage

File default-widgets.php has 752 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Default Widgets
 *
Severity: Major
Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.php - About 1 day to fix

    Function wp_widget_rss_output has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

    function wp_widget_rss_output( $rss, $args = array() ) {
        if ( is_string( $rss ) ) {
            $rss = fetch_feed($rss);
        } elseif ( is_array($rss) && isset($rss['url']) ) {
            $args = $rss;
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.php - About 5 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 wp_widget_rss_output has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function wp_widget_rss_output( $rss, $args = array() ) {
        if ( is_string( $rss ) ) {
            $rss = fetch_feed($rss);
        } elseif ( is_array($rss) && isset($rss['url']) ) {
            $args = $rss;
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.php - About 2 hrs to fix

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

      function wp_widget_rss_form( $args, $inputs = null ) {
      
          $default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true );
          $inputs = wp_parse_args( $inputs, $default_inputs );
          extract( $args );
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.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 widget has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          function widget($args, $instance) {
              $cache = wp_cache_get('widget_recent_posts', 'widget');
      
              if ( !is_array($cache) )
                  $cache = array();
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.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

      Method wp_widget_rss_form has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function wp_widget_rss_form( $args, $inputs = null ) {
      
          $default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true );
          $inputs = wp_parse_args( $inputs, $default_inputs );
          extract( $args );
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.php - About 1 hr to fix

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

            function widget( $args, $instance ) {
                global $wpdb, $comments, $comment;
        
                extract($args, EXTR_SKIP);
                $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']);
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.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 widget has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            function widget($args, $instance) {
        
                if ( isset($instance['error']) && $instance['error'] )
                    return;
        
        
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.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 widget has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function widget($args, $instance) {
        
                if ( isset($instance['error']) && $instance['error'] )
                    return;
        
        
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.php - About 1 hr to fix

          Method widget has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function widget( $args, $instance ) {
                  extract( $args );
          
                  $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title']);
                  $c = $instance['count'] ? '1' : '0';
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.php - About 1 hr to fix

            Method widget has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function widget($args, $instance) {
                    $cache = wp_cache_get('widget_recent_posts', 'widget');
            
                    if ( !is_array($cache) )
                        $cache = array();
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.php - About 1 hr to fix

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

                  function form( $instance ) {
              
                      //Defaults
                      $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false ) );
                      $link_cats = get_terms( 'link_category');
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.php - About 1 hr to fix

                Function wp_widget_rss_process has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                function wp_widget_rss_process( $widget_rss, $check_feed = true ) {
                    $items = (int) $widget_rss['items'];
                    if ( $items < 1 || 20 < $items )
                        $items = 10;
                    $url           = esc_url_raw(strip_tags( $widget_rss['url'] ));
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.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

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

                    function update( $new_instance, $old_instance ) {
                        $instance = $old_instance;
                        $instance['title'] = strip_tags($new_instance['title']);
                        $instance['number'] = (int) $new_instance['number'];
                        $this->flush_widget_cache();
                Severity: Major
                Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.php and 1 other location - About 1 hr to fix
                Web.Admin/2014/wordpress/wp-includes/default-widgets.php on lines 653..664

                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 105.

                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

                    function update( $new_instance, $old_instance ) {
                        $instance = $old_instance;
                        $instance['title'] = strip_tags($new_instance['title']);
                        $instance['number'] = (int) $new_instance['number'];
                        $this->flush_widget_cache();
                Severity: Major
                Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.php and 1 other location - About 1 hr to fix
                Web.Admin/2014/wordpress/wp-includes/default-widgets.php on lines 564..575

                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 105.

                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

                    function form( $instance ) {
                        $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
                        $title = strip_tags($instance['title']);
                ?>
                            <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
                Severity: Major
                Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.php and 1 other location - About 1 hr to fix
                Web.Admin/2014/wordpress/wp-includes/default-widgets.php on lines 354..361

                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 104.

                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

                    function form( $instance ) {
                        $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
                        $title = strip_tags($instance['title']);
                ?>
                        <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
                Severity: Major
                Found in Web.Admin/2014/wordpress/wp-includes/default-widgets.php and 1 other location - About 1 hr to fix
                Web.Admin/2014/wordpress/wp-includes/default-widgets.php on lines 314..320

                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 104.

                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

                There are no issues that match your filters.

                Category
                Status