CaffGeek/MBACNationals

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

Summary

Maintainability
C
1 day
Test Coverage

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

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

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 class-wp-image-editor-imagick.php has 263 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WordPress Imagick Image Editor
 *
 * @package WordPress

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

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

      Method test has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function test( $args = array() ) {
      
              // First, test Imagick's extension and classes.
              if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick' ) || ! class_exists( 'ImagickPixel' ) )
                  return false;

        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-imagick.php - About 50 mins to fix

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

              public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) {
                  if ( $src_abs ) {
                      $src_w -= $src_x;
                      $src_h -= $src_y;
                  }
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/class-wp-image-editor-imagick.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 load has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function load() {
                  if ( $this->image instanceof Imagick )
                      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-imagick.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 $this->update_size( $dst_w, $dst_h );
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-includes/class-wp-image-editor-imagick.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

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

              Avoid too many return statements within this method.
              Open

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

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

                      protected function update_size( $width = null, $height = null ) {
                          $size = null;
                          if ( !$width || !$height ) {
                              try {
                                  $size = $this->image->getImageGeometry();
                  Severity: Minor
                  Found in Web.Admin/2014/wordpress/wp-includes/class-wp-image-editor-imagick.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