From c09578d970fa9d8409852b3e4ab460a200cfdffd Mon Sep 17 00:00:00 2001 From: Eljees <3.14hell@gmail.com> Date: Mon, 21 Sep 2026 23:25:15 +0300 Subject: [PATCH] fix(reports): do not report success when every model was skipped The console summary printed 'No issues found!' even when the scan skipped all files, which reads as a clean result. Signed-off-by: Eljees <3.14hell@gmail.com> --- modelscan/reports.py | 6 ++++++ tests/test_reports.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tests/test_reports.py diff --git a/modelscan/reports.py b/modelscan/reports.py index f09159b8..529846f2 100644 --- a/modelscan/reports.py +++ b/modelscan/reports.py @@ -60,6 +60,12 @@ def generate( print(f"\n[blue]--- {issue_keys} ---") for issue in issues_by_severity[issue_keys]: issue.print() + elif scan.skipped: + # Nothing was scanned successfully, so "no issues" would be misleading. + print( + "\n[yellow] No issues found in the scanned files, but " + f"{len(scan.skipped)} file(s) were skipped and not scanned." + ) else: print("\n[green] No issues found! 🎉") diff --git a/tests/test_reports.py b/tests/test_reports.py new file mode 100644 index 00000000..c3fc27c5 --- /dev/null +++ b/tests/test_reports.py @@ -0,0 +1,36 @@ +# Tests for the modelscan console report. +from typing import Any, Dict, List + +from modelscan.reports import ConsoleReport + + +class _Issues: + def __init__(self) -> None: + self.all_issues: List[Any] = [] + + def group_by_severity(self) -> Dict[str, Any]: + return {} + + +class _Scan: + """Minimal stand-in for ModelScan: no issues, no errors, N skipped files.""" + + def __init__(self, skipped: List[str]) -> None: + self.issues = _Issues() + self.errors: List[Any] = [] + self.skipped = skipped + + +def test_console_report_does_not_claim_success_when_files_are_skipped(capsys: Any) -> None: + ConsoleReport.generate(_Scan(["model.bin"]), settings={"show_skipped": False}) + + output = capsys.readouterr().out + assert "No issues found!" not in output + assert "No issues found in the scanned files" in output + assert "1 file(s) were skipped" in output + + +def test_console_report_reports_success_when_nothing_is_skipped(capsys: Any) -> None: + ConsoleReport.generate(_Scan([]), settings={"show_skipped": False}) + + assert "No issues found!" in capsys.readouterr().out