CaffGeek/MBACNationals

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

Summary

Maintainability
F
1 wk
Test Coverage

File post.php has 911 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WordPress Post Administration API.
 *
 * @package WordPress
Severity: Major
Found in Web.Admin/2014/wordpress/wp-admin/includes/post.php - About 2 days to fix

    Function wp_tiny_mce has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring.
    Open

    function wp_tiny_mce( $teeny = false, $settings = false ) {
        global $concatenate_scripts, $compress_scripts, $tinymce_version;
    
        if ( ! user_can_richedit() )
            return;
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-admin/includes/post.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

    Function bulk_edit_posts has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

    function bulk_edit_posts( $post_data = null ) {
        global $wpdb;
    
        if ( empty($post_data) )
            $post_data = &$_POST;
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-admin/includes/post.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_tiny_mce has 163 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function wp_tiny_mce( $teeny = false, $settings = false ) {
        global $concatenate_scripts, $compress_scripts, $tinymce_version;
    
        if ( ! user_can_richedit() )
            return;
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-admin/includes/post.php - About 6 hrs to fix

      Function _wp_translate_postdata has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

      function _wp_translate_postdata( $update = false, $post_data = null ) {
      
          if ( empty($post_data) )
              $post_data = &$_POST;
      
      
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-admin/includes/post.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

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

      function wp_write_post() {
          global $user_ID;
      
          if ( 'page' == $_POST['post_type'] ) {
              if ( !current_user_can( 'edit_pages' ) )
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-admin/includes/post.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

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

      function edit_post( $post_data = null ) {
      
          if ( empty($post_data) )
              $post_data = &$_POST;
      
      
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-admin/includes/post.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_translate_postdata has 86 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function _wp_translate_postdata( $update = false, $post_data = null ) {
      
          if ( empty($post_data) )
              $post_data = &$_POST;
      
      
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-admin/includes/post.php - About 3 hrs to fix

        Method bulk_edit_posts has 73 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function bulk_edit_posts( $post_data = null ) {
            global $wpdb;
        
            if ( empty($post_data) )
                $post_data = &$_POST;
        Severity: Major
        Found in Web.Admin/2014/wordpress/wp-admin/includes/post.php - About 2 hrs to fix

          Function post_preview has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

          function post_preview() {
          
              $post_ID = (int) $_POST['post_ID'];
              if ( $post_ID < 1 )
                  wp_die( __('Preview not available. Please save as a draft first.') );
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-admin/includes/post.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_write_post has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function wp_write_post() {
              global $user_ID;
          
              if ( 'page' == $_POST['post_type'] ) {
                  if ( !current_user_can( 'edit_pages' ) )
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-admin/includes/post.php - About 2 hrs to fix

            Method edit_post has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function edit_post( $post_data = null ) {
            
                if ( empty($post_data) )
                    $post_data = &$_POST;
            
            
            Severity: Major
            Found in Web.Admin/2014/wordpress/wp-admin/includes/post.php - About 2 hrs to fix

              Function get_sample_permalink_html has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

              function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
                  $post = &get_post($id);
                  list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
              
                  if ( 'publish' == $post->post_status ) {
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-admin/includes/post.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 get_sample_permalink_html has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
                  $post = &get_post($id);
                  list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
              
                  if ( 'publish' == $post->post_status ) {
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-admin/includes/post.php - About 1 hr to fix

                Method wp_edit_posts_query has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function wp_edit_posts_query( $q = false ) {
                    if ( false === $q )
                        $q = $_GET;
                    $q['m']   = isset($q['m']) ? (int) $q['m'] : 0;
                    $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-admin/includes/post.php - About 1 hr to fix

                  Method post_preview has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function post_preview() {
                  
                      $post_ID = (int) $_POST['post_ID'];
                      if ( $post_ID < 1 )
                          wp_die( __('Preview not available. Please save as a draft first.') );
                  Severity: Minor
                  Found in Web.Admin/2014/wordpress/wp-admin/includes/post.php - About 1 hr to fix

                    Method get_sample_permalink has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function get_sample_permalink($id, $title = null, $name = null) {
                        $post = &get_post($id);
                        if (!$post->ID) {
                            return array('', '');
                        }
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-admin/includes/post.php - About 1 hr to fix

                      Function add_meta has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function add_meta( $post_ID ) {
                          global $wpdb;
                          $post_ID = (int) $post_ID;
                      
                          $protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' );
                      Severity: Minor
                      Found in Web.Admin/2014/wordpress/wp-admin/includes/post.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 get_default_post_to_edit has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function get_default_post_to_edit() {
                      
                          $post_title = '';
                          if ( !empty( $_REQUEST['post_title'] ) )
                              $post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));
                      Severity: Minor
                      Found in Web.Admin/2014/wordpress/wp-admin/includes/post.php - About 1 hr to fix

                        Function _fix_attachment_links has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function _fix_attachment_links( $post_ID ) {
                            global $_fix_attachment_link_id;
                        
                            $post = & get_post( $post_ID, ARRAY_A );
                        
                        
                        Severity: Minor
                        Found in Web.Admin/2014/wordpress/wp-admin/includes/post.php - About 45 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 wp_edit_posts_query has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function wp_edit_posts_query( $q = false ) {
                            if ( false === $q )
                                $q = $_GET;
                            $q['m']   = isset($q['m']) ? (int) $q['m'] : 0;
                            $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
                        Severity: Minor
                        Found in Web.Admin/2014/wordpress/wp-admin/includes/post.php - About 45 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 _wp_post_thumbnail_html has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function _wp_post_thumbnail_html( $thumbnail_id = NULL ) {
                            global $content_width, $_wp_additional_image_sizes;
                            $content = '<p class="hide-if-no-js"><a href="#" id="set-post-thumbnail" onclick="jQuery(\'#add_image\').click();return false;">' . esc_html__( 'Set thumbnail' ) . '</a></p>';
                        
                            if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
                        Severity: Minor
                        Found in Web.Admin/2014/wordpress/wp-admin/includes/post.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 0;
                        Severity: Major
                        Found in Web.Admin/2014/wordpress/wp-admin/includes/post.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

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

                            Avoid too many return statements within this method.
                            Open

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

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

                              function postbox_classes( $id, $page ) {
                                  if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id )
                                      return '';
                                  $current_user = wp_get_current_user();
                                  if ( $closed = get_user_option('closedpostboxes_'.$page, 0, false ) ) {
                              Severity: Minor
                              Found in Web.Admin/2014/wordpress/wp-admin/includes/post.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 wp_edit_attachments_query has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                              function wp_edit_attachments_query( $q = false ) {
                                  if ( false === $q )
                                      $q = $_GET;
                              
                                  $q['m']   = isset( $q['m'] ) ? (int) $q['m'] : 0;
                              Severity: Minor
                              Found in Web.Admin/2014/wordpress/wp-admin/includes/post.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 get_sample_permalink has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                              function get_sample_permalink($id, $title = null, $name = null) {
                                  $post = &get_post($id);
                                  if (!$post->ID) {
                                      return array('', '');
                                  }
                              Severity: Minor
                              Found in Web.Admin/2014/wordpress/wp-admin/includes/post.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

                                                  if ( 'en' != $mce_locale && empty($strings) ) {
                                                      if ( @is_file($path . 'en.js') ) {
                                                          $str1 = @file_get_contents($path . 'en.js');
                                                          $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str1, 1 ) . "\n";
                                                      }
                              Severity: Major
                              Found in Web.Admin/2014/wordpress/wp-admin/includes/post.php and 1 other location - About 3 hrs to fix
                              Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php on lines 421..431

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

                              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