CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-admin/menu-header.php

Summary

Maintainability
D
2 days
Test Coverage

Function _wp_menu_output has a Cognitive Complexity of 103 (exceeds 5 allowed). Consider refactoring.
Open

function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
    global $self, $parent_file, $submenu_file, $plugin_page, $pagenow;

    $first = true;
    // 0 = name, 1 = capability, 2 = file, 3 = class, 4 = id, 5 = icon src
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-admin/menu-header.php - About 2 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 _wp_menu_output has 98 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
    global $self, $parent_file, $submenu_file, $plugin_page, $pagenow;

    $first = true;
    // 0 = name, 1 = capability, 2 = file, 3 = class, 4 = id, 5 = icon src
Severity: Major
Found in Web.Admin/2014/wordpress/wp-admin/menu-header.php - About 3 hrs to fix

    Consider simplifying this complex logical expression.
    Open

                    } else if ( (isset($plugin_page) && $plugin_page == $sub_item[2] && (!file_exists($menu_file) || ($item[2] == $self))) || (!isset($plugin_page) && $self == $sub_item[2]) ) {
                        $class[] = 'current';
                    }
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-admin/menu-header.php - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

                      if ( ( ('index.php' != $sub_item[2]) && file_exists(WP_PLUGIN_DIR . "/$sub_file") ) || ! empty($menu_hook) ) {
                          // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir
      
                          $parent_exists = (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/$menu_file") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}") ) || file_exists($menu_file);
                          if ( $parent_exists )
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-admin/menu-header.php - About 40 mins to fix

        There are no issues that match your filters.

        Category
        Status