phgraph/graph

View on GitHub

Showing 16 of 18 total issues

Function getEdges has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    public function getEdges(): array
    {
        if (isset($this->edges)) {
            return $this->edges;
        }
Severity: Minor
Found in src/ShortestPath/MooreBellmanFord.php - About 6 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 createScript has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

    public function createScript(): string
    {
        $directed = $this->graph->hasDirected();

        $name = $this->graph->getAttribute('graphviz.name');
Severity: Minor
Found in src/GraphViz/GraphViz.php - About 6 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 getEdges has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    public function getEdges(): array
    {
        $edge_queue = new SplPriorityQueue();

        /** @var \PHGraph\Edge $edge */
Severity: Minor
Found in src/MinimumSpanningTree/Kruskal.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 getEdges has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    public function getEdges(): array
    {
        if (isset($this->edges)) {
            return $this->edges;
        }
Severity: Minor
Found in src/ShortestPath/Dijkstra.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 getEdges has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function getEdges(): array
    {
        $edges = [];
        $vertex_current = $this->start_vertex;
        $marked = new SplObjectStorage();
Severity: Minor
Found in src/TravelingSalesman/NearestNeighbor.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

Function getEdgesTo has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function getEdgesTo(Vertex $vertex): array
    {
        if ($vertex === $this->vertex) {
            return [];
        }
Severity: Minor
Found in src/ShortestPath/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 getEdges has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function getEdges(): array
    {
        $edge_queue = new SplPriorityQueue();
        $edges = [];

Severity: Minor
Found in src/MinimumSpanningTree/Prim.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 getEdgesTo has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function getEdgesTo(Vertex $vertex): array
    {
        $current_vertex = $vertex;
        $path = [];

Severity: Minor
Found in src/ShortestPath/MooreBellmanFord.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 newFromVertices has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function newFromVertices(array $vertices): Graph
    {
        $new_graph = new static();
        $new_graph->attributes = $this->attributes;
        $keyed_vertices = [];
Severity: Minor
Found in src/Graph.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 isBipartit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function isBipartit(): bool
    {
        if ($this->getNumberOfGroups() !== 2) {
            return false;
        }
Severity: Minor
Found in src/Graph.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 isComplete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function isComplete(): bool
    {
        foreach ($this->vertices as $vertex_a) {
            $connected_vertices = $vertex_a->getVertices();
            foreach ($this->vertices as $vertex_b) {
Severity: Minor
Found in src/Graph.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

Avoid too many return statements within this method.
Open

                    return $left->getAttribute('weight', 0) - $right->getAttribute('weight', 0);
Severity: Major
Found in src/ShortestPath/MooreBellmanFord.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return $this->edges;
    Severity: Major
    Found in src/ShortestPath/MooreBellmanFord.php - About 30 mins to fix

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

          public function removeEdge(Edge $edge, bool $disable = false): void
          {
              if (isset($this->edges_in[$edge->getId()])) {
                  if ($disable) {
                      $this->edges_in_disabled[$edge->getId()] = $edge;
      Severity: Minor
      Found in src/Vertex.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

      Function getVertices has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getVertices(): array
          {
              /** @var \PHGraph\Vertex[] $visited */
              $visited = [];
              $queue = new SplQueue();
      Severity: Minor
      Found in src/Search/DepthFirst.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

      Function getVertices has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getVertices(): array
          {
              $vertices = [];
              $has_loop = false;
      
      
      Severity: Minor
      Found in src/Vertex.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