MartanLV/koki

View on GitHub
src/Node.php

Summary

Maintainability
A
3 hrs
Test Coverage

Showing 17 of 17 total issues

The class Node has an overall complexity of 56 which is very high. The configured complexity threshold is 50.
Open

class Node
{
public $root;
/**
* @var Interval
Severity: Minor
Found in src/Node.php by phpmd

The class Node has 13 public methods. Consider refactoring Node to keep number of public methods under 10.
Open

class Node
{
public $root;
/**
* @var Interval
Severity: Minor
Found in src/Node.php by phpmd

Function remove has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

public function remove(IntervalInterface $i)
{
if ($this->max > $i->getEnd()) {
if ($this->left) {
$this->left->add($i);
Severity: Minor
Found in src/Node.php - About 45 mins to fix

Function add has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

public function add(IntervalInterface $i)
{
if ($this->max > $i->getEnd()) {
if ($this->left) {
$this->left->add($i);
Severity: Minor
Found in src/Node.php - About 45 mins to fix

Function yieldInterSelectNode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

public function yieldInterSelectNode(int $low, int $high)
{
$edgeR = $high >= $this->interval->getStart() && $high <= $this->interval->getEnd();
$edgeL = $low >= $this->interval->getStart() && $low <= $this->interval->getEnd();
$part = $this->interval->getStart() >= $low && $this->interval->getEnd() <= $high;
Severity: Minor
Found in src/Node.php - About 35 mins to fix

Function yieldInterSelect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

public function yieldInterSelect(int $low, int $high)
{
$edgeR = $high >= $this->interval->getStart() && $high <= $this->interval->getEnd();
$edgeL = $low >= $this->interval->getStart() && $low <= $this->interval->getEnd();
$part = $this->interval->getStart() >= $low && $this->interval->getEnd() <= $high;
Severity: Minor
Found in src/Node.php - About 25 mins to fix

The method yieldInterSelectNode() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
Open

public function yieldInterSelectNode(int $low, int $high)
{
$edgeR = $high >= $this->interval->getStart() && $high <= $this->interval->getEnd();
$edgeL = $low >= $this->interval->getStart() && $low <= $this->interval->getEnd();
$part = $this->interval->getStart() >= $low && $this->interval->getEnd() <= $high;
Severity: Minor
Found in src/Node.php by phpmd

The method yieldInterSelect() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
Open

public function yieldInterSelect(int $low, int $high)
{
$edgeR = $high >= $this->interval->getStart() && $high <= $this->interval->getEnd();
$edgeL = $low >= $this->interval->getStart() && $low <= $this->interval->getEnd();
$part = $this->interval->getStart() >= $low && $this->interval->getEnd() <= $high;
Severity: Minor
Found in src/Node.php by phpmd

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

} else {
$this->left = new self($i);
}
Severity: Minor
Found in src/Node.php by phpmd

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

} else {
$this->left = new self($i);
$this->left->root = &$this;
}
Severity: Minor
Found in src/Node.php by phpmd

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

} else {
$this->max = $i->getEnd();
if ($this->right) {
$this->right->add($i);
} else {
Severity: Minor
Found in src/Node.php by phpmd

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

} else {
$this->max = $i->getEnd();
if ($this->right) {
$this->right->add($i);
} else {
Severity: Minor
Found in src/Node.php by phpmd

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

} else {
$this->right = new self($i);
$this->right->root = &$this;
}
Severity: Minor
Found in src/Node.php by phpmd

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

} else {
$this->right = new self($i);
}
Severity: Minor
Found in src/Node.php by phpmd

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

if ($this->max > $i->getEnd()) {
if ($this->left) {
$this->left->add($i);
} else {
$this->left = new self($i);
Severity: Major
Found in src/Node.php and 1 other location - About 1 hr to fix
src/Tree.php on lines 177..190

Avoid variables with short names like $i. Configured minimum length is 3.
Open

public function remove(IntervalInterface $i)
Severity: Minor
Found in src/Node.php by phpmd

Avoid variables with short names like $i. Configured minimum length is 3.
Open

public function add(IntervalInterface $i)
Severity: Minor
Found in src/Node.php by phpmd
Category
Status