Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file violation count to summary report output #378

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cli/src/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ pub fn fmt_tty<W: io::Write>(f: &mut W, files: &[ViolationContent]) -> Result<()
}
let total_violations = files.iter().map(|f| f.violations.len()).sum::<usize>();
let files_checked = files.len();
let files_with_violations = files.iter().filter(|f| !f.violations.is_empty()).count();
if total_violations == 0 {
writeln!(
f,
Expand All @@ -334,6 +335,16 @@ pub fn fmt_tty<W: io::Write>(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(())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading