Skip to content

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

fix(lint): add 'side' to ignore list for effect/affect rule (fix issue #2958) (#2983)

Estefanía Fdez494def4bc29a
diff --git a/harper-core/src/linting/noun_verb_confusion/effect_affect/effect_to_affect.rs b/harper-core/src/linting/noun_verb_confusion/effect_affect/effect_to_affect.rs
index 9c2b11bfc..a630510ab 100644
--- a/harper-core/src/linting/noun_verb_confusion/effect_affect/effect_to_affect.rs
+++ b/harper-core/src/linting/noun_verb_confusion/effect_affect/effect_to_affect.rs
@@ -58,7 +58,7 @@ impl ExprLinter for EffectToAffect {
if matches!(
lower_prev.as_str(),
- "take" | "takes" | "taking" | "took" | "taken"
+ "take" | "takes" | "taking" | "took" | "taken" | "side"
) {
return None;
}
diff --git a/harper-core/src/linting/noun_verb_confusion/mod.rs b/harper-core/src/linting/noun_verb_confusion/mod.rs
index 95d57b5a8..685488c27 100644
--- a/harper-core/src/linting/noun_verb_confusion/mod.rs
+++ b/harper-core/src/linting/noun_verb_confusion/mod.rs
@@ -1087,6 +1087,15 @@ mod tests {
);
}
+ #[test]
+ fn no_change_side_effect() {
+ assert_lint_count(
+ "I forgot to test the side effect that users are deleted when clearing data.",
+ NounVerbConfusion::default(),
+ 0,
+ );
+ }
+
#[test]
fn corrects_cause_and_affect() {
assert_suggestion_result(
@@ -1398,4 +1407,64 @@ mod tests {
"contributed more than you weigh",
);
}
+
+ // Tests for issue #2958: "side effect" must not be flagged.
+ // Legitimate verb uses like "padding side affects the results" should also pass.
+
+ #[test]
+ fn no_flag_side_effects_from_medication() {
+ assert_lint_count(
+ "There were no side effects from the medication.",
+ NounVerbConfusion::default(),
+ 0,
+ );
+ }
+
+ #[test]
+ fn no_flag_side_effects_in_functions() {
+ assert_lint_count(
+ "Avoid side effects in your functions.",
+ NounVerbConfusion::default(),
+ 0,
+ );
+ }
+
+ #[test]
+ fn no_flag_this_change_has_no_side_effects() {
+ assert_lint_count(
+ "This change has no side effects.",
+ NounVerbConfusion::default(),
+ 0,
+ );
+ }
+
+ #[test]
+ fn no_flag_padding_side_affects_results() {
+ // "side" is the subject, "affects" is the verb — legitimate usage.
+ assert_lint_count(
+ "I am still not clear how padding side affects the results.",
+ NounVerbConfusion::default(),
+ 0,
+ );
+ }
+
+ #[test]
+ fn no_flag_what_side_affects_import_machinery() {
+ // "side" is part of the noun phrase "what side", "affects" is the verb.
+ assert_lint_count(
+ "Move that to the top level so you don't need to worry about what side affects the import machinery.",
+ NounVerbConfusion::default(),
+ 0,
+ );
+ }
+
+ #[test]
+ fn no_flag_script_side_affect_other_side() {
+ // "side" is part of the noun phrase "script side", "affect" is the verb.
+ assert_lint_count(
+ "Would an unfreed reference in the script side affect the other side somehow?",
+ NounVerbConfusion::default(),
+ 0,
+ );
+ }
}