chamilo/chamilo-lms

View on GitHub
src/CoreBundle/Traits/Repository/ORM/NestedTreeRepositoryTrait.php

Summary

Maintainability
A
0 mins
Test Coverage

The method verifyTree() has an NPath complexity of 143616. The configured NPath complexity threshold is 200.
Open

    private function verifyTree(&$errors, $root = null)
    {
        $meta = $this->getClassMetadata();
        $em = $this->getEntityManager();
        $config = $this->listener->getConfiguration($em, $meta->name);

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 childrenQueryBuilder() has an NPath complexity of 210. The configured NPath complexity threshold is 200.
Open

    public function childrenQueryBuilder($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false)
    {
        $meta = $this->getClassMetadata();
        $config = $this->listener->getConfiguration($this->getEntityManager(), $meta->name);

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

Missing class import via use statement (line '292', column '27').
Open

                throw new \InvalidArgumentException("Node is not related to this repository");

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

Missing class import via use statement (line '778', column '27').
Open

                throw new \Gedmo\Exception\RuntimeException('Transaction failed', null, $e);

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

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

        } else {
            $count = 1;
            foreach ($this->getChildren(null, true) as $root) {
                $doRecover($root, $count);
            }

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 getLeafsQueryBuilder uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            if ($meta->hasField($sortByField) && in_array(strtolower($direction), array('asc', 'desc'))) {
                $qb->orderBy('node.'.$sortByField, $direction);
            } else {
                throw new InvalidArgumentException("Invalid sort options specified: field - {$sortByField}, direction - {$direction}");

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 getNextSiblingsQueryBuilder uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $qb->andWhere($qb->expr()->isNull('node.'.$config['parent']));
        }

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 assigning values to variables in if clauses and the like (line '614', column '17').
Open

    public function moveDown($node, $number = 1)
    {
        $result = false;
        $meta = $this->getClassMetadata();
        if ($node instanceof $meta->name) {

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

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

        } else {
            throw new InvalidArgumentException("Node is not related to this repository");
        }

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 moveDown uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            throw new InvalidArgumentException("Node is not related to this repository");
        }

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 assigning values to variables in if clauses and the like (line '1114', column '21').
Open

    private function verifyTree(&$errors, $root = null)
    {
        $meta = $this->getClassMetadata();
        $em = $this->getEntityManager();
        $config = $this->listener->getConfiguration($em, $meta->name);

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

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

                } else {
                    $left = $wrapped->getPropertyValue($config['left']);
                    $right = $wrapped->getPropertyValue($config['right']);
                    if ($left && $right) {
                        $qb->where($qb->expr()->lt('node.'.$config['right'], $right));

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 getLeafsQueryBuilder uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                throw new InvalidArgumentException("Invalid sort options specified: field - {$sortByField}, direction - {$direction}");
            }

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 getPrevSiblingsQueryBuilder uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $qb->andWhere($qb->expr()->isNull('node.'.$config['parent']));
        }

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 verify uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $this->verifyTree($errors);
        }

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 childrenQueryBuilder uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            if ($meta->hasField($sortByField) && in_array(strtolower($direction), array('asc', 'desc'))) {
                $qb->orderBy('node.'.$sortByField, $direction);
            } else {
                throw new InvalidArgumentException("Invalid sort options specified: field - {$sortByField}, direction - {$direction}");

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 removeFromTree uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            throw new InvalidArgumentException("Node is not related to this repository");
        }

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 removeFromTree uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $qb = $this->getQueryBuilder();
                    $qb->update($config['useObjectClass'], 'node');
                    $qb->set('node.'.$config['parent'], ':pid');
                    $qb->setParameter('pid', $parentId);

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 verifyTree uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $errors[] = "index [{$i}], duplicate".($root ? ' on tree root: '.$rootId : '');
                }

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 getLeafsQueryBuilder uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                throw new InvalidArgumentException("Node is not related to this repository");
            }

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 childrenQueryBuilder uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            if ($direct) {
                $qb->where($qb->expr()->isNull('node.'.$config['parent']));
            }
        }

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 verifyTree uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $qb = $this->getQueryBuilder();
                $qb->select($qb->expr()->count('node.'.$identifier))
                    ->from($config['useObjectClass'], 'node')
                    ->where($qb->expr()->lt('node.'.$config['left'], $left))

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 assigning values to variables in if clauses and the like (line '649', column '17').
Open

    public function moveUp($node, $number = 1)
    {
        $result = false;
        $meta = $this->getClassMetadata();
        if ($node instanceof $meta->name) {

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

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

        } else {
            $qb->orderBy('node.'.$config['left'], 'ASC');
        }

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 childrenQueryBuilder uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                throw new \InvalidArgumentException("Node is not related to this repository");
            }

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 moveUp uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            throw new InvalidArgumentException("Node is not related to this repository");
        }

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 childrenQueryBuilder uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                throw new InvalidArgumentException("Invalid sort options specified: field - {$sortByField}, direction - {$direction}");
            }

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

Missing parameter name
Open

     * @param $node

Missing parameter name
Open

     * @param $node

Missing parameter name
Open

     * @param $node

Missing parameter name
Open

     * @param $node

Missing parameter name
Open

     * @param $parent

Missing parameter name
Open

     * @param $node

Missing parameter name
Open

     * @param $node

Missing parameter name
Open

     * @param $node

Missing parameter name
Open

     * @param $parent

Missing parameter name
Open

     * @param $sibling

Missing parameter name
Open

     * @param $node

Missing parameter name
Open

     * @param $sibling

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

                if ($parent instanceof Proxy && !$parent->__isInitialized__) {

Missing function doc comment
Open

    public function verifyNode($node)

There are no issues that match your filters.

Category
Status