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');
- Read upRead up
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
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']);
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');
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;
- Read upRead up
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;
- Read upRead up
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;
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;
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']);
- Read upRead up
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) ) )
- Read upRead up
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) ) )
Method _crop_image_resource
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function _crop_image_resource($img, $x, $y, $w, $h) {
Avoid too many return
statements within this method. Open
return $return;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $return;