WordPress/WordPress

View on GitHub
wp-admin/edit-comments.php

Summary

Maintainability
D
1 day
Test Coverage

File edit-comments.php has 290 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Edit Comments Administration Screen.
 *
 * @package WordPress
Severity: Minor
Found in wp-admin/edit-comments.php - About 2 hrs to fix

    Consider simplifying this complex logical expression.
    Open

        if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) {
            if ( $approved > 0 ) {
                /* translators: %s: Number of comments. */
                $messages[] = sprintf( _n( '%s comment approved', '%s comments approved', $approved ), $approved );
            }
    Severity: Major
    Found in wp-admin/edit-comments.php - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

      if ( isset( $_REQUEST['approved'] ) || isset( $_REQUEST['deleted'] ) || isset( $_REQUEST['trashed'] ) || isset( $_REQUEST['untrashed'] ) || isset( $_REQUEST['spammed'] ) || isset( $_REQUEST['unspammed'] ) || isset( $_REQUEST['same'] ) ) {
          $approved  = isset( $_REQUEST['approved'] ) ? (int) $_REQUEST['approved'] : 0;
          $deleted   = isset( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0;
          $trashed   = isset( $_REQUEST['trashed'] ) ? (int) $_REQUEST['trashed'] : 0;
          $untrashed = isset( $_REQUEST['untrashed'] ) ? (int) $_REQUEST['untrashed'] : 0;
      Severity: Major
      Found in wp-admin/edit-comments.php - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                        switch ( $comment->comment_approved ) {
                            case '1':
                                $messages[] = __( 'This comment is already approved.' ) . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>';
                                break;
                            case 'trash':
        Severity: Major
        Found in wp-admin/edit-comments.php - About 45 mins to fix

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

          get_current_screen()->add_help_tab(
              array(
                  'id'      => 'moderating-comments',
                  'title'   => __( 'Moderating Comments' ),
                  'content' =>
          Severity: Major
          Found in wp-admin/edit-comments.php and 1 other location - About 4 hrs to fix
          wp-admin/network/users.php on lines 212..224

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

          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 ( $spammed > 0 ) {
                      $ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0;
                      /* translators: %s: Number of comments. */
                      $messages[] = sprintf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", 'bulk-comments' ) ) . '">' . __( 'Undo' ) . '</a><br />';
                  }
          Severity: Major
          Found in wp-admin/edit-comments.php and 1 other location - About 2 hrs to fix
          wp-admin/edit-comments.php on lines 300..304

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

          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 ( $trashed > 0 ) {
                      $ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0;
                      /* translators: %s: Number of comments. */
                      $messages[] = sprintf( _n( '%s comment moved to the Trash.', '%s comments moved to the Trash.', $trashed ), $trashed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", 'bulk-comments' ) ) . '">' . __( 'Undo' ) . '</a><br />';
                  }
          Severity: Major
          Found in wp-admin/edit-comments.php and 1 other location - About 2 hrs to fix
          wp-admin/edit-comments.php on lines 289..293

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

          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