CaffGeek/MBACNationals

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

Summary

Maintainability
F
6 days
Test Coverage

File media.php has 620 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WordPress API for media display.
 *
 * @package WordPress
Severity: Major
Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 1 day to fix

    Method gallery_shortcode has 94 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function gallery_shortcode($attr) {
        global $post, $wp_locale;
    
        static $instance = 0;
        $instance++;
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 3 hrs to fix

      Function shortcode has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          function shortcode( $attr, $url = '' ) {
              global $post;
      
              if ( empty($url) )
                  return '';
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/media.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 image_get_intermediate_size has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      function image_get_intermediate_size($post_id, $size='thumbnail') {
          if ( !is_array( $imagedata = wp_get_attachment_metadata( $post_id ) ) )
              return false;
      
          // get the best one for a specified set of dimensions
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/media.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 gallery_shortcode has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      function gallery_shortcode($attr) {
          global $post, $wp_locale;
      
          static $instance = 0;
          $instance++;
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/media.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 get_attachment_taxonomies has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      function get_attachment_taxonomies($attachment) {
          if ( is_int( $attachment ) )
              $attachment = get_post($attachment);
          else if ( is_array($attachment) )
              $attachment = (object) $attachment;
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/media.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 image_resize has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) {
      
          $image = wp_load_image( $file );
          if ( !is_resource( $image ) )
              return new WP_Error('error_loading_image', $image);
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/media.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 image_constrain_size_for_editor has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function image_constrain_size_for_editor($width, $height, $size = 'medium') {
          global $content_width, $_wp_additional_image_sizes;
      
          if ( is_array($size) ) {
              $max_width = $size[0];
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/media.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 image_resize has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) {
      
          $image = wp_load_image( $file );
          if ( !is_resource( $image ) )
              return new WP_Error('error_loading_image', $image);
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 1 hr to fix

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

        function image_constrain_size_for_editor($width, $height, $size = 'medium') {
            global $content_width, $_wp_additional_image_sizes;
        
            if ( is_array($size) ) {
                $max_width = $size[0];
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 1 hr to fix

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

              function shortcode( $attr, $url = '' ) {
                  global $post;
          
                  if ( empty($url) )
                      return '';
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 1 hr to fix

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

            function image_get_intermediate_size($post_id, $size='thumbnail') {
                if ( !is_array( $imagedata = wp_get_attachment_metadata( $post_id ) ) )
                    return false;
            
                // get the best one for a specified set of dimensions
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 1 hr to fix

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

              function image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop = false) {
              
                  if ($orig_w <= 0 || $orig_h <= 0)
                      return false;
                  // at least one of dest_w or dest_h must be specific
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/media.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 image_downsize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function image_downsize($id, $size = 'medium') {
              
                  if ( !wp_attachment_is_image($id) )
                      return false;
              
              
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 1 hr to fix

                Method image_resize_dimensions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop = false) {
                
                    if ($orig_w <= 0 || $orig_h <= 0)
                        return false;
                    // at least one of dest_w or dest_h must be specific
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 1 hr to fix

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

                  function image_downsize($id, $size = 'medium') {
                  
                      if ( !wp_attachment_is_image($id) )
                          return false;
                  
                  
                  Severity: Minor
                  Found in Web.Admin/2014/wordpress/wp-includes/media.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

                  Method image_resize has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) {
                  Severity: Major
                  Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 50 mins to fix

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

                    function image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop = false) {
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 35 mins to fix

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

                      function get_image_tag($id, $alt, $title, $align, $size='medium') {
                      Severity: Minor
                      Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 35 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return apply_filters( 'embed_oembed_html', $html, $url, $attr );
                        Severity: Major
                        Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                  return $this->maybe_make_link( $url );
                          Severity: Major
                          Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return function_exists('imagecreatefrompng');
                            Severity: Major
                            Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

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

                                Avoid too many return statements within this method.
                                Open

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

                                  Avoid too many return statements within this method.
                                  Open

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

                                    Avoid too many return statements within this method.
                                    Open

                                                return new WP_Error('resize_path_invalid', __( 'Resize path invalid' ));
                                    Severity: Major
                                    Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                  return new WP_Error('resize_path_invalid', __( 'Resize path invalid' ));
                                      Severity: Major
                                      Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                        return function_exists('imagecreatefromgif');
                                        Severity: Major
                                        Found in Web.Admin/2014/wordpress/wp-includes/media.php - About 30 mins to fix

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

                                                  foreach ( $this->handlers as $priority => $handlers ) {
                                                      foreach ( $handlers as $id => $handler ) {
                                                          if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) {
                                                              if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) )
                                                                  return apply_filters( 'embed_handler_html', $return, $url, $attr );
                                          Severity: Major
                                          Found in Web.Admin/2014/wordpress/wp-includes/media.php and 1 other location - About 1 hr to fix
                                          Web.Admin/2014/wordpress/wp-includes/class-wp-embed.php on lines 157..175

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

                                          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