use crate::suppression::ignore_entry::IgnoreEntry;
pub struct StaleReport<'a> {
entries: Vec<&'a IgnoreEntry>,
removed: bool,
}
impl<'a> StaleReport<'a> {
#[must_use]
pub const fn dry_run(entries: Vec<&'a IgnoreEntry>) -> Self {
Self {
entries,
removed: false,
}
}
#[must_use]
pub const fn removed(entries: Vec<&'a IgnoreEntry>) -> Self {
Self {
entries,
removed: true,
}
}
#[must_use]
pub const fn is_empty(&self) -> bool {
self.entries.is_empty()
}
#[must_use]
pub fn entries(&self) -> &[&'a IgnoreEntry] {
&self.entries
}
#[must_use]
pub const fn heading(&self) -> &'static str {
if self.removed {
"Removed stale entries:"
} else {
"Stale entries (dry run):"
}
}
#[must_use]
pub fn summary(&self) -> String {
let count = self.entries.len();
if self.removed {
format!("\nRemoved {count} stale entries.")
} else {
format!("\n{count} stale entries would be removed.")
}
}
}