Skip to content

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

feat(core): flag redundant use of progressive verbs followed by "more" (#2859)

Elijah Potterc909c9233fb8
diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dict
index e31cdaca8..227c1064a 100644
--- a/harper-core/dictionary.dict
+++ b/harper-core/dictionary.dict
@@ -29910,6 +29910,7 @@ incorrigible/JN
incorrigibly/Ry
incorruptibly/Ry
increasing/~JYV6N
+increasingly/R
increment/~NSgVdG
incremental/~JY
incrementalism/N
@@ -40681,6 +40682,7 @@ programming/~NmgV6
progress/~NmgSVdGv
progression/~NgS
progressive/~JYpNgS
+progressively/R
progressiveness/Ng
progressivism/Nmg
prohibit/~VdGSv
diff --git a/harper-core/src/linting/lint_group.rs b/harper-core/src/linting/lint_group.rs
index da5464178..e5e0b05cb 100644
--- a/harper-core/src/linting/lint_group.rs
+++ b/harper-core/src/linting/lint_group.rs
@@ -173,6 +173,7 @@ use super::quite_quiet::QuiteQuiet;
use super::quote_spacing::QuoteSpacing;
use super::redundant_acronyms::RedundantAcronyms;
use super::redundant_additive_adverbs::RedundantAdditiveAdverbs;
+use super::redundant_progressive_comparative::RedundantProgressiveComparative;
use super::regionalisms::Regionalisms;
use super::repeated_words::RepeatedWords;
use super::respond::Respond;
@@ -754,6 +755,7 @@ impl LintGroup {
insert_struct_rule!(QuoteSpacing, true);
insert_expr_rule!(RedundantAcronyms, true);
insert_expr_rule!(RedundantAdditiveAdverbs, true);
+ insert_expr_rule!(RedundantProgressiveComparative, true);
insert_struct_rule_with_dialect!(Regionalisms, true);
insert_struct_rule!(RepeatedWords, true);
insert_expr_rule!(Respond, true);
diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rs
index 13c988de5..c28109d7e 100644
--- a/harper-core/src/linting/mod.rs
+++ b/harper-core/src/linting/mod.rs
@@ -182,6 +182,7 @@ mod quite_quiet;
mod quote_spacing;
mod redundant_acronyms;
mod redundant_additive_adverbs;
+mod redundant_progressive_comparative;
mod regionalisms;
mod repeated_words;
mod respond;
diff --git a/harper-core/src/linting/redundant_progressive_comparative.rs b/harper-core/src/linting/redundant_progressive_comparative.rs
new file mode 100644
index 000000000..f00d47a3a
--- /dev/null
+++ b/harper-core/src/linting/redundant_progressive_comparative.rs
@@ -0,0 +1,234 @@
+use crate::{
+ CharStringExt, Span, Token, TokenKind,
+ expr::{Expr, SequenceExpr},
+ linting::{Chunk, ExprLinter, Lint, LintKind, Suggestion},
+};
+
+pub struct RedundantProgressiveComparative {
+ expr: Box<dyn Expr>,
+}
+
+impl Default for RedundantProgressiveComparative {
+ fn default() -> Self {
+ Self {
+ expr: Box::new(
+ SequenceExpr::aco("increasingly")
+ .t_ws()
+ .then_word_set(&["more", "less"])
+ .t_ws()
+ .then_kind_either(TokenKind::is_adjective, TokenKind::is_adverb),
+ ),
+ }
+ }
+}
+
+impl ExprLinter for RedundantProgressiveComparative {
+ type Unit = Chunk;
+
+ fn expr(&self) -> &dyn Expr {
+ self.expr.as_ref()
+ }
+
+ fn match_to_lint(&self, matched_tokens: &[Token], src: &[char]) -> Option<Lint> {
+ let first = matched_tokens.first()?;
+ let second = matched_tokens.get(2)?;
+
+ let (replacement, message) = if second
+ .span
+ .get_content(src)
+ .eq_ignore_ascii_case_str("more")
+ {
+ (
+ "more and more",
+ "This phrasing is redundant; use a direct comparative like `more and more`.",
+ )
+ } else if second
+ .span
+ .get_content(src)
+ .eq_ignore_ascii_case_str("less")
+ {
+ (
+ "less and less",
+ "This phrasing is redundant; use a direct comparative like `less and less`.",
+ )
+ } else {
+ return None;
+ };
+
+ let span = Span::new(first.span.start, second.span.end);
+
+ Some(Lint {
+ span,
+ lint_kind: LintKind::Redundancy,
+ suggestions: vec![Suggestion::replace_with_match_case_str(
+ replacement,
+ span.get_content(src),
+ )],
+ message: message.to_string(),
+ priority: 31,
+ })
+ }
+
+ fn description(&self) -> &'static str {
+ "Detects redundant comparatives like `increasingly more` and `increasingly less`."
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::RedundantProgressiveComparative;
+ use crate::linting::tests::{assert_lint_count, assert_no_lints, assert_suggestion_result};
+
+ #[test]
+ fn fixes_increasingly_more() {
+ assert_suggestion_result(
+ "The issue is increasingly more prevalent in distributed systems.",
+ RedundantProgressiveComparative::default(),
+ "The issue is more and more prevalent in distributed systems.",
+ );
+ }
+
+ #[test]
+ fn fixes_increasingly_less() {
+ assert_suggestion_result(
+ "The outages are increasingly less frequent after the migration.",
+ RedundantProgressiveComparative::default(),
+ "The outages are less and less frequent after the migration.",
+ );
+ }
+
+ #[test]
+ fn preserves_match_case_title() {
+ assert_suggestion_result(
+ "The bug is Increasingly More Prevalent in nightly builds.",
+ RedundantProgressiveComparative::default(),
+ "The bug is More and more Prevalent in nightly builds.",
+ );
+ }
+
+ #[test]
+ fn preserves_match_case_all_caps() {
+ assert_suggestion_result(
+ "The bug is INCREASINGLY MORE PREVALENT in nightly builds.",
+ RedundantProgressiveComparative::default(),
+ "The bug is MORE AND MORE PREVALENT in nightly builds.",
+ );
+ }
+
+ #[test]
+ fn preserves_match_case_less_all_caps() {
+ assert_suggestion_result(
+ "The regressions are INCREASINGLY LESS SEVERE with each patch.",
+ RedundantProgressiveComparative::default(),
+ "The regressions are LESS AND LESS SEVERE with each patch.",
+ );
+ }
+
+ #[test]
+ fn ignores_progressively_more() {
+ assert_no_lints(
+ "These failures are progressively more severe in production.",
+ RedundantProgressiveComparative::default(),
+ );
+ }
+
+ #[test]
+ fn ignores_steadily_more() {
+ assert_no_lints(
+ "The interface is steadily more accessible each release.",
+ RedundantProgressiveComparative::default(),
+ );
+ }
+
+ #[test]
+ fn ignores_progressively_less() {
+ assert_no_lints(
+ "The warnings became progressively less noticeable over time.",
+ RedundantProgressiveComparative::default(),
+ );
+ }
+
+ #[test]
+ fn ignores_steadily_less() {
+ assert_no_lints(
+ "The logs are steadily less noisy in recent builds.",
+ RedundantProgressiveComparative::default(),
+ );
+ }
+
+ #[test]
+ fn ignores_more_than() {
+ assert_no_lints(
+ "The issue is increasingly more than a minor annoyance.",
+ RedundantProgressiveComparative::default(),
+ );
+ }
+
+ #[test]
+ fn ignores_less_than() {
+ assert_no_lints(
+ "The issue is increasingly less than a minor annoyance.",
+ RedundantProgressiveComparative::default(),
+ );
+ }
+
+ #[test]
+ fn ignores_noun_after_more() {
+ assert_no_lints(
+ "The issue is increasingly more people reporting crashes.",
+ RedundantProgressiveComparative::default(),
+ );
+ }
+
+ #[test]
+ fn ignores_noun_after_less() {
+ assert_no_lints(
+ "The issue is increasingly less people reporting crashes.",
+ RedundantProgressiveComparative::default(),
+ );
+ }
+
+ #[test]
+ fn ignores_without_comparator() {
+ assert_no_lints(
+ "The issue is increasingly prevalent in this subsystem.",
+ RedundantProgressiveComparative::default(),
+ );
+ }
+
+ #[test]
+ fn ignores_other_adverbial_comparatives() {
+ assert_no_lints(
+ "The issue is much more prevalent in this subsystem.",
+ RedundantProgressiveComparative::default(),
+ );
+ assert_no_lints(
+ "The issue is significantly less prevalent in this subsystem.",
+ RedundantProgressiveComparative::default(),
+ );
+ assert_no_lints(
+ "The issue is ever more prevalent in this subsystem.",
+ RedundantProgressiveComparative::default(),
+ );
+ }
+
+ #[test]
+ fn message_mentions_less_and_less_for_less_branch() {
+ use crate::linting::tests::assert_lint_message;
+
+ assert_lint_message(
+ "The trend is increasingly less stable over time.",
+ RedundantProgressiveComparative::default(),
+ "This phrasing is redundant; use a direct comparative like `less and less`.",
+ );
+ }
+
+ #[test]
+ fn emits_expected_lint_count() {
+ assert_lint_count(
+ "The trend is increasingly more likely in larger teams.",
+ RedundantProgressiveComparative::default(),
+ 1,
+ );
+ }
+}