From 8efde316b038f15055f202ad7413e77e5555bb2c Mon Sep 17 00:00:00 2001 From: bart1e Date: Fri, 16 Dec 2022 18:53:41 +0100 Subject: [PATCH] Printer outputs sorted --- slither/printers/functions/authorization.py | 4 ++-- slither/printers/summary/data_depenency.py | 6 +++--- slither/printers/summary/function.py | 18 +++++++++--------- slither/printers/summary/modifier_calls.py | 2 +- slither/printers/summary/require_calls.py | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/slither/printers/functions/authorization.py b/slither/printers/functions/authorization.py index 488c03e94..ab61d354e 100644 --- a/slither/printers/functions/authorization.py +++ b/slither/printers/functions/authorization.py @@ -54,8 +54,8 @@ class PrinterWrittenVariablesAndAuthorization(AbstractPrinter): table.add_row( [ function.name, - str(state_variables_written), - str(msg_sender_condition), + str(sorted(state_variables_written)), + str(sorted(msg_sender_condition)), ] ) all_tables.append((contract.name, table)) diff --git a/slither/printers/summary/data_depenency.py b/slither/printers/summary/data_depenency.py index 88f78f731..41659a299 100644 --- a/slither/printers/summary/data_depenency.py +++ b/slither/printers/summary/data_depenency.py @@ -42,7 +42,7 @@ class DataDependency(AbstractPrinter): txt += f"\nContract {c.name}\n" table = MyPrettyTable(["Variable", "Dependencies"]) for v in c.state_variables: - table.add_row([v.name, _get(v, c)]) + table.add_row([v.name, sorted(_get(v, c))]) txt += str(table) @@ -51,9 +51,9 @@ class DataDependency(AbstractPrinter): txt += f"\nFunction {f.full_name}\n" table = MyPrettyTable(["Variable", "Dependencies"]) for v in f.variables: - table.add_row([v.name, _get(v, f)]) + table.add_row([v.name, sorted(_get(v, f))]) for v in c.state_variables: - table.add_row([v.canonical_name, _get(v, f)]) + table.add_row([v.canonical_name, sorted(_get(v, f))]) txt += str(table) self.info(txt) diff --git a/slither/printers/summary/function.py b/slither/printers/summary/function.py index 0c5627eb2..b9353ce25 100644 --- a/slither/printers/summary/function.py +++ b/slither/printers/summary/function.py @@ -60,15 +60,15 @@ class FunctionSummary(AbstractPrinter): internal_calls, external_calls, ) in func_summaries: - read = self._convert(read) - write = self._convert(write) - internal_calls = self._convert(internal_calls) - external_calls = self._convert(external_calls) + 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, - modifiers, + sorted(modifiers), read, write, internal_calls, @@ -96,10 +96,10 @@ class FunctionSummary(AbstractPrinter): internal_calls, external_calls, ) in modif_summaries: - read = self._convert(read) - write = self._convert(write) - internal_calls = self._convert(internal_calls) - external_calls = self._convert(external_calls) + 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]) txt += "\n\n" + str(table) txt += "\n" diff --git a/slither/printers/summary/modifier_calls.py b/slither/printers/summary/modifier_calls.py index 530caabc9..cd6c4062e 100644 --- a/slither/printers/summary/modifier_calls.py +++ b/slither/printers/summary/modifier_calls.py @@ -35,7 +35,7 @@ class Modifiers(AbstractPrinter): for (_, call) in function.all_library_calls(): if isinstance(call, Function): modifiers += call.modifiers - table.add_row([function.name, [m.name for m in set(modifiers)]]) + table.add_row([function.name, sorted([m.name for m in set(modifiers)])]) txt += "\n" + str(table) self.info(txt) all_txt += txt diff --git a/slither/printers/summary/require_calls.py b/slither/printers/summary/require_calls.py index 77d95ba5f..7823de160 100644 --- a/slither/printers/summary/require_calls.py +++ b/slither/printers/summary/require_calls.py @@ -48,7 +48,7 @@ class RequireOrAssert(AbstractPrinter): table.add_row( [ function.name, - self._convert([str(m.expression) for m in set(require)]), + self._convert(sorted([str(m.expression) for m in set(require)])), ] ) txt += "\n" + str(table)