mambax7/pedigree

View on GitHub
phpthumb/phpthumb.bmp.php

Summary

Maintainability
F
1 wk
Test Coverage

Function getid3_bmp has a Cognitive Complexity of 174 (exceeds 5 allowed). Consider refactoring.
Open

    public function getid3_bmp(&$BMPdata, &$ThisFileInfo, $ExtractPalette = false, $ExtractData = false)
    {
        // shortcuts
        $ThisFileInfo['bmp']['header']['raw'] = [];
        $thisfile_bmp                         = &$ThisFileInfo['bmp'];
Severity: Minor
Found in phpthumb/phpthumb.bmp.php - About 3 days 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 getid3_bmp has 423 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getid3_bmp(&$BMPdata, &$ThisFileInfo, $ExtractPalette = false, $ExtractData = false)
    {
        // shortcuts
        $ThisFileInfo['bmp']['header']['raw'] = [];
        $thisfile_bmp                         = &$ThisFileInfo['bmp'];
Severity: Major
Found in phpthumb/phpthumb.bmp.php - About 2 days to fix

    File phpthumb.bmp.php has 643 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /////////////////////////////////////////////////////////////////
    /// getID3() by James Heinrich <info@getid3.org>               //
    //  available at http://getid3.sourceforge.net                 //
    //            or http://www.getid3.org                         //
    Severity: Major
    Found in phpthumb/phpthumb.bmp.php - About 1 day to fix

      Function PlotPixelsGD has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          public function PlotPixelsGD(&$BMPdata, $truecolor = true)
          {
              $imagewidth  = $BMPdata['header']['raw']['width'];
              $imageheight = $BMPdata['header']['raw']['height'];
      
      
      Severity: Minor
      Found in phpthumb/phpthumb.bmp.php - About 4 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 PlotPixelsGD has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function PlotPixelsGD(&$BMPdata, $truecolor = true)
          {
              $imagewidth  = $BMPdata['header']['raw']['width'];
              $imageheight = $BMPdata['header']['raw']['height'];
      
      
      Severity: Minor
      Found in phpthumb/phpthumb.bmp.php - About 1 hr to fix

        Method GD2BMPstring has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function GD2BMPstring(&$gd_image)
            {
                $imageX = imagesx($gd_image);
                $imageY = imagesy($gd_image);
        
        
        Severity: Minor
        Found in phpthumb/phpthumb.bmp.php - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                                          for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col = $col) {
                                              $paletteindexbyte = ord($BMPpixelData[$pixeldataoffset++]);
                                              for ($i = 1; $i >= 0; $i--) {
                                                  $paletteindex                     = ($paletteindexbyte & (0x0F << (4 * $i))) >> (4 * $i);
                                                  $thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
          Severity: Major
          Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                            while (($pixeldataoffset % 4) != 0) {
                                                // lines are padded to nearest DWORD
                                                $pixeldataoffset++;
                                            }
            Severity: Major
            Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                              while (($pixeldataoffset % 4) != 0) {
                                                  // lines are padded to nearest DWORD
                                                  $pixeldataoffset++;
                                              }
              Severity: Major
              Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                                for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
                                                    $paletteindex                     = ord($BMPpixelData[$pixeldataoffset++]);
                                                    $thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
                                                }
                Severity: Major
                Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                                  for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
                                                      $thisfile_bmp['data'][$row][$col] = (ord($BMPpixelData[$pixeldataoffset + 2]) << 16) | (ord($BMPpixelData[$pixeldataoffset + 1]) << 8) | ord($BMPpixelData[$pixeldataoffset]);
                                                      $pixeldataoffset                  += 3;
                                                  }
                  Severity: Major
                  Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                    while (($pixeldataoffset % 4) != 0) {
                                                        // lines are padded to nearest DWORD
                                                        $pixeldataoffset++;
                                                    }
                    Severity: Major
                    Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                      for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
                                                          $thisfile_bmp['data'][$row][$col] = (ord($BMPpixelData[$pixeldataoffset + 3]) << 24) | (ord($BMPpixelData[$pixeldataoffset + 2]) << 16) | (ord($BMPpixelData[$pixeldataoffset + 1]) << 8) | ord($BMPpixelData[$pixeldataoffset]);
                                                          $pixeldataoffset                  += 4;
                                                      }
                      Severity: Major
                      Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                        for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col = $col) {
                                                            $paletteindexbyte = ord($BMPpixelData[$pixeldataoffset++]);
                                                            for ($i = 7; $i >= 0; $i--) {
                                                                $paletteindex                     = ($paletteindexbyte & (0x01 << $i)) >> $i;
                                                                $thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
                        Severity: Major
                        Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                          while (($pixeldataoffset % 4) != 0) {
                                                              // lines are padded to nearest DWORD
                                                              $pixeldataoffset++;
                                                          }
                          Severity: Major
                          Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                            while (($pixeldataoffset % 4) != 0) {
                                                                // lines are padded to nearest DWORD
                                                                $pixeldataoffset++;
                                                            }
                            Severity: Major
                            Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                              while (($pixeldataoffset % 4) != 0) {
                                                                  // lines are padded to nearest DWORD
                                                                  $pixeldataoffset++;
                                                              }
                              Severity: Major
                              Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                                for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
                                                                    $pixelvalue      = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset, $thisfile_bmp_header_raw['bits_per_pixel'] / 8));
                                                                    $pixeldataoffset += $thisfile_bmp_header_raw['bits_per_pixel'] / 8;
                                
                                                                    $red                              = (int)round(((($pixelvalue & $thisfile_bmp_header_raw['red_mask']) >> $redshift) / ($thisfile_bmp_header_raw['red_mask'] >> $redshift)) * 255);
                                Severity: Major
                                Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                                      for ($i = 0; $i < $firstbyte; $i++) {
                                                                          $col                              = $pixelcounter % $thisfile_bmp_header_raw['width'];
                                                                          $row                              = $thisfile_bmp_header_raw['height'] - 1 - (($pixelcounter - $col) / $thisfile_bmp_header_raw['width']);
                                                                          $thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$secondbyte];
                                                                          $pixelcounter++;
                                  Severity: Major
                                  Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                                        for ($i = 0; $i < $firstbyte; $i++) {
                                                                            $col                              = $pixelcounter % $thisfile_bmp_header_raw['width'];
                                                                            $row                              = $thisfile_bmp_header_raw['height'] - 1 - (($pixelcounter - $col) / $thisfile_bmp_header_raw['width']);
                                                                            $thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindexes[$i % 2]];
                                                                            $pixelcounter++;
                                    Severity: Major
                                    Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                                          switch ($secondbyte) {
                                                                              case 0:
                                                                                  // end of line
                                                                                  // no need for special processing, just ignore
                                                                                  break;
                                      Severity: Major
                                      Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                                            switch ($secondbyte) {
                                                                                case 0:
                                                                                    // end of line
                                                                                    // no need for special processing, just ignore
                                                                                    break;
                                        Severity: Major
                                        Found in phpthumb/phpthumb.bmp.php - About 45 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                  return true;
                                          Severity: Major
                                          Found in phpthumb/phpthumb.bmp.php - About 30 mins to fix

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

                                                                                    case 2:
                                                                                        // delta - The 2 bytes following the escape contain unsigned values
                                                                                        // indicating the horizontal and vertical offsets of the next pixel
                                                                                        // from the current position.
                                                                                        $colincrement = $this->LittleEndian2Int($BMPpixelData[$pixeldataoffset++]);
                                            Severity: Major
                                            Found in phpthumb/phpthumb.bmp.php and 1 other location - About 1 hr to fix
                                            phpthumb/phpthumb.bmp.php on lines 560..569

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

                                            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 2 locations. Consider refactoring.
                                            Open

                                                                                    case 2:
                                                                                        // delta - The 2 bytes following the escape contain unsigned values
                                                                                        // indicating the horizontal and vertical offsets of the next pixel
                                                                                        // from the current position.
                                                                                        $colincrement = $this->LittleEndian2Int($BMPpixelData[$pixeldataoffset++]);
                                            Severity: Major
                                            Found in phpthumb/phpthumb.bmp.php and 1 other location - About 1 hr to fix
                                            phpthumb/phpthumb.bmp.php on lines 490..499

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

                                            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