mambax7/pedigree

View on GitHub
phpthumb/phpthumb.gif.php

Summary

Maintainability
F
1 wk
Test Coverage

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

<?php
///////////////////////////////////////////////////////////////////////////////////////////////////
// GIF Util - (C) 2003 Yamasoft (S/C)
// http://www.yamasoft.com
// All Rights Reserved
Severity: Major
Found in phpthumb/phpthumb.gif.php - About 2 days to fix

    Function getBmp has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getBmp($bgColor)
        {
            $out = '';
    
            if (!$this->m_bLoaded) {
    Severity: Minor
    Found in phpthumb/phpthumb.gif.php - About 5 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 LZWCommand has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        public function LZWCommand(&$data, $bInit)
        {
            if ($bInit) {
                $this->SetCodeSize = ord($data[0]);
                $data              = substr($data, 1);
    Severity: Minor
    Found in phpthumb/phpthumb.gif.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

    Function getPng has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getPng($bgColor)
        {
            $out = '';
    
            if (!$this->m_bLoaded) {
    Severity: Minor
    Found in phpthumb/phpthumb.gif.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 LZWCommand has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function LZWCommand(&$data, $bInit)
        {
            if ($bInit) {
                $this->SetCodeSize = ord($data[0]);
                $data              = substr($data, 1);
    Severity: Major
    Found in phpthumb/phpthumb.gif.php - About 3 hrs to fix

      Method getBmp has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getBmp($bgColor)
          {
              $out = '';
      
              if (!$this->m_bLoaded) {
      Severity: Major
      Found in phpthumb/phpthumb.gif.php - About 2 hrs to fix

        Method getPng has 73 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getPng($bgColor)
            {
                $out = '';
        
                if (!$this->m_bLoaded) {
        Severity: Major
        Found in phpthumb/phpthumb.gif.php - About 2 hrs to fix

          Function getGD_PixelPlotterVersion has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getGD_PixelPlotterVersion()
              {
                  if (!$this->m_bLoaded) {
                      return false;
                  }
          Severity: Minor
          Found in phpthumb/phpthumb.gif.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 gif_outputAsJpeg has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

          function gif_outputAsJpeg($gif, $lpszFileName, $bgColor = -1)
          {
              // JPEG output that does not require cjpeg added by James Heinrich <info@silisoftware.com> - December 10, 2003
              if ((strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') && (file_exists('/usr/local/bin/cjpeg') || shell_exec('which cjpeg'))) {
                  if (gif_outputAsBmp($gif, $lpszFileName . '.bmp', $bgColor)) {
          Severity: Minor
          Found in phpthumb/phpthumb.gif.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

          Method getGD_PixelPlotterVersion has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getGD_PixelPlotterVersion()
              {
                  if (!$this->m_bLoaded) {
                      return false;
                  }
          Severity: Minor
          Found in phpthumb/phpthumb.gif.php - About 1 hr to fix

            Function GetCode has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                public function GetCode(&$data, $bInit)
                {
                    if ($bInit) {
                        $this->CurBit   = 0;
                        $this->LastBit  = 0;
            Severity: Minor
            Found in phpthumb/phpthumb.gif.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 GetCode has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function GetCode(&$data, $bInit)
                {
                    if ($bInit) {
                        $this->CurBit   = 0;
                        $this->LastBit  = 0;
            Severity: Minor
            Found in phpthumb/phpthumb.gif.php - About 1 hr to fix

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

                  public function load($data, &$datLen)
                  {
                      $datLen = 0;
              
                      while (true) {
              Severity: Minor
              Found in phpthumb/phpthumb.gif.php - About 1 hr to fix

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

                    public function skipExt(&$data, &$extLen)
                    {
                        $extLen = 0;
                
                        $b    = ord($data[0]);
                Severity: Minor
                Found in phpthumb/phpthumb.gif.php - About 1 hr to fix

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

                      public function load($data, &$datLen)
                      {
                          $datLen = 0;
                  
                          while (true) {
                  Severity: Minor
                  Found in phpthumb/phpthumb.gif.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 deInterlace has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function deInterlace()
                      {
                          $data = $this->m_data;
                          $s    = 0;
                          $y    = 0;
                  Severity: Minor
                  Found in phpthumb/phpthumb.gif.php - About 1 hr to fix

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

                        public function load($lpData, &$hdrLen)
                        {
                            $hdrLen = 0;
                    
                            $this->m_lpVer = substr($lpData, 0, 6);
                    Severity: Minor
                    Found in phpthumb/phpthumb.gif.php - About 1 hr to fix

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

                          public function deInterlace()
                          {
                              $data = $this->m_data;
                              $s    = 0;
                              $y    = 0;
                      Severity: Minor
                      Found in phpthumb/phpthumb.gif.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($lpData, &$hdrLen)
                          {
                              $hdrLen = 0;
                      
                              $this->m_lpVer = substr($lpData, 0, 6);
                      Severity: Minor
                      Found in phpthumb/phpthumb.gif.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 true;
                      Severity: Major
                      Found in phpthumb/phpthumb.gif.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

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

                          Avoid too many return statements within this method.
                          Open

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

                            Avoid too many return statements within this method.
                            Open

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

                              Avoid too many return statements within this method.
                              Open

                                              return $this->Stack[$this->sp];
                              Severity: Major
                              Found in phpthumb/phpthumb.gif.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                        return $Code;
                                Severity: Major
                                Found in phpthumb/phpthumb.gif.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

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

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

                                    function gif_getSize($gif, &$width, &$height)
                                    {
                                        if (isset($gif) && (@get_class($gif) == 'cgif') && $gif->loaded()) {
                                            $width  = $gif->width();
                                            $height = $gif->height();
                                    Severity: Minor
                                    Found in phpthumb/phpthumb.gif.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

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

                                    function gif_loadFileToGDimageResource($gifFilename, $bgColor = -1)
                                    {
                                        if ($gif = gif_loadFile($gifFilename)) {
                                            if (!phpthumb_functions::FunctionIsDisabled('set_time_limit')) {
                                                // shouldn't take nearly this long
                                    Severity: Minor
                                    Found in phpthumb/phpthumb.gif.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

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

                                        public function skipExt(&$data, &$extLen)
                                        {
                                            $extLen = 0;
                                    
                                            $b    = ord($data[0]);
                                    Severity: Minor
                                    Found in phpthumb/phpthumb.gif.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

                                    function gif_outputAsBmp($gif, $lpszFileName, $bgColor = -1)
                                    {
                                        if (!isset($gif) || (@get_class($gif) <> 'cgif') || !$gif->loaded() || ($lpszFileName == '')) {
                                            return false;
                                        }
                                    Severity: Major
                                    Found in phpthumb/phpthumb.gif.php and 1 other location - About 5 hrs to fix
                                    phpthumb/phpthumb.gif.php on lines 84..102

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

                                    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

                                    function gif_outputAsPng($gif, $lpszFileName, $bgColor = -1)
                                    {
                                        if (!isset($gif) || (@get_class($gif) <> 'cgif') || !$gif->loaded() || ($lpszFileName == '')) {
                                            return false;
                                        }
                                    Severity: Major
                                    Found in phpthumb/phpthumb.gif.php and 1 other location - About 5 hrs to fix
                                    phpthumb/phpthumb.gif.php on lines 62..80

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

                                    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

                                            if ($this->m_img->m_gih->m_bLocalClr) {
                                                $nColors = $this->m_img->m_gih->m_nTableSize;
                                                $pal     = $this->m_img->m_gih->m_colorTable->toString();
                                                if ($bgColor != -1) {
                                                    $bgColor = $this->m_img->m_gih->m_colorTable->colorIndex($bgColor);
                                    Severity: Major
                                    Found in phpthumb/phpthumb.gif.php and 1 other location - About 3 hrs to fix
                                    phpthumb/phpthumb.gif.php on lines 860..876

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

                                    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

                                            if ($this->m_img->m_gih->m_bLocalClr) {
                                                $nColors = $this->m_img->m_gih->m_nTableSize;
                                                $rgbq    = $this->m_img->m_gih->m_colorTable->toRGBQuad();
                                                if ($bgColor != -1) {
                                                    $bgColor = $this->m_img->m_gih->m_colorTable->colorIndex($bgColor);
                                    Severity: Major
                                    Found in phpthumb/phpthumb.gif.php and 1 other location - About 3 hrs to fix
                                    phpthumb/phpthumb.gif.php on lines 959..975

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

                                    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