Skip to content

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

fix(core): ignore pronouns in `PluralConjugate`

Elijah Potterf56eecd9b8d5
diff --git a/harper-core/src/linting/plural_conjugate.rs b/harper-core/src/linting/plural_conjugate.rs
index af8e92b93..5071e543e 100644
--- a/harper-core/src/linting/plural_conjugate.rs
+++ b/harper-core/src/linting/plural_conjugate.rs
@@ -18,7 +18,7 @@ impl Default for PluralConjugate {
let non_plural_case = SequencePattern::default()
.then(Box::new(|tok: &Token, _source: &[char]| {
- tok.kind.is_not_plural_noun() && tok.kind.is_noun()
+ tok.kind.is_not_plural_noun() && tok.kind.is_noun() && !tok.kind.is_pronoun()
}))
.then_whitespace()
.then_exact_word("are");
@@ -61,7 +61,7 @@ impl PatternLinter for PluralConjugate {
#[cfg(test)]
mod tests {
- use crate::linting::tests::assert_suggestion_result;
+ use crate::linting::tests::{assert_lint_count, assert_suggestion_result};
use super::PluralConjugate;
@@ -91,4 +91,13 @@ mod tests {
"The house is just sitting there.",
);
}
+
+ #[test]
+ fn review_doc_page() {
+ assert_lint_count(
+ "If you are testing it, try harder.",
+ PluralConjugate::default(),
+ 0,
+ );
+ }
}
diff --git a/harper-core/src/token_kind.rs b/harper-core/src/token_kind.rs
index 25aecb499..0e5a09597 100644
--- a/harper-core/src/token_kind.rs
+++ b/harper-core/src/token_kind.rs
@@ -304,6 +304,14 @@ impl TokenKind {
metadata.is_linking_verb()
}
+ pub fn is_not_pronoun_noun(&self) -> bool {
+ let TokenKind::Word(metadata) = self else {
+ return true;
+ };
+
+ metadata.is_not_pronoun_noun()
+ }
+
pub fn is_not_plural_noun(&self) -> bool {
let TokenKind::Word(metadata) = self else {
return true;