CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-includes/nav-menu-template.php

Summary

Maintainability
F
5 days
Test Coverage

Function _wp_menu_item_classes_by_context has a Cognitive Complexity of 98 (exceeds 5 allowed). Consider refactoring.
Open

function _wp_menu_item_classes_by_context( &$menu_items ) {
    global $wp_query, $wp_rewrite;

    $queried_object = $wp_query->get_queried_object();
    $queried_object_id = (int) $wp_query->queried_object_id;
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/nav-menu-template.php - About 1 day 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_item_classes_by_context has 173 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function _wp_menu_item_classes_by_context( &$menu_items ) {
    global $wp_query, $wp_rewrite;

    $queried_object = $wp_query->get_queried_object();
    $queried_object_id = (int) $wp_query->queried_object_id;
Severity: Major
Found in Web.Admin/2014/wordpress/wp-includes/nav-menu-template.php - About 6 hrs to fix

    Function wp_nav_menu has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

    function wp_nav_menu( $args = array() ) {
        static $menu_id_slugs = array();
    
        $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '',
        'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/nav-menu-template.php - About 6 hrs 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

    File nav-menu-template.php has 324 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Navigation Menu template functions
     *
     * @package WordPress
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/nav-menu-template.php - About 3 hrs to fix

      Consider simplifying this complex logical expression.
      Open

              if ( $wp_query->is_singular && 'taxonomy' == $menu_item->type && in_array( $menu_item->object_id, $possible_object_parents ) ) {
                  $active_parent_object_ids[] = (int) $menu_item->object_id;
                  $active_parent_item_ids[] = (int) $menu_item->db_id;
                  $active_object = $queried_object->post_type;
      
      
      Severity: Critical
      Found in Web.Admin/2014/wordpress/wp-includes/nav-menu-template.php - About 3 hrs to fix

        Method wp_nav_menu has 88 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function wp_nav_menu( $args = array() ) {
            static $menu_id_slugs = array();
        
            $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '',
            'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
        Severity: Major
        Found in Web.Admin/2014/wordpress/wp-includes/nav-menu-template.php - About 3 hrs to fix

          Consider simplifying this complex logical expression.
          Open

                  if (
                      isset( $parent_item->type ) &&
                      (
                          // ancestral post object
                          (
          Severity: Critical
          Found in Web.Admin/2014/wordpress/wp-includes/nav-menu-template.php - About 2 hrs to fix

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

                function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
                    $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
            
                    $class_names = '';
            
            
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/nav-menu-template.php - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                  if ( ( !$menu || is_wp_error($menu) || ( isset($menu_items) && empty($menu_items) && !$args->theme_location ) )
                      && $args->fallback_cb && is_callable( $args->fallback_cb ) )
                          return call_user_func( $args->fallback_cb, (array) $args );
              Severity: Major
              Found in Web.Admin/2014/wordpress/wp-includes/nav-menu-template.php - About 1 hr to fix

                Method start_el has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/nav-menu-template.php - About 35 mins to fix

                  Avoid too many return statements within this method.
                  Open

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

                    Avoid too many return statements within this method.
                    Open

                            return $nav_menu;
                    Severity: Major
                    Found in Web.Admin/2014/wordpress/wp-includes/nav-menu-template.php - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status