chamilo/chamilo-lms

View on GitHub
public/main/inc/lib/geometry.lib.php

Summary

Maintainability
A
0 mins
Test Coverage

The function poly_compile() has an NPath complexity of 41668020. The configured NPath complexity threshold is 200.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.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 poly_compile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $pente1 = 0;
        }
Severity: Minor
Found in public/main/inc/lib/geometry.lib.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 poly_dump uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $s .= "0";
            }
Severity: Minor
Found in public/main/inc/lib/geometry.lib.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 poly_compile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            else {    //  infinite elevation of the edge
                if (is_array($bords[$poly[$i]['y']])) {
                    array_push($bords[$poly[$i]['y']], $poly[$i]['x']);
                }
                $old_pente = 0;
Severity: Minor
Found in public/main/inc/lib/geometry.lib.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 '$idx'.
Open

        foreach ($pairs as $idx => $pcoord) {
Severity: Minor
Found in public/main/inc/lib/geometry.lib.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 count() function in for loops.
Open

        for ($i = 0, $j = count($points) - 1; $i < count($points); $j = $i++) {
            $xi = $points[$i][0];
            $yi = $points[$i][1];
            $xj = $points[$j][0];
            $yj = $points[$j][1];
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CountInLoopExpression

Since: 2.7.0

Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

Example

class Foo {

  public function bar()
  {
    $array = array();

    for ($i = 0; count($array); $i++) {
      // ...
    }
  }
}

Source https://phpmd.org/rules/design.html#countinloopexpression

Variable "bord_lenght" is not in valid camel caps format
Open

    $bord_lenght = $max['x'];

Missing parameter name
Open

 * @param max[x]    X resolution

Consider putting global function "poly_init" in a static class
Open

function poly_init($max)

Missing parameter name
Open

 * @param poly        points from the polygone

Missing parameter name
Open

 * @param max        see poly_init

Missing parameter name
Open

 * @param max[y]    Y resolution

Consider putting global function "poly_compile" in a static class
Open

function poly_compile($poly, $max, $test = false)

Missing parameter name
Open

 * @param bool    print or not a debug

Variable "dy_inc" is not in valid camel caps format
Open

        for ($dy = $poly[$i - 1]['y'] + $dy_inc; $dy != $poly[0]['y']; $dy += $dy_inc) {

Missing parameter name
Open

 * @param poly1        first polygone as returned by poly_compile

Missing parameter name
Open

 * @param   string  List of points in x1;y1|... format (or /)

Variable "old_pente" is not in valid camel caps format
Open

                || ($old_pente > 0 && $pente < 0)) {

Variable "old_pente" is not in valid camel caps format
Open

        if (($old_pente < 0 && $pente > 0) || ($old_pente > 0 && $pente < 0)) {

Missing parameter name
Open

 * @param array       see above (poly_init)

Consider putting global function "poly_result" in a static class
Open

function poly_result(&$poly1, &$poly2, $max)

Variable "bord_lenght" is not in valid camel caps format
Open

    $bords = array_fill(0, $bord_lenght, []); // building this array

Variable "old_pente" is not in valid camel caps format
Open

        $old_pente = $pente;

Missing parameter name
Open

 * @param array       the polygone as output by poly_compile()

Variable "old_pente" is not in valid camel caps format
Open

    $old_pente = 0;

Missing parameter name
Open

 * @param max        resolution as specified for poly_init

Variable "dy_inc" is not in valid camel caps format
Open

        $dy_inc = ($poly[$i]['y'] - $poly[$i - 1]['y']) > 0 ? 1 : -1;

Consider putting global function "poly_touch" in a static class
Open

function poly_touch(&$poly1, &$poly2, $max)

Consider putting global function "convert_coordinates" in a static class
Open

function convert_coordinates($coords, $sep = '|')

Consider putting global function "poly_get_max" in a static class
Open

function poly_get_max(&$coords1, &$coords2)

Variable "dy_inc" is not in valid camel caps format
Open

            $x += $pente * $dy_inc;

Missing parameter name
Open

 * @param string      Format ('raw' text or 'html')

Variable "dy_inc" is not in valid camel caps format
Open

            $dy += $dy_inc) {

Missing parameter name
Open

 * @param poly2        second ....

Missing parameter name
Open

 * @param max        resolution as specified for poly_init

Missing parameter name
Open

 * @param poly1        first polygone as returned by poly_compile

Missing parameter name
Open

 * @param   string  The points separator for the list (| or /)

Consider putting global function "poly_dump" in a static class
Open

function poly_dump(&$poly, $max, $format = 'raw')

Variable "bord_lenght" is not in valid camel caps format
Open

    if ($max['y'] > $bord_lenght) {

Variable "dy_inc" is not in valid camel caps format
Open

            $x += $pente * $dy_inc;

Variable "old_pente" is not in valid camel caps format
Open

        if (($old_pente < 0 && $pente > 0) || ($old_pente > 0 && $pente < 0)) {

Missing parameter name
Open

 * @param poly2        second ....

Variable "dy_inc" is not in valid camel caps format
Open

        $dy_inc = ($poly[0]['y'] - $poly[$i - 1]['y']) > 0 ? 1 : -1;

Variable "old_pente" is not in valid camel caps format
Open

                $old_pente = 0;

Variable "bord_lenght" is not in valid camel caps format
Open

        $bord_lenght = $max['y'];

Variable "dy_inc" is not in valid camel caps format
Open

        for ($dy = $poly[$i - 1]['y'] + $dy_inc;

Missing parameter name
Open

 * @param   array   Coordinates of one polygon

Variable "old_pente" is not in valid camel caps format
Open

            if (($old_pente < 0 && $pente > 0)

Variable "dy_inc" is not in valid camel caps format
Open

        for ($dy = $poly[$i - 1]['y'] + $dy_inc; $dy != $poly[0]['y']; $dy += $dy_inc) {

The variable $old_pente is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $dy_inc is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $dy_inc is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $old_pente is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $dy_inc is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $old_pente is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $old_pente is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $dy_inc is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $bord_lenght is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $bord_lenght is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $dy_inc is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $bord_lenght is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $dy_inc is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $dy_inc is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $old_pente is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $old_pente is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $bord_lenght is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $old_pente is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $dy_inc is not named in camelCase.
Open

function poly_compile($poly, $max, $test = false)
{
    $res = poly_init($max);

    // looking for EDGES
Severity: Minor
Found in public/main/inc/lib/geometry.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

There are no issues that match your filters.

Category
Status