CaffGeek/MBACNationals

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

Summary

Maintainability
F
6 days
Test Coverage

Function wp_save_image has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring.
Open

function wp_save_image($post_id) {
    $return = '';
    $success = $delete = $scaled = $nocrop = false;
    $post = get_post($post_id);
    @ini_set('memory_limit', '256M');
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-admin/includes/image-edit.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

File image-edit.php has 548 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WordPress Image Editor
 *
 * @package WordPress
Severity: Major
Found in Web.Admin/2014/wordpress/wp-admin/includes/image-edit.php - About 1 day to fix

    Method wp_image_editor has 155 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function wp_image_editor($post_id, $msg = false) {
        $nonce = wp_create_nonce("image_editor-$post_id");
        $meta = wp_get_attachment_metadata($post_id);
        $thumb = image_get_intermediate_size($post_id, 'thumbnail');
        $sub_sizes = isset($meta['sizes']) && is_array($meta['sizes']);
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-admin/includes/image-edit.php - About 6 hrs to fix

      Method wp_save_image has 139 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function wp_save_image($post_id) {
          $return = '';
          $success = $delete = $scaled = $nocrop = false;
          $post = get_post($post_id);
          @ini_set('memory_limit', '256M');
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-admin/includes/image-edit.php - About 5 hrs to fix

        Function wp_restore_image has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

        function wp_restore_image($post_id) {
            $meta = wp_get_attachment_metadata($post_id);
            $file = get_attached_file($post_id);
            $backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
            $restored = false;
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-admin/includes/image-edit.php - About 5 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_edit_apply_changes has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        function image_edit_apply_changes($img, $changes) {
        
            if ( !is_array($changes) )
                return $img;
        
        
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-admin/includes/image-edit.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_restore_image has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function wp_restore_image($post_id) {
            $meta = wp_get_attachment_metadata($post_id);
            $file = get_attached_file($post_id);
            $backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
            $restored = false;
        Severity: Major
        Found in Web.Admin/2014/wordpress/wp-admin/includes/image-edit.php - About 2 hrs to fix

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

          function image_edit_apply_changes($img, $changes) {
          
              if ( !is_array($changes) )
                  return $img;
          
          
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-admin/includes/image-edit.php - About 2 hrs to fix

            Function wp_image_editor has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

            function wp_image_editor($post_id, $msg = false) {
                $nonce = wp_create_nonce("image_editor-$post_id");
                $meta = wp_get_attachment_metadata($post_id);
                $thumb = image_get_intermediate_size($post_id, 'thumbnail');
                $sub_sizes = isset($meta['sizes']) && is_array($meta['sizes']);
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-admin/includes/image-edit.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 load_image_to_edit has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            function load_image_to_edit($post_id, $mime_type, $size = 'full') {
                $filepath = get_attached_file($post_id);
            
                if ( $filepath && file_exists($filepath) ) {
                    if ( 'full' != $size && ( $data = image_get_intermediate_size($post_id, $size) ) )
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-admin/includes/image-edit.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 load_image_to_edit has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function load_image_to_edit($post_id, $mime_type, $size = 'full') {
                $filepath = get_attached_file($post_id);
            
                if ( $filepath && file_exists($filepath) ) {
                    if ( 'full' != $size && ( $data = image_get_intermediate_size($post_id, $size) ) )
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-admin/includes/image-edit.php - About 1 hr to fix

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

              function _crop_image_resource($img, $x, $y, $w, $h) {
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-admin/includes/image-edit.php - About 35 mins to fix

                Avoid too many return statements within this method.
                Open

                        return $return;
                Severity: Major
                Found in Web.Admin/2014/wordpress/wp-admin/includes/image-edit.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-admin/includes/image-edit.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

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

                      There are no issues that match your filters.

                      Category
                      Status