shrink0r/suffix-tree

View on GitHub

Showing 31 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

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

          public function build(string $S);
      Severity: Minor
      Found in src/Builder/BuilderInterface.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

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

          public function build(string $S): SuffixTree
      Severity: Minor
      Found in src/Builder/SuffixTreeBuilder.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

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

          private function appendSuffix(int $i)
      Severity: Minor
      Found in src/Builder/SuffixTreeBuilder.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

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

          public function __construct(RootNode $root, string $S)
      Severity: Minor
      Found in src/SuffixTree.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

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

          private $S;
      Severity: Minor
      Found in src/Builder/SuffixTreeBuilder.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

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

          private function walkEdge(string $s, int $i, int $start, int $end): int
      Severity: Minor
      Found in src/SuffixTree.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

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

          private function matchSuffixPath(NodeInterface $node, string $path, int $i): int
      Severity: Minor
      Found in src/SuffixTree.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

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

          private function walkEdge(string $s, int $i, int $start, int $end): int
      Severity: Minor
      Found in src/SuffixTree.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

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

          private function renderEdge(NodeInterface $node, NodeInterface $child, array $node_map, string $S): string
      Severity: Minor
      Found in src/Renderer/GraphvizRenderer.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

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

          private $S;
      Severity: Minor
      Found in src/SuffixTree.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      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

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

            private function dfsLongestRepetition(NodeInterface $node, int $path_size, array $slice, $overlap = false): array
        Severity: Minor
        Found in src/SuffixTree.php by phpmd

        BooleanArgumentFlag

        Since: 1.4.0

        A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

        Example

        class Foo {
            public function bar($flag = true) {
            }
        }

        Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

        Missing class import via use statement (line '47', column '23').
        Open

                    throw new \Exception("Trying to link node more than once.");
        Severity: Minor
        Found in src/InternalNode.php by phpmd

        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 '24', column '23').
        Open

                    throw new \Exception("Trying to link non-internal/root node.");
        Severity: Minor
        Found in src/InternalNode.php by phpmd

        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

        Severity
        Category
        Status
        Source
        Language