From 9d510eccef8e7c3c68593ed8b8a040ee0809a3e0 Mon Sep 17 00:00:00 2001 From: bart1e Date: Sat, 21 Jan 2023 14:45:29 +0100 Subject: [PATCH] Strongly connected components algorithm fix + cyclomatic complexity algorithm fix --- slither/utils/code_complexity.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/slither/utils/code_complexity.py b/slither/utils/code_complexity.py index 54b14f028d..a389663b33 100644 --- a/slither/utils/code_complexity.py +++ b/slither/utils/code_complexity.py @@ -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: @@ -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