HuasoFoundries/jpgraph

View on GitHub
src/plot/BoxPlot.php

Summary

Maintainability
A
50 mins
Test Coverage

Method ModBox has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function ModBox($img, $xscale, $yscale, $i, $xl, $xr, $neg)
Severity: Major
Found in src/plot/BoxPlot.php - About 50 mins to fix

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

        public function __construct($datay, $datax = false)
    Severity: Minor
    Found in src/plot/BoxPlot.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 ModBox uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $img->SetColor($this->iPColor);
            }
    Severity: Minor
    Found in src/plot/BoxPlot.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

    Avoid unused parameters such as '$xscale'.
    Open

        public function ModBox($img, $xscale, $yscale, $i, $xl, $xr, $neg)
    Severity: Minor
    Found in src/plot/BoxPlot.php by phpmd

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

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

        public function ModBox($img, $xscale, $yscale, $i, $xl, $xr, $neg)
    Severity: Minor
    Found in src/plot/BoxPlot.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 $xr. Configured minimum length is 3.
    Open

        public function ModBox($img, $xscale, $yscale, $i, $xl, $xr, $neg)
    Severity: Minor
    Found in src/plot/BoxPlot.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 = $yscale->Translate($this->coords[0][$i * 5 + 4]);
    Severity: Minor
    Found in src/plot/BoxPlot.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 $i. Configured minimum length is 3.
    Open

        public function ModBox($img, $xscale, $yscale, $i, $xl, $xr, $neg)
    Severity: Minor
    Found in src/plot/BoxPlot.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

    Method name "BoxPlot::SetMedianColor" is not in camel caps format
    Open

        public function SetMedianColor($aPos, $aNeg)
    Severity: Minor
    Found in src/plot/BoxPlot.php by phpcodesniffer

    Method name "BoxPlot::ModBox" is not in camel caps format
    Open

        public function ModBox($img, $xscale, $yscale, $i, $xl, $xr, $neg)
    Severity: Minor
    Found in src/plot/BoxPlot.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status