Skip to content

Commit

Permalink
Merge pull request #1617 from bart1e/strongly_connected_components_fix
Browse files Browse the repository at this point in the history
Bugs fixed in strongly connected components and cyclomatic complexity algorithms
  • Loading branch information
montyly authored Jan 23, 2023
2 parents 818c485 + 9d510ec commit b6d6294
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions slither/utils/code_complexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def assign(node: "Node", root: List["Node"]):
for father in node.fathers:
assign(father, root)

for n in l:
for n in reversed(l):
component: List["Node"] = []
assign(n, component)
if component:
Expand All @@ -74,9 +74,9 @@ def compute_cyclomatic_complexity(function: "Function") -> int:
# where M is the complexity
# E number of edges
# N number of nodes
# P number of connected components
# P number of connected components (always 1 for a function)

E = compute_number_edges(function)
N = len(function.nodes)
P = len(compute_strongly_connected_components(function))
P = 1
return E - N + 2 * P

0 comments on commit b6d6294

Please sign in to comment.