algb12/GraphDS

View on GitHub

Showing 47 of 47 total issues

Function run has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    public function run($start, $dest, $k = 3)
    {
        if (empty($this->graph->vertices[$start])) {
            throw new InvalidArgumentException("Vertex $start does not exist.");
        }
Severity: Minor
Found in src/Algo/Yen.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 run has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function run()
    {
        foreach (array_keys($this->graph->vertices) as $vertex1) {
            foreach (array_keys($this->graph->vertices) as $vertex2) {
                $this->dist[$vertex1][$vertex2] = INF;
Severity: Minor
Found in src/Algo/FloydWarshall.php - About 2 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 run has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function run($start, $dest, $k = 3)
    {
        if (empty($this->graph->vertices[$start])) {
            throw new InvalidArgumentException("Vertex $start does not exist.");
        }
Severity: Major
Found in src/Algo/Yen.php - About 2 hrs to fix

    Method getGraphML has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getGraphML()
        {
            $directionality = $this->graph->directed ? 'directed' : 'undirected';
            $export = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?>'
                                          .'<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">'
    Severity: Minor
    Found in src/Persistence/ExportGraph.php - About 1 hr to fix

      Function run has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function run($root)
          {
              foreach (array_keys($this->graph->vertices) as $vertex) {
                  $this->dist[$vertex] = INF;
                  $this->parent[$vertex] = null;
      Severity: Minor
      Found in src/Algo/DFS.php - About 1 hr 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 fromGraphML has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function fromGraphML($file)
          {
              if (!file_exists($file)) {
                  throw new InvalidArgumentException('File '.$file.' does not exist.');
              }
      Severity: Minor
      Found in src/Persistence/ImportGraph.php - About 1 hr 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

      Avoid excessively long variable names like $originalDestinationVertex. Keep variable name length under 20.
      Open

              $originalDestinationVertex = $destinationVertex;
      Severity: Minor
      Found in src/Algo/Dijkstra.php by phpmd

      LongVariable

      Since: 0.2

      Detects when a field, formal or local variable is declared with a long name.

      Example

      class Something {
          protected $reallyLongIntName = -3; // VIOLATION - Field
          public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
              $otherReallyLongName = -5; // VIOLATION - Local
              for ($interestingIntIndex = 0; // VIOLATION - For
                   $interestingIntIndex < 10;
                   $interestingIntIndex++ ) {
              }
          }
      }

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

      Method fromGraphML has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function fromGraphML($file)
          {
              if (!file_exists($file)) {
                  throw new InvalidArgumentException('File '.$file.' does not exist.');
              }
      Severity: Minor
      Found in src/Persistence/ImportGraph.php - About 1 hr to fix

        Function run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public function run($start)
            {
                $this->start = $start;
                if (empty($this->graph->vertices[$start])) {
                    throw new InvalidArgumentException("Vertex $start does not exist.");
        Severity: Minor
        Found in src/Algo/DijkstraMulti.php - About 1 hr 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 run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public function run($start)
            {
                $this->start = $start;
                if (empty($this->graph->vertices[$start])) {
                    throw new InvalidArgumentException("Vertex $start does not exist.");
        Severity: Minor
        Found in src/Algo/Dijkstra.php - About 1 hr 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 run has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function run($start)
            {
                $this->start = $start;
                if (empty($this->graph->vertices[$start])) {
                    throw new InvalidArgumentException("Vertex $start does not exist.");
        Severity: Minor
        Found in src/Algo/DijkstraMulti.php - About 1 hr to fix

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

              public function run($start)
              {
                  $this->start = $start;
                  if (empty($this->graph->vertices[$start])) {
                      throw new InvalidArgumentException("Vertex $start does not exist.");
          Severity: Minor
          Found in src/Algo/Dijkstra.php - About 1 hr to fix

            Avoid using undefined variables such as '$discovered' which will lead to PHP notices.
            Open

                        unset($discovered[$key]);
            Severity: Minor
            Found in src/Algo/DijkstraMulti.php by phpmd

            UndefinedVariable

            Since: 2.8.0

            Detects when a variable is used that has not been defined before.

            Example

            class Foo
            {
                private function bar()
                {
                    // $message is undefined
                    echo $message;
                }
            }

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

            Avoid using undefined variables such as '$discovered' which will lead to PHP notices.
            Open

                            if (!in_array($child, $discovered)) {
            Severity: Minor
            Found in src/Algo/DijkstraMulti.php by phpmd

            UndefinedVariable

            Since: 2.8.0

            Detects when a variable is used that has not been defined before.

            Example

            class Foo
            {
                private function bar()
                {
                    // $message is undefined
                    echo $message;
                }
            }

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

            Avoid using undefined variables such as '$discovered' which will lead to PHP notices.
            Open

                    if (($key = array_search($source, $discovered)) !== false) {
            Severity: Minor
            Found in src/Algo/DijkstraMulti.php by phpmd

            UndefinedVariable

            Since: 2.8.0

            Detects when a variable is used that has not been defined before.

            Example

            class Foo
            {
                private function bar()
                {
                    // $message is undefined
                    echo $message;
                }
            }

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

            Avoid using undefined variables such as '$discovered' which will lead to PHP notices.
            Open

                    $discovered[] = $source;
            Severity: Minor
            Found in src/Algo/DijkstraMulti.php by phpmd

            UndefinedVariable

            Since: 2.8.0

            Detects when a variable is used that has not been defined before.

            Example

            class Foo
            {
                private function bar()
                {
                    // $message is undefined
                    echo $message;
                }
            }

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

            Function enumerate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                private function enumerate($source, $dest)
                {
                    array_unshift($this->path, $source);
                    $discovered[] = $source;
            
            
            Severity: Minor
            Found in src/Algo/DijkstraMulti.php - About 1 hr 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 run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public function run($root)
                {
                    foreach (array_keys($this->graph->vertices) as $vertex) {
                        $this->dist[$vertex] = INF;
                        $this->parent[$vertex] = null;
            Severity: Minor
            Found in src/Algo/BFS.php - About 1 hr 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 run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function run()
                {
                    foreach (array_keys($this->graph->vertices) as $vertex1) {
                        foreach (array_keys($this->graph->vertices) as $vertex2) {
                            $this->dist[$vertex1][$vertex2] = INF;
            Severity: Minor
            Found in src/Algo/FloydWarshall.php - About 1 hr to fix

              Method run has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function run($root)
                  {
                      foreach (array_keys($this->graph->vertices) as $vertex) {
                          $this->dist[$vertex] = INF;
                          $this->parent[$vertex] = null;
              Severity: Minor
              Found in src/Algo/DFS.php - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language