WordPress/WordPress

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

Summary

Maintainability
D
1 day
Test Coverage

File edit-comments.php has 379 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 5 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 ) {
                $messages[] = sprintf(
                    /* translators: %s: Number of comments. */
                    _n( '%s comment approved.', '%s comments 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'] )
      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.' ) . sprintf(
                                    ' <a href="%1$s">%2$s</a>',
                                    esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ),
        Severity: Major
        Found in wp-admin/edit-comments.php - About 45 mins to fix

          Similar blocks of code found in 4 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 3 other locations - About 3 hrs to fix
          wp-admin/erase-personal-data.php on lines 32..44
          wp-admin/export-personal-data.php on lines 32..44
          wp-admin/network/users.php on lines 226..238

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

          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;
          
                      $messages[] = sprintf(
                          /* translators: %s: Number of comments. */
          Severity: Major
          Found in wp-admin/edit-comments.php and 1 other location - About 1 hr to fix
          wp-admin/edit-comments.php on lines 361..373

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

          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;
          
                      $messages[] = sprintf(
                          /* translators: %s: Number of comments. */
          Severity: Major
          Found in wp-admin/edit-comments.php and 1 other location - About 1 hr to fix
          wp-admin/edit-comments.php on lines 339..351

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

          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