CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-admin/includes/class-wp-comments-list-table.php

Summary

Maintainability
F
4 days
Test Coverage

Function column_comment has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

    function column_comment( $comment ) {
        global $comment_status;
        $post = get_post();

        $user_can = $this->user_can;

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

File class-wp-comments-list-table.php has 426 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Comments and Post Comments List Table classes.
 *
 * @package WordPress

    Method column_comment has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function column_comment( $comment ) {
            global $comment_status;
            $post = get_post();
    
            $user_can = $this->user_can;

      Method prepare_items has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function prepare_items() {
              global $post_id, $comment_status, $search, $comment_type;
      
              $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
              if ( !in_array( $comment_status, array( 'all', 'moderated', 'approved', 'spam', 'trash' ) ) )

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

            function get_views() {
                global $post_id, $comment_status, $comment_type;
        
                $status_links = array();
                $num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();

          Method extra_tablenav has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function extra_tablenav( $which ) {
                  global $comment_status, $comment_type;
          ?>
                  <div class="alignleft actions">
          <?php

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

                function prepare_items() {
                    global $post_id, $comment_status, $search, $comment_type;
            
                    $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
                    if ( !in_array( $comment_status, array( 'all', 'moderated', 'approved', 'spam', 'trash' ) ) )

            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_views has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                function get_views() {
                    global $post_id, $comment_status, $comment_type;
            
                    $status_links = array();
                    $num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();

            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 column_author has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                function column_author( $comment ) {
                    global $comment_status;
            
                    $author_url = get_comment_author_url();
                    if ( 'http://' == $author_url )

            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_bulk_actions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                function get_bulk_actions() {
                    global $comment_status;
            
                    $actions = array();
                    if ( in_array( $comment_status, array( 'all', 'approved' ) ) )

            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

            Consider simplifying this complex logical expression.
            Open

                            if ( ( 'reply' == $action || 'quickedit' == $action ) && ! defined('DOING_AJAX') )
                                $action .= ' hide-if-no-js';
                            elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' ) ) {
                                if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) )
                                    $action .= ' approve';

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

                  function extra_tablenav( $which ) {
                      global $comment_status, $comment_type;
              ?>
                      <div class="alignleft actions">
              <?php

              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 column_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  function column_response( $comment ) {
                      $post = get_post();
              
                      if ( isset( $this->pending_count[$post->ID] ) ) {
                          $pending_comments = $this->pending_count[$post->ID];

              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

                          if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
                              if ( 'approved' == $the_comment_status )
                                  $actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=unapproved' class='vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
                              else if ( 'unapproved' == $the_comment_status )
                                  $actions['approve'] = "<a href='$approve_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=approved' class='vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
              Web.Admin/2014/wordpress/wp-admin/includes/template.php on lines 2174..2182

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

              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

                          if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
                              $actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::delete=1' class='delete vim-d vim-destructive'>" . __( 'Delete Permanently' ) . '</a>';
                          } else {
                              $actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
                          }
              Web.Admin/2014/wordpress/wp-admin/includes/template.php on lines 2192..2196

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

              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