CaffGeek/MBACNationals

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

Summary

Maintainability
F
5 days
Test Coverage

Function redirect_canonical has a Cognitive Complexity of 160 (exceeds 5 allowed). Consider refactoring.
Open

function redirect_canonical($requested_url=null, $do_redirect=true) {
    global $wp_rewrite, $is_IIS, $wp_query, $wpdb;

    if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || ( isset($_POST) && count($_POST) ) || is_preview() || is_robots() )
        return;
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/canonical.php - About 3 days 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 redirect_canonical has 201 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function redirect_canonical($requested_url=null, $do_redirect=true) {
    global $wp_rewrite, $is_IIS, $wp_query, $wpdb;

    if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || ( isset($_POST) && count($_POST) ) || is_preview() || is_robots() )
        return;
Severity: Major
Found in Web.Admin/2014/wordpress/wp-includes/canonical.php - About 1 day to fix

    Consider simplifying this complex logical expression.
    Open

            if ( is_attachment() && !empty($_GET['attachment_id']) && ! $redirect_url ) {
                if ( $redirect_url = get_attachment_link(get_query_var('attachment_id')) )
                    $redirect['query'] = remove_query_arg('attachment_id', $redirect['query']);
            } elseif ( is_single() && !empty($_GET['p']) && ! $redirect_url ) {
                if ( $redirect_url = get_permalink(get_query_var('p')) )
    Severity: Critical
    Found in Web.Admin/2014/wordpress/wp-includes/canonical.php - About 6 hrs to fix

      Consider simplifying this complex logical expression.
      Open

          if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || ( isset($_POST) && count($_POST) ) || is_preview() || is_robots() )
              return;
      Severity: Critical
      Found in Web.Admin/2014/wordpress/wp-includes/canonical.php - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                            if ( $paged > 1 && !is_single() ) {
                                $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit("page/$paged", 'paged');
                            } elseif ( !is_single() ) {
                                $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit($paged_redirect['path'], 'paged');
                            }
        Severity: Major
        Found in Web.Admin/2014/wordpress/wp-includes/canonical.php - About 45 mins to fix

          Consider simplifying this complex logical expression.
          Open

              if ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && !is_404() && (!is_front_page() || ( is_front_page() && (get_query_var('paged') > 1) ) ) ) {
                  $user_ts_type = '';
                  if ( get_query_var('paged') > 0 ) {
                      $user_ts_type = 'paged';
                  } else {
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-includes/canonical.php - About 40 mins to fix

            Avoid too many return statements within this method.
            Open

                    return $redirect_url;
            Severity: Major
            Found in Web.Admin/2014/wordpress/wp-includes/canonical.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return false;
              Severity: Major
              Found in Web.Admin/2014/wordpress/wp-includes/canonical.php - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status