CaffGeek/MBACNationals

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

Summary

Maintainability
F
5 days
Test Coverage

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

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

    Function wp_setup_nav_menu_item has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    function wp_setup_nav_menu_item( $menu_item ) {
        if ( isset( $menu_item->post_type ) ) {
            if ( 'nav_menu_item' == $menu_item->post_type ) {
                $menu_item->db_id = (int) $menu_item->ID;
                $menu_item->menu_item_parent = empty( $menu_item->menu_item_parent ) ? get_post_meta( $menu_item->ID, '_menu_item_menu_item_parent', true ) : $menu_item->menu_item_parent;
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/nav-menu.php - About 4 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

    Method wp_update_nav_menu_item has 98 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item_data = array() ) {
        $menu_id = (int) $menu_id;
        $menu_item_db_id = (int) $menu_item_db_id;
    
        // make sure that we don't convert non-nav_menu_item objects into nav_menu_item objects
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-includes/nav-menu.php - About 3 hrs to fix

      Function wp_get_nav_menu_items has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      function wp_get_nav_menu_items( $menu, $args = array() ) {
          $menu = wp_get_nav_menu_object( $menu );
      
          if ( ! $menu )
              return false;
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/nav-menu.php - About 3 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

      Function wp_update_nav_menu_item has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

      function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item_data = array() ) {
          $menu_id = (int) $menu_id;
          $menu_item_db_id = (int) $menu_item_db_id;
      
          // make sure that we don't convert non-nav_menu_item objects into nav_menu_item objects
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/nav-menu.php - About 3 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

      Method wp_setup_nav_menu_item has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function wp_setup_nav_menu_item( $menu_item ) {
          if ( isset( $menu_item->post_type ) ) {
              if ( 'nav_menu_item' == $menu_item->post_type ) {
                  $menu_item->db_id = (int) $menu_item->ID;
                  $menu_item->menu_item_parent = empty( $menu_item->menu_item_parent ) ? get_post_meta( $menu_item->ID, '_menu_item_menu_item_parent', true ) : $menu_item->menu_item_parent;
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-includes/nav-menu.php - About 3 hrs to fix

        Method wp_get_nav_menu_items has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function wp_get_nav_menu_items( $menu, $args = array() ) {
            $menu = wp_get_nav_menu_object( $menu );
        
            if ( ! $menu )
                return false;
        Severity: Major
        Found in Web.Admin/2014/wordpress/wp-includes/nav-menu.php - About 2 hrs to fix

          Function _wp_auto_add_pages_to_menu has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

          function _wp_auto_add_pages_to_menu( $new_status, $old_status, $post ) {
              if ( 'publish' != $new_status || 'publish' == $old_status || 'page' != $post->post_type )
                  return;
              if ( ! empty( $post->post_parent ) )
                  return;
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/nav-menu.php - About 1 hr 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

          Function wp_get_associated_nav_menu_items has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          function wp_get_associated_nav_menu_items( $object_id = 0, $object_type = 'post_type', $taxonomy = '' ) {
              $object_id = (int) $object_id;
              $menu_item_ids = array();
          
              $query = new WP_Query;
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/nav-menu.php - About 1 hr 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_update_nav_menu_object has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function wp_update_nav_menu_object( $menu_id = 0, $menu_data = array() ) {
              $menu_id = (int) $menu_id;
          
              $_menu = wp_get_nav_menu_object( $menu_id );
          
          
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/nav-menu.php - About 1 hr to fix

            Method wp_get_associated_nav_menu_items has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function wp_get_associated_nav_menu_items( $object_id = 0, $object_type = 'post_type', $taxonomy = '' ) {
                $object_id = (int) $object_id;
                $menu_item_ids = array();
            
                $query = new WP_Query;
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/nav-menu.php - About 1 hr to fix

              Function wp_update_nav_menu_object has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              function wp_update_nav_menu_object( $menu_id = 0, $menu_data = array() ) {
                  $menu_id = (int) $menu_id;
              
                  $_menu = wp_get_nav_menu_object( $menu_id );
              
              
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/nav-menu.php - About 1 hr 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_auto_add_pages_to_menu has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function _wp_auto_add_pages_to_menu( $new_status, $old_status, $post ) {
                  if ( 'publish' != $new_status || 'publish' == $old_status || 'page' != $post->post_type )
                      return;
                  if ( ! empty( $post->post_parent ) )
                      return;
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/nav-menu.php - About 1 hr to fix

                Function wp_delete_nav_menu has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                function wp_delete_nav_menu( $menu ) {
                    $menu = wp_get_nav_menu_object( $menu );
                    if ( ! $menu )
                        return false;
                
                
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/nav-menu.php - About 55 mins 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

                Function _sort_nav_menu_items has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                function _sort_nav_menu_items( $a, $b ) {
                    global $_menu_item_sort_prop;
                
                    if ( empty( $_menu_item_sort_prop ) )
                        return 0;
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/nav-menu.php - About 35 mins 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

                Avoid too many return statements within this method.
                Open

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

                  Avoid too many return statements within this method.
                  Open

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

                    Avoid too many return statements within this method.
                    Open

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

                      Avoid too many return statements within this method.
                      Open

                              return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop );
                      Severity: Major
                      Found in Web.Admin/2014/wordpress/wp-includes/nav-menu.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

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

                          There are no issues that match your filters.

                          Category
                          Status