From a6f08ed6aa6d3279a82e9408285b6b1c8c15bbd8 Mon Sep 17 00:00:00 2001 From: Josselin Date: Tue, 11 Sep 2018 09:21:11 +0100 Subject: [PATCH] Move contract analysis to Slither.__init__. Remove useless check --- slither/__main__.py | 2 -- slither/slither.py | 8 ++------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/slither/__main__.py b/slither/__main__.py index a003afffe..c65ab0a28 100644 --- a/slither/__main__.py +++ b/slither/__main__.py @@ -29,8 +29,6 @@ def process(filename, args, detector_classes, printer_classes): for printer_cls in printer_classes: slither.register_printer(printer_cls) - slither.analyze_contracts() - analyzed_contracts_count = len(slither.contracts) results = [] diff --git a/slither/slither.py b/slither/slither.py index 869a42e88..67290718a 100644 --- a/slither/slither.py +++ b/slither/slither.py @@ -28,6 +28,8 @@ class Slither(SlitherSolc): for d in stdout: self.parse_contracts_from_json(d) + self.analyze_contracts() + def register_detector(self, detector_class): """ :param detector_class: Class inheriting from `AbstractDetector`. @@ -50,8 +52,6 @@ class Slither(SlitherSolc): """ :return: List of registered detectors results. """ - if not self.analyzed: - raise Exception('Launch analysis first by calling {}!'.format(self.analyze_contracts.__name__)) return [d.detect() for d in self._detectors] @@ -59,14 +59,10 @@ class Slither(SlitherSolc): """ :return: List of registered printers outputs. """ - if not self.analyzed: - raise Exception('Launch analysis first by calling {}!'.format(self.analyze_contracts.__name__)) return [p.output(self.filename) for p in self._printers] def _check_common_things(self, thing_name, cls, base_cls, instances_list): - if self.analyzed: - raise Exception('There is no point of registering {} after running the analyzis.'.format(thing_name)) if not issubclass(cls, base_cls) or cls is base_cls: raise Exception(