HuasoFoundries/jpgraph

View on GitHub

Showing 6,805 of 6,805 total issues

Avoid unused local variables such as '$w'.
Open

                        list($tot, $w) = $this->iObj[$i]->title->GetWidth($this->img, true);
Severity: Minor
Found in src/graph/GanttGraph.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

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

The method StrokeDays 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->day->iTextColor);
                }
Severity: Minor
Found in src/graph/GanttScale.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 local variables such as '$wdays'.
Open

            $wdays     = $this->iDateLocale->GetDayAbb();
Severity: Minor
Found in src/graph/GanttScale.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

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

Avoid using static access to class '\Amenadiel\JpGraph\Util\JpGraphError' in method 'Stroke'.
Open

            Util\JpGraphError::RaiseL(6023);
Severity: Minor
Found in src/graph/GanttScale.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\Amenadiel\JpGraph\Util\Helper' in method '__construct'.
Open

            $aCachedName = Util\Helper::GenImgName();
Severity: Minor
Found in src/graph/Graph.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

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

        } else {
            if (is_array($aTxt)) {
                for ($i = 0; $i < safe_count($aTxt); ++$i) {
                    $this->texts[] = $aTxt[$i];
                }
Severity: Minor
Found in src/graph/Graph.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 using static access to class '\Amenadiel\JpGraph\Util\JpGraphError' in method 'CreateSimple'.
Open

                            Util\JpGraphError::RaiseL(6003, $j);
Severity: Minor
Found in src/graph/GanttGraph.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

The method StrokeDays() has 147 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public function StrokeDays($aYCoord, $getHeight = false)
    {
        $img      = $this->iImg;
        $daywidth = $this->GetDayWidth();
        $xt       = $img->left_margin + $this->iLabelWidth;
Severity: Minor
Found in src/graph/GanttScale.php by phpmd

Avoid using static access to class '\Amenadiel\JpGraph\Util\JpGraphError' in method 'Set90AndMargin'.
Open

            Util\JpGraphError::RaiseL(25009); //('You must specify what scale to use with a call to Graph::SetScale()');
Severity: Minor
Found in src/graph/Graph.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

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

        } else {
            $this->y2plots[] = $aPlot;
        }
Severity: Minor
Found in src/graph/Graph.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 AddLine uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                //$this->y2lines[] = $aLine;
                $this->y2plots[] = $aLine;
            }
Severity: Minor
Found in src/graph/Graph.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 using static access to class '\Amenadiel\JpGraph\Util\JpGraphError' in method 'AddBand'.
Open

            Util\JpGraphError::RaiseL(25016); //(" Graph::AddBand() You tried to add a null band to the graph.");
Severity: Minor
Found in src/graph/Graph.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

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

            } else {
                $this->y2bands[] = $aBand;
            }
Severity: Minor
Found in src/graph/Graph.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 CreateSimple() has an NPath complexity of 209. The configured NPath complexity threshold is 200.
Open

    public function CreateSimple($data, $constrains = [], $progress = [])
    {
        $num = safe_count($data);
        for ($i = 0; $i < $num; ++$i) {
            switch ($data[$i][1]) {
Severity: Minor
Found in src/graph/GanttGraph.php by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

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

        } else {
            // position the top bar at 1/2 a vert spacing from the scale
            $pos = round($img->top_margin + $this->iVertHeaderSize + $this->iTopPlotMargin + ($aPos + 1) * $this->iVertSpacing);
        }
Severity: Minor
Found in src/graph/GanttScale.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 StrokeMonths uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $monthwidth = $this->GetDayWidth() * ($this->GetNumDaysInMonth($monthnbr, $year) - $this->GetMonthDayNbr($this->iStartDate) + 1);
            }
Severity: Minor
Found in src/graph/GanttScale.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 StrokeYears uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $yearwidth = $this->GetDayWidth() * ($this->GetNumDaysInYear($year) - $this->GetYearDayNbr($this->iStartDate) + 1);
            }
Severity: Minor
Found in src/graph/GanttScale.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 '$aAxisType'.
Open

    public function SetScale($aAxisType, $aYMin = 1, $aYMax = 1, $aXMin = 1, $aXMax = 1)
Severity: Minor
Found in src/graph/GanttGraph.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

The class GanttScale has 1224 lines of code. Current threshold is 1000. Avoid really long classes.
Open

class GanttScale
{
    public $minute;
    public $hour;
    public $day;
Severity: Minor
Found in src/graph/GanttScale.php by phpmd

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

            } else {
                Util\JpGraphError::RaiseL(6021);
                //("Unknown formatting style for week.");
            }
Severity: Minor
Found in src/graph/GanttScale.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

Severity
Category
Status
Source
Language