Skip to content

Commit

Permalink
Add cyclomatic complexity to modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
smonicas committed Feb 23, 2023
1 parent 143223a commit 05defa8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion slither/core/declarations/function_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_summary(
[str(x) for x in self.state_variables_written],
[str(x) for x in self.internal_calls],
[str(x) for x in self.external_calls_as_expressions],
compute_cyclomatic_complexity(self)
compute_cyclomatic_complexity(self),
)

# endregion
Expand Down
20 changes: 16 additions & 4 deletions slither/printers/summary/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def output(self, _filename): # pylint: disable=too-many-locals
"Write",
"Internal Calls",
"External Calls",
"Cyclomatic Complexity"
"Cyclomatic Complexity",
]
)
for (
Expand All @@ -60,7 +60,7 @@ def output(self, _filename): # pylint: disable=too-many-locals
write,
internal_calls,
external_calls,
cyclomatic_complexity
cyclomatic_complexity,
) in func_summaries:
read = self._convert(sorted(read))
write = self._convert(sorted(write))
Expand All @@ -75,7 +75,7 @@ def output(self, _filename): # pylint: disable=too-many-locals
write,
internal_calls,
external_calls,
cyclomatic_complexity
cyclomatic_complexity,
]
)
txt += "\n \n" + str(table)
Expand All @@ -87,6 +87,7 @@ def output(self, _filename): # pylint: disable=too-many-locals
"Write",
"Internal Calls",
"External Calls",
"Cyclomatic Complexity",
]
)
for (
Expand All @@ -98,12 +99,23 @@ def output(self, _filename): # pylint: disable=too-many-locals
write,
internal_calls,
external_calls,
cyclomatic_complexity,
) in modif_summaries:
read = self._convert(sorted(read))
write = self._convert(sorted(write))
internal_calls = self._convert(sorted(internal_calls))
external_calls = self._convert(sorted(external_calls))
table.add_row([f_name, visi, read, write, internal_calls, external_calls])
table.add_row(
[
f_name,
visi,
read,
write,
internal_calls,
external_calls,
cyclomatic_complexity,
]
)
txt += "\n\n" + str(table)
txt += "\n"
self.info(txt)
Expand Down

0 comments on commit 05defa8

Please sign in to comment.