HuasoFoundries/jpgraph

View on GitHub

Showing 6,805 of 6,805 total issues

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 {
                // TTF fonts
                $sff = $this->font_family;
                $sfs = $this->font_style;
                $sfz = floor($this->font_size * $this->iSuperScale);
Severity: Minor
Found in src/text/SuperScriptText.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 File() has an NPath complexity of 1160. The configured NPath complexity threshold is 200.
Open

    public function File($family, $style = FS_NORMAL, $font_path = null)
    {
        $fam = @$this->font_files[$family];
        if (!$fam) {
            Util\JpGraphError::RaiseL(25046, $family); //("Specified TTF font family (id=$family) is unknown or does not exist. Please note that TTF fonts are not distributed with JpGraph for copyright reasons. You can find the MS TTF WEB-fonts (arial, courier etc) for download at http://corefonts.sourceforge.net/");
Severity: Minor
Found in src/text/TTF.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

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

        $jpgraph_font_dir = dirname(dirname(__FILE__)) . '/fonts/';
Severity: Minor
Found in src/text/TTF.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 assigning values to variables in if clauses and the like (line '281', column '54').
Open

    public function Stroke($aImg, $aX, $aY)
    {
        if ($this->iShow) {
            $aImg->SetColor($this->iColor);
            $aImg->SetFont($this->iFFamily, $this->iFStyle, $this->iFSize);
Severity: Minor
Found in src/text/TextProperty.php by phpmd

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

Avoid unused parameters such as '$aMargin'.
Open

    public function GetColWidth($aImg, $aMargin = 0)
Severity: Minor
Found in src/text/TextPropertyBelow.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 method SetupPlot uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $this->ApplyPlot($plot);
        }
Severity: Minor
Found in src/themes/Theme.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 Set uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $res = @setlocale(LC_TIME, $aLocale);
        }
Severity: Minor
Found in src/util/DateLocale.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 '$maxh'.
Open

            $maxh = 0;
Severity: Minor
Found in src/plot/WindrosePlot.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 _StrokeFreeRose uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $dblImg->SetColor($this->iRadialColorArray[$dir]);
            }
Severity: Minor
Found in src/plot/WindrosePlot.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 StrokeWithScale uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $this->Stroke($aImg);
        }
Severity: Minor
Found in src/text/GTextTable.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 Stroke() has 118 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public function Stroke($aImg, $aX = null, $aY = null)
    {
        if ($aX !== null && $aY !== null) {
            $this->iXPos = $aX;
            $this->iYPos = $aY;
Severity: Minor
Found in src/text/GTextTable.php by phpmd

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

                Util\JpGraphError::RaiseL(22014); //('Index for copmass direction must be between 0 and 15.');
Severity: Minor
Found in src/plot/WindrosePlot.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 AdjustMarginsForGrid() has an NPath complexity of 256. The configured NPath complexity threshold is 200.
Open

    public function AdjustMarginsForGrid()
    {
        if ($this->iCol > 0) {
            switch ($this->iGridStyle[0]) {
                case TGRID_SINGLE:
Severity: Minor
Found in src/text/GTextTableCell.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

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

    private $iImg;
Severity: Minor
Found in src/text/GTextTable.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

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

                Util\JpGraphError::RaiseL(27012, $this->iHorAlign);
Severity: Minor
Found in src/text/GTextTableCell.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 'SetRowNumberFormat'.
Open

            Util\JpGraphError::RaiseL(27013); // argument must be a string
Severity: Minor
Found in src/text/GTextTable.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 unused local variables such as '$csim'.
Open

        $csim = '';
Severity: Minor
Found in src/text/GTextTable.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 SetCSIMTarget uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $t = $aTarget;
                }
Severity: Minor
Found in src/text/GTextTable.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 '_chkR'.
Open

            Util\JpGraphError::Raise(27014); // Table not initialized
Severity: Minor
Found in src/text/GTextTable.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 GetHeight uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $iheight = 0;
        }
Severity: Minor
Found in src/text/GTextTableCell.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