diff --git a/slither/__main__.py b/slither/__main__.py index b92e727b7..37d43d1da 100644 --- a/slither/__main__.py +++ b/slither/__main__.py @@ -462,7 +462,7 @@ def parse_args(detector_classes, printer_classes): # pylint: disable=too-many-s help="Provide a config file (default: slither.config.json)", action="store", dest="config_file", - default="slither.config.json", + default=None, ) group_misc.add_argument( diff --git a/slither/utils/command_line.py b/slither/utils/command_line.py index e7806f68a..c6ab83bfa 100644 --- a/slither/utils/command_line.py +++ b/slither/utils/command_line.py @@ -52,6 +52,15 @@ defaults_flag_in_config = { def read_config_file(args): + # No config file was provided as an argument + if args.config_file is None: + # Check wether the default config file is present + if os.path.exists("slither.config.json"): + # The default file exists, use it + args.config_file = "slither.config.json" + else: + return + if os.path.isfile(args.config_file): try: with open(args.config_file, encoding="utf8") as f: