CaffGeek/MBACNationals

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

Summary

Maintainability
F
1 wk
Test Coverage

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

<?php

/**
 * Create HTML list of nav menu input items.
 *
Severity: Major
Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 2 days to fix

    Function _wp_ajax_menu_quick_search has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

    function _wp_ajax_menu_quick_search( $request = array() ) {
        $args = array();
        $type = isset( $request['type'] ) ? $request['type'] : '';
        $object_type = isset( $request['object_type'] ) ? $request['object_type'] : '';
        $query = isset( $request['q'] ) ? $request['q'] : '';
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 7 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_nav_menu_item_post_type_meta_box has 189 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
        global $_nav_menu_placeholder, $nav_menu_selected_id;
    
        $post_type_name = $post_type['args']->name;
    
    
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 7 hrs to fix

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

          function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
              global $_wp_nav_menu_max_depth;
              $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
      
              ob_start();
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 6 hrs to fix

        Method wp_nav_menu_item_taxonomy_meta_box has 157 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) {
            global $nav_menu_selected_id;
            $taxonomy_name = $taxonomy['args']->name;
        
            // paginate browsing for large numbers of objects
        Severity: Major
        Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 6 hrs to fix

          Function wp_nav_menu_update_menu_items has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

          function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) {
              $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) );
          
              $menu_items = array();
              // Index menu items by db ID
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-admin/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_ajax_menu_quick_search has 92 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function _wp_ajax_menu_quick_search( $request = array() ) {
              $args = array();
              $type = isset( $request['type'] ) ? $request['type'] : '';
              $object_type = isset( $request['object_type'] ) ? $request['object_type'] : '';
              $query = isset( $request['q'] ) ? $request['q'] : '';
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 3 hrs to fix

            Function wp_nav_menu_item_post_type_meta_box has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

            function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
                global $_nav_menu_placeholder, $nav_menu_selected_id;
            
                $post_type_name = $post_type['args']->name;
            
            
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-admin/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_get_nav_menu_to_edit has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

            function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
                $menu = wp_get_nav_menu_object( $menu_id );
            
                // If the menu exists, get its items.
                if ( is_nav_menu( $menu ) ) {
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 2 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_nav_menu_item_taxonomy_meta_box has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

            function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) {
                global $nav_menu_selected_id;
                $taxonomy_name = $taxonomy['args']->name;
            
                // paginate browsing for large numbers of objects
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 2 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_save_nav_menu_items has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

            function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) {
                $menu_id = (int) $menu_id;
                $items_saved = array();
            
                if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) {
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 2 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_nav_menu_update_menu_items has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) {
                $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) );
            
                $menu_items = array();
                // Index menu items by db ID
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 2 hrs to fix

              Method wp_save_nav_menu_items has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) {
                  $menu_id = (int) $menu_id;
                  $items_saved = array();
              
                  if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) {
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 1 hr to fix

                Function start_el has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
                        global $_wp_nav_menu_max_depth;
                        $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
                
                        ob_start();
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-admin/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_initial_nav_menu_meta_boxes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                function wp_initial_nav_menu_meta_boxes() {
                    global $wp_meta_boxes;
                
                    if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) )
                        return;
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-admin/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_get_nav_menu_to_edit has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
                    $menu = wp_get_nav_menu_object( $menu_id );
                
                    // If the menu exists, get its items.
                    if ( is_nav_menu( $menu ) ) {
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 1 hr to fix

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

                      function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
                          global $_nav_menu_placeholder;
                  
                          $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
                          $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
                  Severity: Minor
                  Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                                if (
                                    empty( $_item_object_data['menu-item-object-id'] ) && // checkbox is not checked
                                    (
                                        ! isset( $_item_object_data['menu-item-type'] ) || // and item type either isn't set
                                        in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) || // or URL is the default
                    Severity: Major
                    Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 40 mins 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-admin/includes/nav-menu.php - About 35 mins 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-admin/includes/nav-menu.php - About 35 mins to fix

                          Function _wp_nav_menu_meta_box_object has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function _wp_nav_menu_meta_box_object( $object = null ) {
                              if ( isset( $object->name ) ) {
                          
                                  if ( 'page' == $object->name ) {
                                      $object->_default_query = array(
                          Severity: Minor
                          Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 25 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 start_el has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
                                  global $_nav_menu_placeholder;
                          
                                  $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
                                  $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
                          Severity: Minor
                          Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php - About 25 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

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                                      <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
                                          <?php
                                          $args['walker'] = $walker;
                                          echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
                                          ?>
                          Severity: Major
                          Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php and 1 other location - About 1 hr to fix
                          Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php on lines 1010..1019

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

                          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

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                                      <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
                                          <?php
                                          $args['walker'] = $walker;
                                          echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
                                          ?>
                          Severity: Major
                          Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php and 1 other location - About 1 hr to fix
                          Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php on lines 753..762

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

                          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

                              $page_links = paginate_links( array(
                                  'base' => add_query_arg(
                                      array(
                                          $taxonomy_name . '-tab' => 'all',
                                          'paged' => '%#%',
                          Severity: Minor
                          Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php and 1 other location - About 30 mins to fix
                          Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php on lines 657..671

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

                          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

                              $page_links = paginate_links( array(
                                  'base' => add_query_arg(
                                      array(
                                          $post_type_name . '-tab' => 'all',
                                          'paged' => '%#%',
                          Severity: Minor
                          Found in Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php and 1 other location - About 30 mins to fix
                          Web.Admin/2014/wordpress/wp-admin/includes/nav-menu.php on lines 897..911

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

                          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