From e8ea8e6f0713e4945709ac98f6af9167a61bb198 Mon Sep 17 00:00:00 2001 From: ermakov-oleg Date: Thu, 19 Sep 2024 13:47:43 +0200 Subject: [PATCH] reporter: display number of files with violations in summary message --- cli/src/reporter.rs | 11 +++++++++++ ...porter__test_reporter__display_violations_tty.snap | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cli/src/reporter.rs b/cli/src/reporter.rs index 9b67cc8c..4094244f 100644 --- a/cli/src/reporter.rs +++ b/cli/src/reporter.rs @@ -321,6 +321,7 @@ pub fn fmt_tty(f: &mut W, files: &[ViolationContent]) -> Result<() } let total_violations = files.iter().map(|f| f.violations.len()).sum::(); let files_checked = files.len(); + let files_with_violations = files.iter().filter(|f| !f.violations.is_empty()).count(); if total_violations == 0 { writeln!( f, @@ -334,6 +335,16 @@ pub fn fmt_tty(f: &mut W, files: &[ViolationContent]) -> Result<() "find detailed examples and solutions for each rule at {}", style("https://squawkhq.com/docs/rules").underlined() )?; + writeln!( + f, + "Found {total_violations} issue{plural} in {files_with_violations} file{files_plural} (checked {files_checked} {files_checked_plural})", + total_violations = total_violations, + plural = if total_violations == 1 { "" } else { "s" }, + files_with_violations = files_with_violations, + files_plural = if files_with_violations == 1 { "" } else { "s" }, + files_checked = files_checked, + files_checked_plural = if files_checked == 1 { "source file" } else { "source files" } + )?; } Ok(()) } diff --git a/cli/src/snapshots/squawk__reporter__test_reporter__display_violations_tty.snap b/cli/src/snapshots/squawk__reporter__test_reporter__display_violations_tty.snap index 56fa90bf..b3decbb5 100644 --- a/cli/src/snapshots/squawk__reporter__test_reporter__display_violations_tty.snap +++ b/cli/src/snapshots/squawk__reporter__test_reporter__display_violations_tty.snap @@ -18,4 +18,4 @@ main.sql:3:1: warning: adding-required-field help: Make the field nullable or add a non-VOLATILE DEFAULT (Postgres 11+). find detailed examples and solutions for each rule at https://squawkhq.com/docs/rules - +Found 2 issues in 1 file (checked 1 source file)