brokencube/automatorm

View on GitHub
src/Orm/Traits/ClosureTree.php

Summary

Maintainability
B
5 hrs
Test Coverage

Method getFullTree has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getFullTree()
    {
        $table = $this->closureTable;

        // Find the root node from the supplied node_id
Severity: Minor
Found in src/Orm/Traits/ClosureTree.php - About 1 hr to fix

    Static call to undeclared method \Automatorm\Orm\Traits\ClosureTree::findAll
    Open

            foreach (static::findAll(['id' => $ids]) as $node) {
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Call to undeclared method \Automatorm\Orm\Traits\ClosureTree::getConnection
    Open

            $query = new Query($this->getConnection());
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Reference to undeclared property \Automatorm\Orm\Traits\ClosureTree->id
    Open

                ->where(['child_id' => $this->id])
    Severity: Minor
    Found in src/Orm/Traits/ClosureTree.php by phan

    Reference to undeclared property \Automatorm\Orm\Traits\ClosureTree->id
    Open

                WHERE p.child_id = {$parent->id} AND c.parent_id = {$this->id}
    Severity: Minor
    Found in src/Orm/Traits/ClosureTree.php by phan

    Reference to undeclared property \Automatorm\Orm\Traits\ClosureTree->id
    Open

                ->where(['p.child_id' => $parent->id, 'c.parent_id' => $this->id])
    Severity: Minor
    Found in src/Orm/Traits/ClosureTree.php by phan

    Reference to undeclared property \Automatorm\Orm\Traits\ClosureTree->id
    Open

            $query->sql(QueryBuilder::insert($this->closureTable, ['parent_id' => $this->id, 'child_id' => $this->id, 'depth' => 0]));
    Severity: Minor
    Found in src/Orm/Traits/ClosureTree.php by phan

    Call to undeclared method \Automatorm\Orm\Traits\ClosureTree::getConnection
    Open

            $query = new Query($this->getConnection());
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Invalid offset 0 of array type array{}
    Open

            return static::find(['id' => $results[0]['parent_id']]);
    Severity: Minor
    Found in src/Orm/Traits/ClosureTree.php by phan

    Call to undeclared method \Automatorm\Orm\Traits\ClosureTree::getConnection
    Open

            $query = new Query($this->getConnection());
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Static call to undeclared method \Automatorm\Orm\Traits\ClosureTree::get
    Open

            return static::get($rootid);
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Call to undeclared method \Automatorm\Orm\Traits\ClosureTree::getConnection
    Open

            $query = new Query($this->getConnection());
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Invalid offset 1 of array type array{0:array{}}|array{0:} in an array destructuring assignment
    Open

            list($root, $results) = $query->execute();
    Severity: Minor
    Found in src/Orm/Traits/ClosureTree.php by phan

    Call to undeclared method \Automatorm\Orm\Traits\ClosureTree::getConnection
    Open

            $query = new Query($this->getConnection());
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Call to undeclared method \Automatorm\Orm\Traits\ClosureTree::getConnection
    Open

            $query = new Query($this->getConnection());
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Static call to undeclared method \Automatorm\Orm\Traits\ClosureTree::get
    Open

                $parent = static::get($row['parent_id']);
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Reference to undeclared property \Automatorm\Orm\Traits\ClosureTree->id
    Open

                QueryBuilder::select($this->closureTable, ['child_id'])->where(['parent_id' => $this->id, 'depth' => 1])
    Severity: Minor
    Found in src/Orm/Traits/ClosureTree.php by phan

    Invalid offset 0 of array type array{}
    Open

            $rootid = $root[0]['id'];
    Severity: Minor
    Found in src/Orm/Traits/ClosureTree.php by phan

    Call to undeclared method \Automatorm\Orm\Traits\ClosureTree::getConnection
    Open

            $query = new Query($this->getConnection());
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Call to undeclared method \Automatorm\Orm\Traits\ClosureTree::getConnection
    Open

            $query = new Query($this->getConnection());
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Static call to undeclared method \Automatorm\Orm\Traits\ClosureTree::get
    Open

                $child = static::get($row['child_id']);
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Static call to undeclared method \Automatorm\Orm\Traits\ClosureTree::findAll
    Open

            return static::findAll(['id' => $parents])->sortById($parents);
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Static call to undeclared method \Automatorm\Orm\Traits\ClosureTree::findAll
    Open

            return static::findAll(['id' => $children]);
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Reference to undeclared property \Automatorm\Orm\Traits\ClosureTree->id
    Open

                QueryBuilder::select($this->closureTable, ['parent_id'])->where(['child_id' => $this->id, 'depth' => 1])->limit(1)
    Severity: Minor
    Found in src/Orm/Traits/ClosureTree.php by phan

    Static call to undeclared method \Automatorm\Orm\Traits\ClosureTree::find
    Open

            return static::find(['id' => $results[0]['parent_id']]);
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Reference to undeclared property \Automatorm\Orm\Traits\ClosureTree->id
    Open

                QueryBuilder::select($this->closureTable, ['parent_id'])->where(['child_id' => $this->id, 'depth>=' => 1])->orderBy('depth')
    Severity: Minor
    Found in src/Orm/Traits/ClosureTree.php by phan

    Reference to undeclared property \Automatorm\Orm\Traits\ClosureTree->id
    Open

                QueryBuilder::select($this->closureTable, ['child_id'])->where(['parent_id' => $this->id, 'depth>=' => 1])
    Severity: Minor
    Found in src/Orm/Traits/ClosureTree.php by phan

    Static call to undeclared method \Automatorm\Orm\Traits\ClosureTree::findAll
    Open

            return static::findAll(['id' => $children]);
    Severity: Critical
    Found in src/Orm/Traits/ClosureTree.php by phan

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function getChildren()
        {
            // Find all direct child/parent relationships
            $query = new Query($this->getConnection());
            $query->sql(
    Severity: Major
    Found in src/Orm/Traits/ClosureTree.php and 1 other location - About 2 hrs to fix
    src/Orm/Traits/ClosureTree.php on lines 174..189

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 122.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function getDescendants()
        {
            // Find all direct child/parent relationships
            $query = new Query($this->getConnection());
            $query->sql(
    Severity: Major
    Found in src/Orm/Traits/ClosureTree.php and 1 other location - About 2 hrs to fix
    src/Orm/Traits/ClosureTree.php on lines 157..172

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 122.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Line exceeds 120 characters; contains 130 characters
    Open

            $query->sql(QueryBuilder::insert($this->closureTable, ['parent_id' => $this->id, 'child_id' => $this->id, 'depth' => 0]));

    Line exceeds 120 characters; contains 126 characters
    Open

                QueryBuilder::select($this->closureTable, ['parent_id'])->where(['child_id' => $this->id, 'depth' => 1])->limit(1)

    Line exceeds 120 characters; contains 136 characters
    Open

                QueryBuilder::select($this->closureTable, ['parent_id'])->where(['child_id' => $this->id, 'depth>=' => 1])->orderBy('depth')

    Whitespace found at end of line
    Open

            // Find all the ancestors of the root node above - i.e. find all nodes in this graph 

    There are no issues that match your filters.

    Category
    Status