MartanLV/koki

View on GitHub
src/Tree.php

Summary

Maintainability
B
4 hrs
Test Coverage

Showing 23 of 23 total issues

The class Tree has 15 public methods. Consider refactoring Tree to keep number of public methods under 10.
Open

class Tree extends Node
{
public $root;
 
/**
Severity: Minor
Found in src/Tree.php by phpmd

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

public function remove(IntervalInterface $i)
{
if (!$i->left && !$i->right) {
if ($i->root) {
$i->root = null;
Severity: Minor
Found in src/Tree.php - About 2 hrs to fix

Method remove has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public function remove(IntervalInterface $i)
{
if (!$i->left && !$i->right) {
if ($i->root) {
$i->root = null;
Severity: Minor
Found in src/Tree.php - About 1 hr to fix

    The method remove() has an NPath complexity of 384. The configured NPath complexity threshold is 200.
    Open

    public function remove(IntervalInterface $i)
    {
    if (!$i->left && !$i->right) {
    if ($i->root) {
    $i->root = null;
    Severity: Minor
    Found in src/Tree.php by phpmd

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

    public function remove(IntervalInterface $i)
    {
    if (!$i->left && !$i->right) {
    if ($i->root) {
    $i->root = null;
    Severity: Minor
    Found in src/Tree.php by phpmd

    The method __construct has a boolean flag argument $preSorted, which is a certain sign of a Single Responsibility Principle violation.
    Open

    public function __construct(array $intervals = [], bool $preSorted = false)
    Severity: Minor
    Found in src/Tree.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 Node($i);
    }
    Severity: Minor
    Found in src/Tree.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 Node($i);
    }
    Severity: Minor
    Found in src/Tree.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/Tree.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 Node($i);
    Severity: Major
    Found in src/Tree.php and 1 other location - About 1 hr to fix
    src/Node.php on lines 214..227

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

    usort($arr, function (IntervalInterface $i0, IntervalInterface $i) {
    Severity: Minor
    Found in src/Tree.php by phpmd

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

    !$preSorted && usort($intervals, function (IntervalInterface $i0, IntervalInterface $i) {
    Severity: Minor
    Found in src/Tree.php by phpmd

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

    !$preSorted && usort($intervals, function (IntervalInterface $i0, IntervalInterface $i) {
    Severity: Minor
    Found in src/Tree.php by phpmd

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

    public function remove(IntervalInterface $i)
    Severity: Minor
    Found in src/Tree.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/Tree.php by phpmd

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

    usort($arr, function (IntervalInterface $i0, IntervalInterface $i) {
    Severity: Minor
    Found in src/Tree.php by phpmd

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

    array_walk($intervals, function (IntervalInterface $el) use (&$max) {
    Severity: Minor
    Found in src/Tree.php by phpmd

    The variable $l_intervals is not named in camelCase.
    Open

    public function toTree(array $intervals)
    {
    $max = 0;
    $len = count($intervals);
    $mid = (int) floor($len / 2);
    Severity: Minor
    Found in src/Tree.php by phpmd

    The variable $r_intervals is not named in camelCase.
    Open

    public function toTree(array $intervals)
    {
    $max = 0;
    $len = count($intervals);
    $mid = (int) floor($len / 2);
    Severity: Minor
    Found in src/Tree.php by phpmd

    The variable $l_intervals is not named in camelCase.
    Open

    public function toTree(array $intervals)
    {
    $max = 0;
    $len = count($intervals);
    $mid = (int) floor($len / 2);
    Severity: Minor
    Found in src/Tree.php by phpmd

    The variable $r_intervals is not named in camelCase.
    Open

    public function toTree(array $intervals)
    {
    $max = 0;
    $len = count($intervals);
    $mid = (int) floor($len / 2);
    Severity: Minor
    Found in src/Tree.php by phpmd

    The variable $l_intervals is not named in camelCase.
    Open

    public function toTree(array $intervals)
    {
    $max = 0;
    $len = count($intervals);
    $mid = (int) floor($len / 2);
    Severity: Minor
    Found in src/Tree.php by phpmd

    The variable $r_intervals is not named in camelCase.
    Open

    public function toTree(array $intervals)
    {
    $max = 0;
    $len = count($intervals);
    $mid = (int) floor($len / 2);
    Severity: Minor
    Found in src/Tree.php by phpmd
    Category
    Status