HuasoFoundries/jpgraph

View on GitHub

Showing 6,805 of 6,805 total issues

Function AdjDate has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public function AdjDate($aTime, $aRound = 0, $aYearType = false, $aMonthType = false, $aDayType = false)
    {
        $y = (int) date('Y', $aTime);
        $m = (int) date('m', $aTime);
        $d = (int) date('d', $aTime);
Severity: Minor
Found in src/graph/DateScale.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 Stroke has 80 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function Stroke($img, $aaoption = 0)
    {
        $n = safe_count($this->data);

        // If user hasn't set the colors use the theme array
Severity: Major
Found in src/plot/PiePlot3D.php - About 3 hrs to fix

    Method StrokeHours has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function StrokeHours($aYCoord, $getHeight = false)
        {
            $img = $this->iImg;
            $xt  = $img->left_margin + $this->iLabelWidth;
            $yt  = $aYCoord + $img->top_margin;
    Severity: Major
    Found in src/graph/GanttScale.php - About 3 hrs to fix

      GTextTableCell has 27 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class GTextTableCell
      {
          public $iColSpan      = 1;
          public $iRowSpan      = 1;
          public $iMarginLeft   = 5;
      Severity: Minor
      Found in src/text/GTextTableCell.php - About 3 hrs to fix

        Legend has 27 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Legend
        {
            public $txtcol          = [];
            public $font_family     = FF_DEFAULT;
            public $font_style      = FS_NORMAL;
        Severity: Minor
        Found in src/graph/Legend.php - About 3 hrs to fix

          File Text.php has 297 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          /**
           * JPGraph v4.0.3
           */
          Severity: Minor
          Found in src/text/Text.php - About 3 hrs to fix

            Method AutoScale has 78 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function AutoScale($img, $min, $max, $maxsteps, $majend = true)
                {
                    if (!is_numeric($min) || !is_numeric($max)) {
                        Util\JpGraphError::Raise(25044);
                    }
            Severity: Major
            Found in src/graph/LinearScale.php - About 3 hrs to fix

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

                          case GRAD_HOR:
                              $steps = ceil(abs($yb - $yt) + 1);
                              $delta = $yb >= $yt ? 1 : -1;
                              $this->GetColArray($from_color, $to_color, $steps, $colors, $this->numcolors);
                              for ($i = 0, $y = $yt; $i < $steps; ++$i) {
              Severity: Major
              Found in src/plot/Gradient.php and 1 other location - About 3 hrs to fix
              src/plot/Gradient.php on lines 66..76

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

              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 GRAD_VER:
                              $steps = ceil(abs($xr - $xl) + 1);
                              $delta = $xr >= $xl ? 1 : -1;
                              $this->GetColArray($from_color, $to_color, $steps, $colors, $this->numcolors);
                              for ($i = 0, $x = $xl; $i < $steps; ++$i) {
              Severity: Major
              Found in src/plot/Gradient.php and 1 other location - About 3 hrs to fix
              src/plot/Gradient.php on lines 77..87

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

              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

              Function StrokeAxisLabelBackground has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function StrokeAxisLabelBackground()
                  {
                      // Types
                      // 0 = No background
                      // 1 = Only X-labels, length of axis
              Severity: Minor
              Found in src/graph/Graph.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 StrokeTitle has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function StrokeTitle($image, $w, $h)
                  {
                      // Stroke title
                      if ($this->title->t !== '') {
                          $margin = 3;
              Severity: Minor
              Found in src/graph/MGraph.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 Stroke has 77 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function Stroke($pos, $dummy = true)
                  {
                      $this->img->SetLineWeight($this->weight);
                      $this->img->SetColor($this->color);
                      $this->img->SetFont($this->font_family, $this->font_style, $this->font_size);
              Severity: Major
              Found in src/graph/PolarAxis.php - About 3 hrs to fix

                File TTF.php has 293 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                /**
                 * JPGraph v4.0.3
                 */
                Severity: Minor
                Found in src/text/TTF.php - About 3 hrs to fix

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

                                  if (!empty($set[$yt])) {
                                      $nrgb   = imagecolorat($newgdh, $xt, $syt);
                                      $nr     = ($nrgb >> 16) & 0xFF;
                                      $ng     = ($nrgb >> 8) & 0xFF;
                                      $nb     = $nrgb & 0xFF;
                  Severity: Major
                  Found in src/image/ImgTrans.php and 1 other location - About 3 hrs to fix
                  src/image/ImgTrans.php on lines 184..195

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

                  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 (!empty($set[$xt])) {
                                      $nrgb   = imagecolorat($newgdh, $sxt, $yt);
                                      $nr     = ($nrgb >> 16) & 0xFF;
                                      $ng     = ($nrgb >> 8) & 0xFF;
                                      $nb     = $nrgb & 0xFF;
                  Severity: Major
                  Found in src/image/ImgTrans.php and 1 other location - About 3 hrs to fix
                  src/image/ImgTrans.php on lines 101..112

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

                  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

                  File MGraph.php has 292 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  /**
                   * JPGraph v4.0.3
                   */
                  Severity: Minor
                  Found in src/graph/MGraph.php - About 3 hrs to fix

                    Method Raise has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function Raise($aMsg, $aHalt = true)
                        {
                            $img_iconerror =
                                'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAAaV' .
                                'BMVEX//////2Xy8mLl5V/Z2VvMzFi/v1WyslKlpU+ZmUyMjEh/' .
                    Severity: Major
                    Found in src/util/JpGraphErrObjectImg.php - About 3 hrs to fix

                      Method StrokeGrid has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function StrokeGrid($pos)
                          {
                              $x = round($this->img->left_margin + $this->img->plotwidth / 2);
                              $this->scale->ticks->Stroke($this->img, $this->scale, $pos);
                      
                      
                      Severity: Major
                      Found in src/graph/PolarAxis.php - About 3 hrs to fix

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

                            public function PutAndStream($aImage, $aCacheFileName, $aInline, $aStrokeFileName)
                            {
                                // Check if we should always stroke the image to a file
                                if (_FORCE_IMGTOFILE) {
                                    $aStrokeFileName = _FORCE_IMGDIR . Util\Helper::GenImgName();
                        Severity: Major
                        Found in src/image/ImgStreamCache.php - About 2 hrs to fix

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

                              public function DoStroke($aTicksPos, $aType, $aColor, $aWeight)
                              {
                                  $nbrgrids = safe_count($aTicksPos);
                                  if (!$this->show || $nbrgrids === 0) {
                                      return;
                          Severity: Major
                          Found in src/graph/Grid.php - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language