CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-includes/class-wp-image-editor-gd.php

Summary

Maintainability
C
1 day
Test Coverage

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

    public function multi_resize( $sizes ) {
        $metadata = array();
        $orig_size = $this->size;

        foreach ( $sizes as $size => $size_data ) {
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/class-wp-image-editor-gd.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 _save has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    protected function _save( $image, $filename = null, $mime_type = null ) {
        list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );

        if ( ! $filename )
            $filename = $this->generate_filename( null, null, $extension );
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/class-wp-image-editor-gd.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 _save has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function _save( $image, $filename = null, $mime_type = null ) {
        list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );

        if ( ! $filename )
            $filename = $this->generate_filename( null, null, $extension );
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/class-wp-image-editor-gd.php - About 1 hr to fix

    Method multi_resize has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function multi_resize( $sizes ) {
            $metadata = array();
            $orig_size = $this->size;
    
            foreach ( $sizes as $size => $size_data ) {
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-image-editor-gd.php - About 1 hr to fix

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

          public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) {
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-includes/class-wp-image-editor-gd.php - About 50 mins to fix

        Avoid too many return statements within this method.
        Open

                return array(
                    'path'      => $filename,
                    'file'      => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ),
                    'width'     => $this->size['width'],
                    'height'    => $this->size['height'],
        Severity: Major
        Found in Web.Admin/2014/wordpress/wp-includes/class-wp-image-editor-gd.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return $this->set_quality( $this->quality );
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-includes/class-wp-image-editor-gd.php - About 30 mins to fix

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

                public function load() {
                    if ( $this->image )
                        return true;
            
                    if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) )
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/class-wp-image-editor-gd.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

            There are no issues that match your filters.

            Category
            Status