shrink0r/suffix-tree

View on GitHub

Showing 7 of 31 total issues

Function appendSuffix has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    private function appendSuffix(int $i)
    {
        // initialize phase state
        $this->prev_int_node = null;
        $this->suffixes_to_add++;
Severity: Minor
Found in src/Builder/SuffixTreeBuilder.php - About 4 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function transferChildren has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    private function transferChildren(
        NodeInterface $node,
        array &$node_map = [],
        array &$lazy_links = [],
        int $path_size = 0
Severity: Minor
Found in src/Builder/SuffixTreeBuilder.php - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method transferChildren has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function transferChildren(
        NodeInterface $node,
        array &$node_map = [],
        array &$lazy_links = [],
        int $path_size = 0
Severity: Major
Found in src/Builder/SuffixTreeBuilder.php - About 2 hrs to fix

    Method appendSuffix has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function appendSuffix(int $i)
        {
            // initialize phase state
            $this->prev_int_node = null;
            $this->suffixes_to_add++;
    Severity: Minor
    Found in src/Builder/SuffixTreeBuilder.php - About 1 hr to fix

      Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function __construct(int $start, int $end, int $smin, int $smax, array $children = [], $suffix_link = null)
      Severity: Minor
      Found in src/InternalNode.php - About 45 mins to fix

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

            public function render(SuffixTree $tree): string
            {
                $node_map = [];
        
                $nodes = [];
        Severity: Minor
        Found in src/Renderer/GraphvizRenderer.php - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

            private function dfsLongestRepetition(NodeInterface $node, int $path_size, array $slice, $overlap = false): array
            {
                if ($node instanceof LeafNode && $slice[1] < $path_size - $node->getEdgeSize()) {
                    $slice = [ $node->getSuffixIdx(), $path_size - $node->getEdgeSize() ];
                } else {
        Severity: Minor
        Found in src/SuffixTree.php - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Severity
        Category
        Status
        Source
        Language