Skip to content

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

feat: implement #525 (worse/worst confusion)

hippietrail28c174090cac
diff --git a/harper-core/src/linting/phrase_corrections.rs b/harper-core/src/linting/phrase_corrections.rs
index a7c6c4742..334b5879c 100644
--- a/harper-core/src/linting/phrase_corrections.rs
+++ b/harper-core/src/linting/phrase_corrections.rs
@@ -615,6 +615,42 @@ pub fn lint_group() -> LintGroup {
"Use `nerve-racking` for something that causes anxiety or tension.",
"Corrects common misspellings and missing hyphen in `nerve-racking`."
),
+ "ALotWorst" => (
+ ["a lot worst", "alot worst"],
+ ["a lot worse"],
+ "Use `worse` for comparing. (`Worst` is for the extreme case)",
+ "Corrects `a lot worst` to `a lot worse` for proper comparative usage."
+ ),
+ "FarWorse" => (
+ ["far worst"],
+ ["far worse"],
+ "Use `worse` for comparing. (`Worst` is for the extreme case)",
+ "Corrects `far worst` to `far worse` for proper comparative usage."
+ ),
+ "MuchWorse" => (
+ ["much worst"],
+ ["much worse"],
+ "Use `worse` for comparing. (`Worst` is for the extreme case)",
+ "Corrects `much worst` to `much worse` for proper comparative usage."
+ ),
+ "WorseAndWorse" => (
+ ["worst and worst", "worse and worst", "worst and worse"],
+ ["worse and worse"],
+ "Use `worse` for comparing. (`Worst` is for the extreme case)",
+ "Corrects `worst and worst` to `worse and worse` for proper comparative usage."
+ ),
+ "WorseThan" => (
+ ["worst than"],
+ ["worse than"],
+ "Use `worse` for comparing. (`Worst` is for the extreme case)",
+ "Corrects `worst than` to `worse than` for proper comparative usage."
+ ),
+ "WorstEver" => (
+ ["worse ever"],
+ ["worst ever"],
+ "Use `worst` for the extreme case. (`Worse` is for comparing)",
+ "Corrects `worse ever` to `worst ever` for proper comparative usage."
+ ),
});
group.set_all_rules_to(Some(true));
@@ -851,4 +887,85 @@ mod tests {
"It's nerve-racking to think about it because I have code inside the callback that resolves the member and somehow I feel like it's so ..",
);
}
+
+ #[test]
+ fn detect_a_lot_worse_atomic() {
+ assert_suggestion_result("a lot worst", lint_group(), "a lot worse");
+ }
+ #[test]
+ fn detect_a_lot_worse_real_world() {
+ assert_suggestion_result(
+ "On a debug build, it's even a lot worst.",
+ lint_group(),
+ "On a debug build, it's even a lot worse.",
+ );
+ }
+ #[test]
+ fn detect_far_worse_atomic() {
+ assert_suggestion_result("far worst", lint_group(), "far worse");
+ }
+ #[test]
+ fn detect_far_worse_real_world() {
+ assert_suggestion_result(
+ "I mainly use Firefox (personal preference) and have noticed it has far worst performance than Chrome",
+ lint_group(),
+ "I mainly use Firefox (personal preference) and have noticed it has far worse performance than Chrome",
+ );
+ }
+ #[test]
+ fn detect_much_worse_atomic() {
+ assert_suggestion_result("much worst", lint_group(), "much worse");
+ }
+ #[test]
+ fn detect_much_worse_real_world() {
+ assert_suggestion_result(
+ "the generated image quality is much worst (actually nearly broken)",
+ lint_group(),
+ "the generated image quality is much worse (actually nearly broken)",
+ );
+ }
+ #[test]
+ fn detect_worst_and_worst_atomic() {
+ assert_suggestion_result("worst and worst", lint_group(), "worse and worse");
+ }
+ #[test]
+ fn detect_worst_and_worst_real_world() {
+ assert_suggestion_result(
+ "This control-L trick does not work for me. The padding is getting worst and worst.",
+ lint_group(),
+ "This control-L trick does not work for me. The padding is getting worse and worse.",
+ );
+ }
+ #[test]
+ fn detect_worse_and_worst_real_world() {
+ assert_suggestion_result(
+ "This progressively got worse and worst to the point that the machine (LEAD 1010) stopped moving alltogether.",
+ lint_group(),
+ "This progressively got worse and worse to the point that the machine (LEAD 1010) stopped moving alltogether.",
+ );
+ }
+ #[test]
+ fn detect_worse_than_atomic() {
+ assert_suggestion_result("worst than", lint_group(), "worse than");
+ }
+ #[test]
+ fn detect_worse_than_real_world() {
+ assert_suggestion_result(
+ "Project real image - inversion quality is worst than in StyleGAN2",
+ lint_group(),
+ "Project real image - inversion quality is worse than in StyleGAN2",
+ );
+ }
+ #[test]
+ fn detect_worst_ever_atomic() {
+ assert_suggestion_result("worse ever", lint_group(), "worst ever");
+ }
+ #[test]
+ fn detect_worst_ever_real_world() {
+ assert_suggestion_result(
+ "The Bcl package family is one of the worse ever published by Microsoft.",
+ lint_group(),
+ "The Bcl package family is one of the worst ever published by Microsoft.",
+ );
+ }
}