diff --git a/refurb/loader.py b/refurb/loader.py index 48e9f0a..f71515c 100644 --- a/refurb/loader.py +++ b/refurb/loader.py @@ -183,9 +183,12 @@ def load_checks(settings: Settings) -> defaultdict[type[Node], list[Check]]: enabled_errors.add(str(ErrorCode.from_error(error))) if settings.verbose: - print("Enabled checks:") + msg = ( + ", ".join(sorted(enabled_errors)) + if enabled_errors + else "No checks enabled" + ) - for code in sorted(enabled_errors): - print(code) + print(f"Enabled checks: {msg}\n") return found diff --git a/test/test_main.py b/test/test_main.py index 21a2656..4bfb002 100644 --- a/test/test_main.py +++ b/test/test_main.py @@ -251,14 +251,22 @@ def test_verbose_flag_prints_all_enabled_checks() -> None: with patch("builtins.print") as p: main(["test/data/err_100.py", "--verbose", "--enable-all"]) + stdout = "\n".join(args[0][0] for args in p.call_args_list) + # Current number of checks at time of writing. This number doesn't need to # be kept updated, it is only set to a known value to verify that it is # doing what it should. current_check_count = 76 - assert p.call_count > current_check_count + for error_id in range(100, 100 + current_check_count): + assert f"FURB{error_id}" in stdout + + +def test_verbose_flag_prints_message_when_all_checks_disabled() -> None: + with patch("builtins.print") as p: + main(["test/data/err_100.py", "--verbose", "--disable-all"]) stdout = "\n".join(args[0][0] for args in p.call_args_list) - for error_id in range(100, 100 + current_check_count): - assert f"FURB{error_id}" in stdout + assert "FURB100" not in stdout + assert "No checks enabled" in stdout