From 05defa87101721a96a6914342ce0c70e8db61d74 Mon Sep 17 00:00:00 2001 From: Simone Date: Thu, 23 Feb 2023 23:56:22 +0100 Subject: [PATCH] Add cyclomatic complexity to modifiers --- .../core/declarations/function_contract.py | 2 +- slither/printers/summary/function.py | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/slither/core/declarations/function_contract.py b/slither/core/declarations/function_contract.py index 72632690c7..01077353b1 100644 --- a/slither/core/declarations/function_contract.py +++ b/slither/core/declarations/function_contract.py @@ -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 diff --git a/slither/printers/summary/function.py b/slither/printers/summary/function.py index 8d58170ab5..7f1633865a 100644 --- a/slither/printers/summary/function.py +++ b/slither/printers/summary/function.py @@ -48,7 +48,7 @@ def output(self, _filename): # pylint: disable=too-many-locals "Write", "Internal Calls", "External Calls", - "Cyclomatic Complexity" + "Cyclomatic Complexity", ] ) for ( @@ -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)) @@ -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) @@ -87,6 +87,7 @@ def output(self, _filename): # pylint: disable=too-many-locals "Write", "Internal Calls", "External Calls", + "Cyclomatic Complexity", ] ) for ( @@ -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)