Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs fixed in strongly connected components and cyclomatic complexity algorithms #1617

Merged
merged 1 commit into from
Jan 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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