Skip to content

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

feat: get/go pass→get/go past (#4121)

Andrew Dunbarc74aa5669d53
diff --git a/harper-core/default_config.json b/harper-core/default_config.json
index b27b01ef0..953e071a2 100644
--- a/harper-core/default_config.json
+++ b/harper-core/default_config.json
@@ -3413,6 +3413,13 @@
"label": "Full to the Brim"
}
},
+ {
+ "Bool": {
+ "name": "GetPassGoPass",
+ "state": true,
+ "label": "Get Pass, Go Pass"
+ }
+ },
{
"Bool": {
"name": "HadOf",
diff --git a/harper-core/src/linting/get_pass_go_pass.rs b/harper-core/src/linting/get_pass_go_pass.rs
new file mode 100644
index 000000000..f4e1e6fb3
--- /dev/null
+++ b/harper-core/src/linting/get_pass_go_pass.rs
@@ -0,0 +1,136 @@
+use crate::{
+ Lint, Token,
+ expr::{Expr, SequenceExpr},
+ linting::{ExprLinter, LintKind, Suggestion, expr_linter::Chunk},
+};
+
+pub struct GetPassGoPass {
+ expr: SequenceExpr,
+}
+
+impl Default for GetPassGoPass {
+ fn default() -> Self {
+ Self {
+ expr: SequenceExpr::word_set(&[
+ "get", "gets", "getting", "got", "gotten", "go", "goes", "going", "gone", "went",
+ ])
+ .t_ws()
+ .t_aco("pass"),
+ }
+ }
+}
+
+impl ExprLinter for GetPassGoPass {
+ type Unit = Chunk;
+
+ fn match_to_lint(&self, toks: &[Token], src: &[char]) -> Option<Lint> {
+ let span = toks.last()?.span;
+
+ Some(Lint {
+ span,
+ lint_kind: LintKind::Grammar,
+ suggestions: vec![Suggestion::replace_with_match_case_str(
+ "past",
+ span.get_content(src),
+ )],
+ message: "Use the preposition `past` here and not the verb `pass`.".to_owned(),
+ ..Default::default()
+ })
+ }
+
+ fn expr(&self) -> &dyn Expr {
+ &self.expr
+ }
+
+ fn description(&self) -> &str {
+ "Corrects `pass` to `past` after `get` and `go`."
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use crate::linting::tests::assert_suggestion_result;
+
+ use super::GetPassGoPass;
+
+ #[test]
+ fn fix_get_pass() {
+ assert_suggestion_result(
+ "Can't get pass the provider confirmation in the exchange feature",
+ GetPassGoPass::default(),
+ "Can't get past the provider confirmation in the exchange feature",
+ );
+ }
+
+ #[test]
+ fn fix_gets_pass() {
+ assert_suggestion_result(
+ "But once rewritten in block code it gets pass the type check just fine",
+ GetPassGoPass::default(),
+ "But once rewritten in block code it gets past the type check just fine",
+ );
+ }
+
+ #[test]
+ fn fix_getting_pass() {
+ assert_suggestion_result(
+ "I am not getting pass the initial \"Control the game using WASD keys\" message.",
+ GetPassGoPass::default(),
+ "I am not getting past the initial \"Control the game using WASD keys\" message.",
+ );
+ }
+
+ #[test]
+ fn fix_go_pass() {
+ assert_suggestion_result(
+ "the X axis movement will go pass the collider",
+ GetPassGoPass::default(),
+ "the X axis movement will go past the collider",
+ );
+ }
+
+ #[test]
+ fn fix_goes_pass() {
+ assert_suggestion_result(
+ "return false if it goes pass the number of questions",
+ GetPassGoPass::default(),
+ "return false if it goes past the number of questions",
+ );
+ }
+
+ #[test]
+ fn fix_going_pass() {
+ assert_suggestion_result(
+ "Why is it not going pass the first batch?",
+ GetPassGoPass::default(),
+ "Why is it not going past the first batch?",
+ )
+ }
+
+ #[test]
+ fn fix_gone_pass() {
+ assert_suggestion_result(
+ "Make sure we haven't gone pass the node count limit.",
+ GetPassGoPass::default(),
+ "Make sure we haven't gone past the node count limit.",
+ )
+ }
+
+ #[test]
+ fn fix_got_pass() {
+ assert_suggestion_result(
+ "Ok I got pass the first issue.",
+ GetPassGoPass::default(),
+ "Ok I got past the first issue.",
+ );
+ }
+
+ #[test]
+ fn fix_gotten_pass() {
+ assert_suggestion_result(
+ "I have now gotten pass the show stoppers.",
+ GetPassGoPass::default(),
+ "I have now gotten past the show stoppers.",
+ )
+ }
+}
diff --git a/harper-core/src/linting/lint_group/mod.rs b/harper-core/src/linting/lint_group/mod.rs
index 8e0a4ed2f..645596565 100644
--- a/harper-core/src/linting/lint_group/mod.rs
+++ b/harper-core/src/linting/lint_group/mod.rs
@@ -106,6 +106,7 @@ use super::for_the_nth_time::ForTheNthTime;
use super::free_predicate::FreePredicate;
use super::friend_of_me::FriendOfMe;
use super::full_to_the_brim::FullToTheBrim;
+use super::get_pass_go_pass::GetPassGoPass;
use super::go_so_far_as_to::GoSoFarAsTo;
use super::go_to_war::GoToWar;
use super::good_at::GoodAt;
@@ -701,6 +702,7 @@ impl LintGroup {
insert_expr_rule!(FreePredicate);
insert_expr_rule!(FriendOfMe);
insert_expr_rule!(FullToTheBrim);
+ insert_expr_rule!(GetPassGoPass);
insert_expr_rule!(GoSoFarAsTo);
insert_expr_rule!(GoToWar);
insert_expr_rule!(GoodAt);
diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rs
index 65f184fe4..ad7e7e00b 100644
--- a/harper-core/src/linting/mod.rs
+++ b/harper-core/src/linting/mod.rs
@@ -107,6 +107,7 @@ mod for_the_nth_time;
mod free_predicate;
mod friend_of_me;
mod full_to_the_brim;
+mod get_pass_go_pass;
mod go_so_far_as_to;
mod go_to_war;
mod good_at;