Remove libraries, mock contract, option interfaces

pull/2153/head
Simone 2 years ago committed by Alexis
parent 118c916b35
commit 41f599b546
No known key found for this signature in database
  1. 8
      slither/__main__.py
  2. 8
      slither/printers/inheritance/inheritance_graph.py
  3. 4
      slither/slither.py

@ -335,6 +335,14 @@ def parse_args(
default=defaults_flag_in_config["printers_to_run"],
)
group_printer.add_argument(
"--exclude-interfaces",
help= "Exclude interfaces from inheritance-graph printer",
action="store_true",
dest="exclude_interfaces",
default=False,
)
group_detector.add_argument(
"--list-detectors",
help="List available detectors",

@ -98,12 +98,14 @@ class PrinterInheritanceGraph(AbstractPrinter):
"""
ret = ""
inheritance = [i for i in contract.immediate_inheritance if "mock" not in i.name.lower()]
# Add arrows (number them if there is more than one path so we know order of declaration for inheritance).
if len(contract.immediate_inheritance) == 1:
if len(inheritance) == 1:
immediate_inheritance = contract.immediate_inheritance[0]
ret += f"c{contract.id}_{contract.name} -> c{immediate_inheritance.id}_{immediate_inheritance};\n"
else:
for i, immediate_inheritance in enumerate(contract.immediate_inheritance):
for i, immediate_inheritance in enumerate(inheritance):
ret += f'c{contract.id}_{contract.name} -> c{immediate_inheritance.id}_{immediate_inheritance} [ label="{i + 1}" ];\n'
# Functions
@ -195,6 +197,8 @@ class PrinterInheritanceGraph(AbstractPrinter):
content = 'digraph "" {\n'
for c in self.contracts:
if c.is_top_level or "mock" in c.name.lower() or c.is_library or (self.slither.exclude_interfaces and c.is_interface):
continue
content += self._summary(c) + "\n"
content += "}"

@ -196,10 +196,12 @@ class Slither(
if printers_to_run == "echidna":
self.skip_data_dependency = True
# Used in inheritance-graph printer
self.exclude_interfaces = kwargs.get("exclude_interfaces", False)
self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
def _init_parsing_and_analyses(self, skip_analyze: bool) -> None:
for parser in self._parsers:
try:
parser.parse_contracts()

Loading…
Cancel
Save