Merge pull request #1513 from bart1e/deterministic-printer-output

Printer outputs sorted
pull/1542/head
Feist Josselin 2 years ago committed by GitHub
commit a98a5c4e52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      slither/printers/functions/authorization.py
  2. 6
      slither/printers/summary/data_depenency.py
  3. 18
      slither/printers/summary/function.py
  4. 2
      slither/printers/summary/modifier_calls.py
  5. 2
      slither/printers/summary/require_calls.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))

@ -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)

@ -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"

@ -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

@ -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)

Loading…
Cancel
Save