Add cyclomatic complexity to function-summary

pull/1685/head
Simone 2 years ago
parent 9779380b80
commit 143223af95
  1. 4
      slither/core/declarations/function_contract.py
  2. 3
      slither/printers/summary/function.py

@ -6,6 +6,7 @@ from typing import Dict, TYPE_CHECKING, List, Tuple
from slither.core.children.child_contract import ChildContract
from slither.core.children.child_inheritance import ChildInheritance
from slither.core.declarations import Function
from slither.utils.code_complexity import compute_cyclomatic_complexity
# pylint: disable=import-outside-toplevel,too-many-instance-attributes,too-many-statements,too-many-lines
@ -73,7 +74,7 @@ class FunctionContract(Function, ChildContract, ChildInheritance):
def get_summary(
self,
) -> Tuple[str, str, str, List[str], List[str], List[str], List[str], List[str]]:
) -> Tuple[str, str, str, List[str], List[str], List[str], List[str], List[str], int]:
"""
Return the function summary
Returns:
@ -89,6 +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)
)
# endregion

@ -48,6 +48,7 @@ class FunctionSummary(AbstractPrinter):
"Write",
"Internal Calls",
"External Calls",
"Cyclomatic Complexity"
]
)
for (
@ -59,6 +60,7 @@ class FunctionSummary(AbstractPrinter):
write,
internal_calls,
external_calls,
cyclomatic_complexity
) in func_summaries:
read = self._convert(sorted(read))
write = self._convert(sorted(write))
@ -73,6 +75,7 @@ class FunctionSummary(AbstractPrinter):
write,
internal_calls,
external_calls,
cyclomatic_complexity
]
)
txt += "\n \n" + str(table)

Loading…
Cancel
Save