HuasoFoundries/jpgraph

View on GitHub

Showing 6,805 of 6,805 total issues

Avoid unused private fields such as '$_bottom_margin'.
Open

    private $_bottom_margin = 30;
Severity: Minor
Found in src/image/Image.php by phpmd

UnusedPrivateField

Since: 0.2

Detects when a private field is declared and/or assigned a value, but not used.

Example

class Something
{
    private static $FOO = 2; // Unused
    private $i = 5; // Unused
    private $j = 6;
    public function addOne()
    {
        return $this->j++;
    }
}

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

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

        } else {
            if (($fromWidth != -1 && ($fromWidth != $toWidth)) || ($fromHeight != -1 && ($fromHeight != $fromHeight))) {
                // Create a new canvas that will hold the re-scaled original from image
                if ($toWidth <= 1 || $toHeight <= 1) {
                    Util\JpGraphError::RaiseL(25083); //('Illegal image size when copying image. Size for copied to image is 1 pixel or less.');
Severity: Minor
Found in src/image/Image.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 StrokeBoxedText() has 113 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public function StrokeBoxedText(
        $x,
        $y,
        $txt,
        $dir = 0,
Severity: Minor
Found in src/image/Image.php by phpmd

The method StrokeBoxedText 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(25090, $dir);
            }
Severity: Minor
Found in src/image/Image.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 StrokeBoxedText uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            if ($fcolor) {
                $oc = $this->current_color;
                $this->SetColor($fcolor);
                $this->FilledRoundedRectangle($x - $xmarg, $y - $ymarg, $x + $width, $y + $height - $ymarg, $cornerradius);
Severity: Minor
Found in src/image/Image.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 StrokeBoxedText2() has 163 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public function StrokeBoxedText2(
        $x,
        $y,
        $txt,
        $dir = 0,
Severity: Minor
Found in src/image/Image.php by phpmd

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

        Util\JpGraphError::RaiseL(5004, $aName);
Severity: Minor
Found in src/image/FlagImages.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\JpGraphError' in method 'Stroke'.
Open

                        Util\JpGraphError::RaiseL(6032, $this->iPathType);
Severity: Minor
Found in src/image/GanttLink.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 Stroke uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                        } else {
                            $c = [$x1, $y1, $x1, $midy, $x2, $midy, $x2, $y2];
                        }
Severity: Minor
Found in src/image/GanttLink.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 'StrokeBoxedText2'.
Open

            Util\JpGraphError::RaiseL(25131); //StrokeBoxedText2() Only support TTF fonts and not built in bitmap fonts
Severity: Minor
Found in src/image/Image.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\Graph\Graph' in method '__construct'.
Open

            $this->iGDImage = Graph\Graph::LoadBkgImage('', $aIcon);
Severity: Minor
Found in src/image/IconImage.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 CopyCanvasH has 10 parameters. Consider reducing the number of parameters to less than 10.
Open

    public function CopyCanvasH($aToHdl, $aFromHdl, $aToX, $aToY, $aFromX, $aFromY, $aWidth, $aHeight, $aw = -1, $ah = -1)
    {
        if ($aw === -1) {
            $aw = $aWidth;
            $ah = $aHeight;
Severity: Minor
Found in src/image/Image.php by phpmd

The method StrokeBoxedText has 12 parameters. Consider reducing the number of parameters to less than 10.
Open

    public function StrokeBoxedText(
        $x,
        $y,
        $txt,
        $dir = 0,
Severity: Minor
Found in src/image/Image.php by phpmd

The method _StrokeBuiltinFont() has an NPath complexity of 1200. The configured NPath complexity threshold is 200.
Open

    public function _StrokeBuiltinFont($x, $y, $txt, $dir, $paragraph_align, &$aBoundingBox, $aDebug = false)
    {
        if (is_numeric($dir) && $dir != 90 && $dir != 0) {
            Util\JpGraphError::RaiseL(25091);
        }
Severity: Minor
Found in src/image/Image.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 _StrokeBuiltinFont uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                //Put the text
                imagestring($this->img, $use_font, $x, $y - $h + 1, $txt, $this->current_color);
            }
Severity: Minor
Found in src/image/Image.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 'StyleLine'.
Open

                    Util\JpGraphError::RaiseL(25104, $this->line_style); //(" Unknown line style: $this->line_style ");
Severity: Minor
Found in src/image/Image.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 _StrokeTTF uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    // Center
                    $xl = $x + $w / 2 - $wl / 2;
                }
Severity: Minor
Found in src/image/Image.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 'SetMargin'.
Open

                Util\JpGraphError::RaiseL(25130, $this->plotwidth, $this->plotheight);
Severity: Minor
Found in src/image/Image.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\JpGraphError' in method 'imagettfbbox_fixed'.
Open

            Util\JpGraphError::RaiseL(25092, $this->font_file);
Severity: Minor
Found in src/image/Image.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\JpGraphError' in method 'SetLineStyle'.
Open

                Util\JpGraphError::RaiseL(25102, $s); //(" Illegal string argument to SetLineStyle(): $s");
Severity: Minor
Found in src/image/Image.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

Severity
Category
Status
Source
Language