Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
69 changes: 69 additions & 0 deletions harper-core/src/linting/noun_verb_confusion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
);
}
}
Loading