Add cyclomatic complexity to modifiers

pull/1685/head
Simone 2 years ago
parent 143223af95
commit 05defa8710
  1. 2
      slither/core/declarations/function_contract.py
  2. 20
      slither/printers/summary/function.py

@ -90,7 +90,7 @@ class FunctionContract(Function, ChildContract, ChildInheritance):
[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

@ -48,7 +48,7 @@ class FunctionSummary(AbstractPrinter):
"Write",
"Internal Calls",
"External Calls",
"Cyclomatic Complexity"
"Cyclomatic Complexity",
]
)
for (
@ -60,7 +60,7 @@ class FunctionSummary(AbstractPrinter):
write,
internal_calls,
external_calls,
cyclomatic_complexity
cyclomatic_complexity,
) in func_summaries:
read = self._convert(sorted(read))
write = self._convert(sorted(write))
@ -75,7 +75,7 @@ class FunctionSummary(AbstractPrinter):
write,
internal_calls,
external_calls,
cyclomatic_complexity
cyclomatic_complexity,
]
)
txt += "\n \n" + str(table)
@ -87,6 +87,7 @@ class FunctionSummary(AbstractPrinter):
"Write",
"Internal Calls",
"External Calls",
"Cyclomatic Complexity",
]
)
for (
@ -98,12 +99,23 @@ class FunctionSummary(AbstractPrinter):
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)

Loading…
Cancel
Save