owncloud/core

View on GitHub
lib/private/legacy/image.php

Summary

Maintainability
F
1 wk
Test Coverage

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

<?php
/**
 * @author Andreas Fischer <bantu@owncloud.com>
 * @author Bartek Przybylski <bart.p.pl@gmail.com>
 * @author Bart Visscher <bartv@thisnet.nl>
Severity: Major
Found in lib/private/legacy/image.php - About 1 day to fix

    Function imagebmp has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring.
    Open

        function imagebmp($im, $fileName = '', $bit = 24, $compression = 0) {
            if (!\in_array($bit, [1, 4, 8, 16, 24, 32])) {
                $bit = 24;
            } elseif ($bit == 32) {
                $bit = 24;
    Severity: Minor
    Found in lib/private/legacy/image.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

    OC_Image has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class OC_Image implements \OCP\IImage {
        /** @var false|resource */
        protected $resource = false; // tmp resource.
        /** @var int */
        protected $imageType = IMAGETYPE_PNG; // Default to png if file type isn't evident.
    Severity: Minor
    Found in lib/private/legacy/image.php - About 4 hrs to fix

      Method imagebmp has 98 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function imagebmp($im, $fileName = '', $bit = 24, $compression = 0) {
              if (!\in_array($bit, [1, 4, 8, 16, 24, 32])) {
                  $bit = 24;
              } elseif ($bit == 32) {
                  $bit = 24;
      Severity: Major
      Found in lib/private/legacy/image.php - About 3 hrs to fix

        Function _output has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            private function _output($filePath = null, $mimeType = null) {
                if ($filePath) {
                    if (!\file_exists(\dirname($filePath))) {
                        \mkdir(\dirname($filePath), 0777, true);
                    }
        Severity: Minor
        Found in lib/private/legacy/image.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 loadFromFile has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            public function loadFromFile($imagePath = false) {
                // exif_imagetype throws "read error!" if file is less than 12 byte
                if (!@\is_file($imagePath) || !\file_exists($imagePath) || \filesize($imagePath) < 12 || !\is_readable($imagePath)) {
                    return false;
                }
        Severity: Minor
        Found in lib/private/legacy/image.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 fixOrientation has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            public function fixOrientation() {
                $o = $this->getOrientation();
                $this->logger->debug('OC_Image->fixOrientation() Orientation: ' . $o, ['app' => 'core']);
                $rotate = 0;
                $flip = false;
        Severity: Minor
        Found in lib/private/legacy/image.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 _output has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function _output($filePath = null, $mimeType = null) {
                if ($filePath) {
                    if (!\file_exists(\dirname($filePath))) {
                        \mkdir(\dirname($filePath), 0777, true);
                    }
        Severity: Major
        Found in lib/private/legacy/image.php - About 2 hrs to fix

          Method loadFromFile has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function loadFromFile($imagePath = false) {
                  // exif_imagetype throws "read error!" if file is less than 12 byte
                  if (!@\is_file($imagePath) || !\file_exists($imagePath) || \filesize($imagePath) < 12 || !\is_readable($imagePath)) {
                      return false;
                  }
          Severity: Major
          Found in lib/private/legacy/image.php - About 2 hrs to fix

            Method fixOrientation has 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function fixOrientation() {
                    $o = $this->getOrientation();
                    $this->logger->debug('OC_Image->fixOrientation() Orientation: ' . $o, ['app' => 'core']);
                    $rotate = 0;
                    $flip = false;
            Severity: Major
            Found in lib/private/legacy/image.php - About 2 hrs to fix

              Function adjustStreamChunkSize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function adjustStreamChunkSize($handle) {
                      $stream = $handle;
                      $metadata = \stream_get_meta_data($stream);
                      while ($metadata['stream_type'] === 'user-space') {
                          \stream_set_chunk_size($stream, 64 * 1024);
              Severity: Minor
              Found in lib/private/legacy/image.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 centerCrop has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function centerCrop($size = 0) {
                      if (!$this->valid()) {
                          $this->logger->error('OC_Image->centerCrop, No image loaded', ['app' => 'core']);
                          return false;
                      }
              Severity: Minor
              Found in lib/private/legacy/image.php - About 1 hr to fix

                Method adjustStreamChunkSize has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function adjustStreamChunkSize($handle) {
                        $stream = $handle;
                        $metadata = \stream_get_meta_data($stream);
                        while ($metadata['stream_type'] === 'user-space') {
                            \stream_set_chunk_size($stream, 64 * 1024);
                Severity: Minor
                Found in lib/private/legacy/image.php - About 1 hr to fix

                  Method preciseResize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function preciseResize($width, $height) {
                          if (!$this->valid()) {
                              $this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
                              return false;
                          }
                  Severity: Minor
                  Found in lib/private/legacy/image.php - About 1 hr to fix

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

                        public function centerCrop($size = 0) {
                            if (!$this->valid()) {
                                $this->logger->error('OC_Image->centerCrop, No image loaded', ['app' => 'core']);
                                return false;
                            }
                    Severity: Minor
                    Found in lib/private/legacy/image.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

                    Avoid deeply nested control flow statements.
                    Open

                                            for ($k = 8 - $bit; $k >= $limit; $k -= $bit) {
                                                $index = \imagecolorat($im, $i, $j);
                                                $bin |= $index << $k;
                                                $i++;
                                            }
                    Severity: Major
                    Found in lib/private/legacy/image.php - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  if ($sameNum != 0) {
                                                      $bmpData .= \chr($sameNum) . \chr($lastIndex);
                                                  }
                      Severity: Major
                      Found in lib/private/legacy/image.php - About 45 mins to fix

                        Function data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function data() {
                                if (!$this->valid()) {
                                    return null;
                                }
                                \ob_start();
                        Severity: Minor
                        Found in lib/private/legacy/image.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

                        Function loadFromBase64 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function loadFromBase64($str) {
                                if (!\is_string($str)) {
                                    return false;
                                }
                                $data = \base64_decode($str);
                        Severity: Minor
                        Found in lib/private/legacy/image.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

                        Function loadExifData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function loadExifData($file) {
                                if (!\is_callable('exif_read_data')) {
                                    $this->logger->debug('OC_Image->loadExifData() Exif module not enabled.', ['app' => 'core']);
                                    return;
                                }
                        Severity: Minor
                        Found in lib/private/legacy/image.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

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

                            public function load($imageRef) {
                                if (\is_resource($imageRef)) {
                                    if (\get_resource_type($imageRef) == 'gd') {
                                        $this->resource = $imageRef;
                                        return $this->resource;
                        Severity: Minor
                        Found in lib/private/legacy/image.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->resource;
                        Severity: Major
                        Found in lib/private/legacy/image.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                  return true;
                          Severity: Major
                          Found in lib/private/legacy/image.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return false;
                            Severity: Major
                            Found in lib/private/legacy/image.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                      return false;
                              Severity: Major
                              Found in lib/private/legacy/image.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                        return false;
                                Severity: Major
                                Found in lib/private/legacy/image.php - About 30 mins to fix

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

                                      private function detectImageTypeFromStream($stream) {
                                          $detectedType = false;
                                  
                                          \rewind($stream);
                                          $bytes = \fread($stream, 2);
                                  Severity: Minor
                                  Found in lib/private/legacy/image.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

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

                                              case IMAGETYPE_GIF:
                                                  if (\imagetypes() & IMG_GIF) {
                                                      $this->resource = \imagecreatefromgif($imagePath);
                                                      // Preserve transparency
                                                      \imagealphablending($this->resource, true);
                                  Severity: Major
                                  Found in lib/private/legacy/image.php and 1 other location - About 1 hr to fix
                                  lib/private/legacy/image.php on lines 645..654

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

                                  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

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

                                              case IMAGETYPE_PNG:
                                                  if (\imagetypes() & IMG_PNG) {
                                                      $this->resource = \imagecreatefrompng($imagePath);
                                                      // Preserve transparency
                                                      \imagealphablending($this->resource, true);
                                  Severity: Major
                                  Found in lib/private/legacy/image.php and 1 other location - About 1 hr to fix
                                  lib/private/legacy/image.php on lines 621..630

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

                                  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

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

                                      public function heightTopLeft() {
                                          $o = $this->getOrientation();
                                          $this->logger->debug('OC_Image->heightTopLeft() Orientation: ' . $o, ['app' => 'core']);
                                          switch ($o) {
                                              case -1:
                                  Severity: Minor
                                  Found in lib/private/legacy/image.php and 1 other location - About 55 mins to fix
                                  lib/private/legacy/image.php on lines 149..166

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

                                  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

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

                                      public function widthTopLeft() {
                                          $o = $this->getOrientation();
                                          $this->logger->debug('OC_Image->widthTopLeft() Orientation: ' . $o, ['app' => 'core']);
                                          switch ($o) {
                                              case -1:
                                  Severity: Minor
                                  Found in lib/private/legacy/image.php and 1 other location - About 55 mins to fix
                                  lib/private/legacy/image.php on lines 173..190

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

                                  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

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

                                          if ($this->imageType == IMAGETYPE_GIF or $this->imageType == IMAGETYPE_PNG) {
                                              \imagecolortransparent($process, \imagecolorallocatealpha($process, 0, 0, 0, 127));
                                              \imagealphablending($process, false);
                                              \imagesavealpha($process, true);
                                          }
                                  Severity: Minor
                                  Found in lib/private/legacy/image.php and 2 other locations - About 30 mins to fix
                                  lib/private/legacy/image.php on lines 833..837
                                  lib/private/legacy/image.php on lines 930..934

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

                                  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

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

                                          if ($this->imageType == IMAGETYPE_GIF or $this->imageType == IMAGETYPE_PNG) {
                                              \imagecolortransparent($process, \imagecolorallocatealpha($process, 0, 0, 0, 127));
                                              \imagealphablending($process, false);
                                              \imagesavealpha($process, true);
                                          }
                                  Severity: Minor
                                  Found in lib/private/legacy/image.php and 2 other locations - About 30 mins to fix
                                  lib/private/legacy/image.php on lines 833..837
                                  lib/private/legacy/image.php on lines 891..895

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

                                  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

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

                                          if ($this->imageType == IMAGETYPE_GIF or $this->imageType == IMAGETYPE_PNG) {
                                              \imagecolortransparent($process, \imagecolorallocatealpha($process, 0, 0, 0, 127));
                                              \imagealphablending($process, false);
                                              \imagesavealpha($process, true);
                                          }
                                  Severity: Minor
                                  Found in lib/private/legacy/image.php and 2 other locations - About 30 mins to fix
                                  lib/private/legacy/image.php on lines 891..895
                                  lib/private/legacy/image.php on lines 930..934

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

                                  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