HuasoFoundries/jpgraph

View on GitHub
src/graph/RadarGrid.php

Summary

Maintainability
F
6 days
Test Coverage

Method Stroke has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function Stroke($img, $pos, $scale, $startangle)
    {
        $nbrpnts = safe_count($this->data);
        $astep   = 2 * M_PI / $nbrpnts;
        $a       = $startangle;
Severity: Minor
Found in src/graph/RadarGrid.php - About 1 hr to fix

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

        public function Stroke($img, $pos, $scale, $startangle)
        {
            $nbrpnts = safe_count($this->data);
            $astep   = 2 * M_PI / $nbrpnts;
            $a       = $startangle;
    Severity: Minor
    Found in src/graph/RadarGrid.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 Stroke has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function Stroke($img, $grid)
        {
            if (!$this->show) {
                return;
            }
    Severity: Minor
    Found in src/graph/RadarGrid.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 Stroke has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function Stroke($img, $grid)
        {
            if (!$this->show) {
                return;
            }
    Severity: Minor
    Found in src/graph/RadarGrid.php - About 1 hr to fix

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

                          $this->mark->Stroke($img, $pnts[$i * 2], $pnts[$i * 2 + 1]);
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

              $pnts[] = $pnts[0];
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

                          $this->mark->SetCSIMAltVal($pnts[$i * 2], $pnts[$i * 2 + 1]);
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

                          $this->mark->Stroke($img, $pnts[$i * 2], $pnts[$i * 2 + 1]);
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

                          $this->mark->Stroke($img, $pnts[$i * 2], $pnts[$i * 2 + 1]);
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

                  $img->FilledPolygon($pnts);
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

                  $pnts[$i * 2]     = $x;
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

              $pnts[] = $pnts[1];
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

              $pnts[] = $pnts[0];
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

              $pnts[] = $pnts[1];
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

                          $this->mark->SetCSIMAltVal($pnts[$i * 2], $pnts[$i * 2 + 1]);
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

                          $this->mark->Stroke($img, $pnts[$i * 2], $pnts[$i * 2 + 1]);
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

                          $pnts[$i * 2 + 1] = $y;
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

                          $pnts[$i * 2]     = $x;
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

              $img->Polygon($pnts);
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$pnts' which will lead to PHP notices.
      Open

                  $pnts[$i * 2 + 1] = $y;
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      The method Show has a boolean flag argument $aShowMajor, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public function Show($aShowMajor = true)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

      Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

      The method SetColor has a boolean flag argument $aFillColor, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public function SetColor($aColor, $aFillColor = false)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

      Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

      The method SetFill has a boolean flag argument $f, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public function SetFill($f = true)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

      Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

      The method Stroke uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                      } else {
                          $this->mark->Stroke($img, $pnts[$i * 2], $pnts[$i * 2 + 1]);
                      }
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The method Legend uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $graph->legend->Add($this->legend, $this->color, $this->mark);
              }
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

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

      class RadarPlot
      {
          public $mark;
          public $legend           = '';
          public $legendcsimtarget = '';
      Severity: Major
      Found in src/graph/RadarGrid.php and 1 other location - About 6 days to fix
      src/plot/RadarPlot.php on lines 13..177

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

      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

      Avoid variables with short names like $l. Configured minimum length is 3.
      Open

                      $l = ($k + 1) % $nbrpnts;
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      Avoid variables with short names like $f. Configured minimum length is 3.
      Open

          public function SetFill($f = true)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      Avoid variables with short names like $cs. Configured minimum length is 3.
      Open

                  $cs = $scale->RelTranslate($this->data[$i]);
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      Avoid variables with short names like $x. Configured minimum length is 3.
      Open

                  $x  = round($cs * cos($a) + $scale->scale_abs[0]);
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      Avoid variables with short names like $y. Configured minimum length is 3.
      Open

                  $y  = round($pos - $cs * sin($a));
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      Avoid variables with short names like $a. Configured minimum length is 3.
      Open

              $a       = $startangle;
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      Avoid variables with short names like $w. Configured minimum length is 3.
      Open

          public function SetLineWeight($w)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      Each class must be in a file by itself
      Open

      class RadarPlot
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarPlot::GetCount" is not in camel caps format
      Open

          public function GetCount()
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarPlot::Max" is not in camel caps format
      Open

          public function Max()
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarPlot::SetLegend" is not in camel caps format
      Open

          public function SetLegend($legend)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarPlot::Min" is not in camel caps format
      Open

          public function Min()
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarPlot::SetCSIMTargets" is not in camel caps format
      Open

          public function SetCSIMTargets($aTargets, $aAlts = null)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarPlot::Legend" is not in camel caps format
      Open

          public function Legend($graph)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarGrid::SetColor" is not in camel caps format
      Open

          public function SetColor($aMajColor)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarGrid::SetLineStyle" is not in camel caps format
      Open

          public function SetLineStyle($aType)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarPlot::SetLineWeight" is not in camel caps format
      Open

          public function SetLineWeight($w)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarPlot::SetColor" is not in camel caps format
      Open

          public function SetColor($aColor, $aFillColor = false)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarGrid::Show" is not in camel caps format
      Open

          public function Show($aShowMajor = true)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarPlot::GetCSIMareas" is not in camel caps format
      Open

          public function GetCSIMareas()
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarGrid::SetWeight" is not in camel caps format
      Open

          public function SetWeight($aWeight)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarPlot::SetFillColor" is not in camel caps format
      Open

          public function SetFillColor($aColor)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarGrid::Stroke" is not in camel caps format
      Open

          public function Stroke($img, $grid)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarPlot::Stroke" is not in camel caps format
      Open

          public function Stroke($img, $pos, $scale, $startangle)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarPlot::SetLineStyle" is not in camel caps format
      Open

          public function SetLineStyle($aStyle)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      Method name "RadarPlot::SetFill" is not in camel caps format
      Open

          public function SetFill($f = true)
      Severity: Minor
      Found in src/graph/RadarGrid.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status