algb12/GraphDS

View on GitHub

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

      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

      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/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

        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

        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

            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

                Function removeEdge has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function removeEdge($vertex1, $vertex2)
                    {
                        if (empty($this->vertices[$vertex1]) || empty($this->vertices[$vertex2])) {
                            throw new InvalidArgumentException('One of the vertices does not exist.');
                        }
                Severity: Minor
                Found in src/Graph/UndirectedGraph.php - About 55 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 getGraphML has a Cognitive Complexity of 9 (exceeds 5 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 55 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 removeVertex has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function removeVertex($vertex)
                    {
                        if (empty($this->vertices[$vertex])) {
                            throw new InvalidArgumentException("Vertex $vertex does not exist.");
                        }
                Severity: Minor
                Found in src/Graph/DirectedGraph.php - About 55 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 removeVertex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function removeVertex($vertex)
                    {
                        if (empty($this->vertices[$vertex])) {
                            throw new InvalidArgumentException("Vertex $vertex does not exist.");
                        }
                Severity: Minor
                Found in src/Graph/UndirectedGraph.php - About 25 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