autowp/image

View on GitHub

Showing 44 of 100 total issues

Function convertByInnerFit has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private function convertByInnerFit(Imagick $imagick, Sampler\Format $format): Imagick
    {
        $srcWidth  = $imagick->getImageWidth();
        $srcHeight = $imagick->getImageHeight();
        $srcRatio  = $srcWidth / $srcHeight;
Severity: Minor
Found in src/Sampler.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

Function getFormatedImageRows has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private function getFormatedImageRows(array $imagesId, string $formatName): array
    {
        $destImageRows = [];
        if (count($imagesId)) {
            $select = $this->imageTable->getSql()->select()
Severity: Minor
Found in src/Storage.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 convertByInnerFit has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function convertByInnerFit(Imagick $imagick, Sampler\Format $format): Imagick
    {
        $srcWidth  = $imagick->getImageWidth();
        $srcHeight = $imagick->getImageHeight();
        $srcRatio  = $srcWidth / $srcHeight;
Severity: Minor
Found in src/Sampler.php - About 1 hr to fix

    Method generateLockWrite has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function generateLockWrite(string $dirName, array $options, int $width, int $height, Closure $callback): int
        {
            $insertAttemptException = null;
            $imageId                = 0;
            $attemptIndex           = 0;
    Severity: Minor
    Found in src/Storage.php - About 1 hr to fix

      Function setImageCrop has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setImageCrop(int $imageId, ?array $crop): void
          {
              if (! $imageId) {
                  throw new Storage\Exception("Invalid image id provided `$imageId`");
              }
      Severity: Minor
      Found in src/Storage.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

      Function extendVertical has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          private function extendVertical(Imagick $imagick, Sampler\Format $format): void
          {
              $fRatio = (int) $format->getWidth() / (int) $format->getHeight();
      
              $srcWidth  = $imagick->getImageWidth();
      Severity: Minor
      Found in src/Sampler.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

      Function convertByMaximumFit has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          private function convertByMaximumFit(Imagick $imagick, Sampler\Format $format): Imagick
          {
              $srcWidth  = $imagick->getImageWidth();
              $srcHeight = $imagick->getImageHeight();
              $srcRatio  = $srcWidth / $srcHeight;
      Severity: Minor
      Found in src/Sampler.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

      Function convertByOuterFit has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          private function convertByOuterFit(Imagick $imagick, Sampler\Format $format): Imagick
          {
              $srcWidth  = $imagick->getImageWidth();
              $srcHeight = $imagick->getImageHeight();
              $srcRatio  = $srcWidth / $srcHeight;
      Severity: Minor
      Found in src/Sampler.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

      Function extendHorizontal has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          private function extendHorizontal(Imagick $imagick, Sampler\Format $format): void
          {
              $fRatio = (int) $format->getWidth() / (int) $format->getHeight();
      
              $srcWidth  = $imagick->getImageWidth();
      Severity: Minor
      Found in src/Sampler.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 convertByMaximumFit has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function convertByMaximumFit(Imagick $imagick, Sampler\Format $format): Imagick
          {
              $srcWidth  = $imagick->getImageWidth();
              $srcHeight = $imagick->getImageHeight();
              $srcRatio  = $srcWidth / $srcHeight;
      Severity: Minor
      Found in src/Sampler.php - About 1 hr to fix

        Method extendEdgeColor has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function extendEdgeColor(ImagickPixelIterator $iterator): ?ImagickPixel
            {
                $sum = [
                    'r' => [],
                    'g' => [],
        Severity: Minor
        Found in src/Sampler.php - About 1 hr to fix

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

              public function flush(array $options): StorageInterface
              {
                  $defaults = [
                      'format' => null,
                      'image'  => null,
          Severity: Minor
          Found in src/Storage.php - About 1 hr to fix

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

                public function flop(int $imageId): void
                {
                    $imageRow = $this->getImageRow($imageId);
            
                    if (! $imageRow) {
            Severity: Minor
            Found in src/Storage.php - About 1 hr to fix

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

                  public function normalize(int $imageId): void
                  {
                      $imageRow = $this->getImageRow($imageId);
              
                      if (! $imageRow) {
              Severity: Minor
              Found in src/Storage.php - About 1 hr to fix

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

                    private function buildImageResult($imageRow): Storage\Image
                    {
                        $dir = $this->getDir($imageRow['dir']);
                        if (! $dir) {
                            throw new Storage\Exception("Dir '{$imageRow['dir']}' not defined");
                Severity: Minor
                Found in src/Storage.php - About 1 hr to fix

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

                      public function addImageFromFile(string $file, string $dirName, array $options = []): int
                      {
                          $imageInfo = getimagesize($file);
                  
                          $width  = (int) $imageInfo[0];
                  Severity: Minor
                  Found in src/Storage.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

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

                      public function addImageFromImagick(Imagick $imagick, string $dirName, array $options = []): int
                      {
                          $width  = $imagick->getImageWidth();
                          $height = $imagick->getImageHeight();
                  
                  
                  Severity: Minor
                  Found in src/Storage.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 changeImageName has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function changeImageName(int $imageId, array $options = []): void
                      {
                          $imageRow = $this->getImageRow($imageId);
                          if (! $imageRow) {
                              throw new Storage\Exception("Image `$imageId` not found");
                  Severity: Minor
                  Found in src/Storage.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

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

                      private function generateLockWrite(string $dirName, array $options, int $width, int $height, Closure $callback): int
                  Severity: Minor
                  Found in src/Storage.php - About 35 mins to fix

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

                        private function crop(Imagick $imagick, int $width, int $height, int $left, int $top): Imagick
                    Severity: Minor
                    Found in src/Sampler.php - About 35 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language