Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

feat(stats): count total applied suggestions

Elijah Potter70c041977505
diff --git a/harper-stats/src/summary.rs b/harper-stats/src/summary.rs
index ac2e82393..04bbbfad2 100644
--- a/harper-stats/src/summary.rs
+++ b/harper-stats/src/summary.rs
@@ -2,8 +2,10 @@ use std::{collections::HashMap, fmt::Display};
use harper_core::linting::{LintGroupConfig, LintKind};
+#[derive(Debug, Default)]
pub struct Summary {
pub lint_counts: HashMap<LintKind, u32>,
+ pub total_applied: u32,
pub final_config: LintGroupConfig,
// The most common misspelled words.
pub misspelled: HashMap<String, u32>,
@@ -11,11 +13,7 @@ pub struct Summary {
impl Summary {
pub fn new() -> Self {
- Self {
- lint_counts: HashMap::new(),
- final_config: LintGroupConfig::default(),
- misspelled: HashMap::new(),
- }
+ Self::default()
}
/// Increment the count for a particular lint kind.
@@ -24,6 +22,7 @@ impl Summary {
.entry(kind)
.and_modify(|counter| *counter += 1)
.or_insert(1);
+ self.total_applied += 1;
}
/// Increment the count for a particular misspelled word.
@@ -41,12 +40,6 @@ impl Summary {
}
}
-impl Default for Summary {
- fn default() -> Self {
- Self::new()
- }
-}
-
impl Display for Summary {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, "`LintKind` counts")?;