harper_core/linting/noun_verb_confusion/
mod.rs

1use super::merge_linters::merge_linters;
2
3mod effect_affect;
4mod noun_instead_of_verb;
5mod verb_instead_of_noun;
6
7// Common noun-verb pairs that are often confused
8// See also [`NounInsteadOfVerb``]
9pub(crate) const NOUN_VERB_PAIRS: &[(&str, &str)] = &[
10    ("advice", "advise"),
11    ("belief", "believe"),
12    ("breath", "breathe"),
13    ("effect", "affect"), // "Effect" is also a verb meaning "to bring about". "Affect" is a noun in psychology.
14    ("emphasis", "emphasize"), // TODO how to handle "emphasise" as well as "emphasize"?
15    ("intent", "intend"),
16    // ("proof", "prove"),  // "Proof" is also a verb, a synonym of "proofread".
17    // Add more pairs here as needed
18];
19
20use noun_instead_of_verb::NounInsteadOfVerb;
21use verb_instead_of_noun::VerbInsteadOfNoun;
22
23merge_linters! {
24    NounVerbConfusion =>
25        NounInsteadOfVerb,
26        VerbInsteadOfNoun
27        => "Handles common confusions between related nouns and verbs (e.g., 'advice/advise', 'breath/breathe')"
28}
29
30#[cfg(test)]
31mod tests {
32    use super::NounVerbConfusion;
33    use crate::linting::tests::{assert_lint_count, assert_no_lints, assert_suggestion_result};
34
35    #[test]
36    fn corrects_good_advise() {
37        assert_suggestion_result("Good advise", NounVerbConfusion::default(), "Good advice");
38    }
39
40    #[test]
41    fn corrects_bad_advise() {
42        assert_suggestion_result(
43            "I just wanted to bring attention to this because it stood out to me as potentially bad advise.",
44            NounVerbConfusion::default(),
45            "I just wanted to bring attention to this because it stood out to me as potentially bad advice.",
46        );
47    }
48
49    #[test]
50    fn dont_flag_correct_better_advise() {
51        assert_lint_count(
52            "Hello! I am an engineer at Plexon and am conducting tests with Kilosort4 so we can better advise our clients.",
53            NounVerbConfusion::default(),
54            0,
55        );
56    }
57
58    #[test]
59    #[ignore = "'better advise' can be correct as above, or a mistake like here"]
60    fn correct_better_advise() {
61        assert_suggestion_result(
62            "Maybe this will be a decent idea, .or anybody has better advise :)",
63            NounVerbConfusion::default(),
64            "Maybe this will be a decent idea, .or anybody has better advice :)",
65        );
66    }
67
68    #[test]
69    fn dont_flag_correct_better_believe() {
70        assert_lint_count(
71            "You'd better believe this is bbedit-gist-maker.",
72            NounVerbConfusion::default(),
73            0,
74        );
75    }
76
77    #[test]
78    fn correct_strong_believe() {
79        assert_suggestion_result(
80            "cause my strong believe is that we must give any user to describe whether a post is meant factual",
81            NounVerbConfusion::default(),
82            "cause my strong belief is that we must give any user to describe whether a post is meant factual",
83        );
84    }
85
86    #[test]
87    fn correct_deep_breathe() {
88        assert_suggestion_result(
89            "Take deep breathe and Do it again!",
90            NounVerbConfusion::default(),
91            "Take deep breath and Do it again!",
92        );
93    }
94
95    #[test]
96    fn correct_bad_intend() {
97        assert_suggestion_result(
98            "What do you do if you only see slightly longer posts that may still be acceptable (and not bad intend from the poster)",
99            NounVerbConfusion::default(),
100            "What do you do if you only see slightly longer posts that may still be acceptable (and not bad intent from the poster)",
101        );
102    }
103
104    #[test]
105    fn corrects_belief_instead_of_verb() {
106        assert_suggestion_result(
107            "I belief in you.",
108            NounVerbConfusion::default(),
109            "I believe in you.",
110        );
111    }
112
113    #[test]
114    #[ignore = "`to` can't disambiguate since it's valid between verbs and nouns"]
115    fn corrects_breath_instead_of_verb() {
116        assert_suggestion_result(
117            "Remember to breath deeply.",
118            NounVerbConfusion::default(),
119            "Remember to breathe deeply.",
120        );
121    }
122
123    #[test]
124    fn does_not_flag_correct_believe() {
125        assert_lint_count("I believe in you.", NounVerbConfusion::default(), 0);
126    }
127
128    #[test]
129    fn does_not_flag_correct_breath() {
130        assert_lint_count("Take a deep breath.", NounVerbConfusion::default(), 0);
131    }
132
133    // real-world example unit tests
134
135    #[test]
136    fn fix_when_i_breath_you_breath() {
137        assert_suggestion_result(
138            "When I breath, you breath!",
139            NounVerbConfusion::default(),
140            "When I breathe, you breathe!",
141        );
142    }
143
144    #[test]
145    fn fix_weather_climate_and_the_air_we_breath() {
146        assert_suggestion_result(
147            "Weather Climate and the Air We Breath",
148            NounVerbConfusion::default(),
149            "Weather Climate and the Air We Breathe",
150        );
151    }
152
153    #[test]
154    fn fix_always_breath() {
155        assert_suggestion_result(
156            "breathing. remember to always breath.",
157            NounVerbConfusion::default(),
158            "breathing. remember to always breathe.",
159        );
160    }
161
162    #[test]
163    fn fix_never_breath_a_word() {
164        assert_suggestion_result(
165            "And never breath a word about your loss; If you can force your heart and nerve and sinew.",
166            NounVerbConfusion::default(),
167            "And never breathe a word about your loss; If you can force your heart and nerve and sinew.",
168        );
169    }
170
171    #[test]
172    fn fix_breath_for_seconds() {
173        assert_suggestion_result(
174            "Once turned on, the LED on the TX unit would breath for a few seconds, then go completely dead and not responding to objects in front of the sensors.",
175            NounVerbConfusion::default(),
176            "Once turned on, the LED on the TX unit would breathe for a few seconds, then go completely dead and not responding to objects in front of the sensors.",
177        );
178    }
179
180    #[test]
181    fn fix_breath_a_little_more_life() {
182        assert_suggestion_result(
183            "... up to 12% more performance, could breath a little more life into systems as old as Sandy Bridge.",
184            NounVerbConfusion::default(),
185            "... up to 12% more performance, could breathe a little more life into systems as old as Sandy Bridge.",
186        );
187    }
188
189    #[test]
190    fn fix_the_diversity_we_breath() {
191        assert_suggestion_result(
192            "The Diversity We Breath: Community Diversity",
193            NounVerbConfusion::default(),
194            "The Diversity We Breathe: Community Diversity",
195        );
196    }
197
198    #[test]
199    fn fix_belief() {
200        assert_suggestion_result(
201            "While I have no plans to return to aerospace I belief it gives me a unique perspective to many challenges.",
202            NounVerbConfusion::default(),
203            "While I have no plans to return to aerospace I believe it gives me a unique perspective to many challenges.",
204        );
205    }
206
207    #[test]
208    fn fix_we_belief() {
209        assert_suggestion_result(
210            "In contrast to other vendors in e-mobility, we belief that true transparency is only trustworthy if the entire process ...",
211            NounVerbConfusion::default(),
212            "In contrast to other vendors in e-mobility, we believe that true transparency is only trustworthy if the entire process ...",
213        );
214    }
215
216    #[test]
217    #[ignore = "`underwater` is a marginal noun so `breath underwater` matches the compound noun test."]
218    fn fix_i_can_breath() {
219        assert_suggestion_result(
220            "Steps to reproduce Expected behaviour I can breath underwater.",
221            NounVerbConfusion::default(),
222            "Steps to reproduce Expected behaviour I can breathe underwater.",
223        );
224    }
225
226    #[test]
227    fn fix_caps_should_breath() {
228        assert_suggestion_result(
229            "CAPS 1 2 3 4 5 A B C D SHOULD BREATH A BIT MORE ?",
230            NounVerbConfusion::default(),
231            "CAPS 1 2 3 4 5 A B C D SHOULD BREATHE A BIT MORE ?",
232        );
233    }
234
235    #[test]
236    fn fix_can_you_advice_me() {
237        assert_suggestion_result(
238            "Can you advice me how to train?",
239            NounVerbConfusion::default(),
240            "Can you advise me how to train?",
241        );
242    }
243
244    #[test]
245    fn fix_we_can_advice_you() {
246        assert_suggestion_result(
247            "Feel free to share more details about your use case, so we can advice you specifically based on your case.",
248            NounVerbConfusion::default(),
249            "Feel free to share more details about your use case, so we can advise you specifically based on your case.",
250        );
251    }
252
253    #[test]
254    fn fix_would_advice_against() {
255        assert_suggestion_result(
256            "So that I would advice against using a spindle in laser mode.",
257            NounVerbConfusion::default(),
258            "So that I would advise against using a spindle in laser mode.",
259        );
260    }
261
262    #[test]
263    fn fix_advice_to_listen() {
264        assert_suggestion_result(
265            "The idea of this applicaton was inspired by Ray Dalio, who always advice to listen to people who know more than us by experience.",
266            NounVerbConfusion::default(),
267            "The idea of this applicaton was inspired by Ray Dalio, who always advise to listen to people who know more than us by experience.",
268        );
269    }
270
271    #[test]
272    #[ignore = "`You` is an object pronoun in this example. `It` is also both subject and object."]
273    fn dont_fix_advice_on_that() {
274        assert_lint_count(
275            "I don't do table returning functions in my code so can't offer you advice on that.",
276            NounVerbConfusion::default(),
277            0,
278        );
279    }
280
281    #[test]
282    fn fix_advice_to_stick_with_openvscode() {
283        assert_suggestion_result(
284            "But unless you really need it, I would advice to stick with openvscode as there are nearly the same.",
285            NounVerbConfusion::default(),
286            "But unless you really need it, I would advise to stick with openvscode as there are nearly the same.",
287        );
288    }
289
290    #[test]
291    fn fix_advice_to_back_up_os_image() {
292        assert_suggestion_result(
293            "I would advice to back up all OS image before any update, because you could lose something what was working previously.",
294            NounVerbConfusion::default(),
295            "I would advise to back up all OS image before any update, because you could lose something what was working previously.",
296        );
297    }
298
299    #[test]
300    fn fix_advice_to_use_ms_store() {
301        assert_suggestion_result(
302            "I know we can always advice to use the MS store to download JASP instead",
303            NounVerbConfusion::default(),
304            "I know we can always advise to use the MS store to download JASP instead",
305        );
306    }
307
308    #[test]
309    fn fix_should_intent_be() {
310        assert_suggestion_result(
311            "Should intent be on the blocklist?",
312            NounVerbConfusion::default(),
313            "Should intent be on the blocklist?",
314        );
315    }
316
317    #[test]
318    fn fix_if_you_intent() {
319        assert_suggestion_result(
320            "If you intent to use a 64 bits machine, change line 74",
321            NounVerbConfusion::default(),
322            "If you intend to use a 64 bits machine, change line 74",
323        );
324    }
325
326    #[test]
327    fn fix_what_you_would_intent_to_do() {
328        assert_suggestion_result(
329            "May I ask what you would intent to do with such a feature?",
330            NounVerbConfusion::default(),
331            "May I ask what you would intend to do with such a feature?",
332        );
333    }
334
335    #[test]
336    fn dont_flag_intent_records() {
337        assert_lint_count(
338            "there are always intent records associated to the txns",
339            NounVerbConfusion::default(),
340            0,
341        );
342    }
343
344    #[test]
345    fn fix_did_you_always_intent_to() {
346        assert_suggestion_result(
347            "Did you always intent to fight malware? No.",
348            NounVerbConfusion::default(),
349            "Did you always intend to fight malware? No.",
350        );
351    }
352
353    #[test]
354    fn fix_we_recommend_you_create_a_new_issue_on_github_explaining_what_you_intent_to_do() {
355        assert_suggestion_result(
356            "... we recommend you create a new issue on github explaining what you intent to do.",
357            NounVerbConfusion::default(),
358            "... we recommend you create a new issue on github explaining what you intend to do.",
359        );
360    }
361
362    #[test]
363    fn fix_intent_to_use_non_imported_symbol() {
364        assert_suggestion_result(
365            "There's a warning reported for this code, saying that it may intent to use non-imported symbol",
366            NounVerbConfusion::default(),
367            "There's a warning reported for this code, saying that it may intend to use non-imported symbol",
368        );
369    }
370
371    // tests for preceding "to"
372
373    #[test]
374    fn fix_to_emphasis_the() {
375        assert_suggestion_result(
376            "This one could be used in a dialog to emphasis the surprise.",
377            NounVerbConfusion::default(),
378            "This one could be used in a dialog to emphasize the surprise.",
379        );
380    }
381
382    #[test]
383    fn allow_to_emphasis_at_end() {
384        assert_lint_count(
385            "Changes literal underscores to emphasis",
386            NounVerbConfusion::default(),
387            0,
388        );
389    }
390
391    #[test]
392    fn allow_to_intent_adjective() {
393        assert_lint_count(
394            "Cleanup passing statistics to intent aware iterator",
395            NounVerbConfusion::default(),
396            0,
397        );
398    }
399
400    #[test]
401    fn fix_to_advice_a_class() {
402        assert_suggestion_result(
403            "How to advice a class that have been intercepted by another javaagent",
404            NounVerbConfusion::default(),
405            "How to advise a class that have been intercepted by another javaagent",
406        );
407    }
408
409    #[test]
410    fn fix_to_breath_some() {
411        assert_suggestion_result(
412            "You go to the balcony to breath some fresh air and look down at the things outside.",
413            NounVerbConfusion::default(),
414            "You go to the balcony to breathe some fresh air and look down at the things outside.",
415        );
416    }
417
418    #[test]
419    fn fix_to_emphasis_a() {
420        assert_suggestion_result(
421            "we'd like to emphasis a few points below",
422            NounVerbConfusion::default(),
423            "we'd like to emphasize a few points below",
424        );
425    }
426
427    #[test]
428    fn fix_to_advice_their() {
429        assert_suggestion_result(
430            "People who are managing this situation tend to advice their users to lock+unlock their screen",
431            NounVerbConfusion::default(),
432            "People who are managing this situation tend to advise their users to lock+unlock their screen",
433        );
434    }
435
436    // affect vs. effect sentences gathered from user reports
437
438    #[test]
439    fn fix_positive_affect_on_small_businesses() {
440        assert_suggestion_result(
441            "The new law had a positive affect on small businesses.",
442            NounVerbConfusion::default(),
443            "The new law had a positive effect on small businesses.",
444        );
445    }
446
447    #[test]
448    fn fix_measured_the_affect_of_caffeine() {
449        assert_suggestion_result(
450            "We measured the affect of caffeine on reaction time.",
451            NounVerbConfusion::default(),
452            "We measured the effect of caffeine on reaction time.",
453        );
454    }
455
456    #[test]
457    fn fix_side_affects_included_nausea() {
458        assert_suggestion_result(
459            "The side affects included nausea and fatigue.",
460            NounVerbConfusion::default(),
461            "The side effects included nausea and fatigue.",
462        );
463    }
464
465    #[test]
466    fn fix_cause_and_affect_not_same() {
467        assert_suggestion_result(
468            "Cause and affect are not the same thing.",
469            NounVerbConfusion::default(),
470            "Cause and effect are not the same thing.",
471        );
472    }
473
474    #[test]
475    fn fix_change_will_have_an_affect_on_revenue() {
476        assert_suggestion_result(
477            "The change will have an affect on our revenue.",
478            NounVerbConfusion::default(),
479            "The change will have an effect on our revenue.",
480        );
481    }
482
483    #[test]
484    fn fix_medicine_took_affect_within_minutes() {
485        assert_suggestion_result(
486            "The medicine took affect within minutes.",
487            NounVerbConfusion::default(),
488            "The medicine took effect within minutes.",
489        );
490    }
491
492    #[test]
493    fn fix_policy_will_come_into_affect() {
494        assert_suggestion_result(
495            "The policy will come into affect on October 1.",
496            NounVerbConfusion::default(),
497            "The policy will come into effect on October 1.",
498        );
499    }
500
501    #[test]
502    fn fix_rules_are_now_in_affect() {
503        assert_suggestion_result(
504            "The rules are now in affect.",
505            NounVerbConfusion::default(),
506            "The rules are now in effect.",
507        );
508    }
509
510    #[test]
511    fn fix_with_immediate_affect_office_closed() {
512        assert_suggestion_result(
513            "With immediate affect, the office is closed.",
514            NounVerbConfusion::default(),
515            "With immediate effect, the office is closed.",
516        );
517    }
518
519    #[test]
520    fn fix_stunning_special_affects() {
521        assert_suggestion_result(
522            "The director used stunning special affects.",
523            NounVerbConfusion::default(),
524            "The director used stunning special effects.",
525        );
526    }
527
528    #[test]
529    fn fix_placebo_affect_can_be_powerful() {
530        assert_suggestion_result(
531            "The placebo affect can be powerful.",
532            NounVerbConfusion::default(),
533            "The placebo effect can be powerful.",
534        );
535    }
536
537    #[test]
538    fn fix_ripple_affect_across_market() {
539        assert_suggestion_result(
540            "We felt the ripple affect across the entire market.",
541            NounVerbConfusion::default(),
542            "We felt the ripple effect across the entire market.",
543        );
544    }
545
546    #[test]
547    fn fix_snowball_affect_amplified_problem() {
548        assert_suggestion_result(
549            "The snowball affect amplified the problem.",
550            NounVerbConfusion::default(),
551            "The snowball effect amplified the problem.",
552        );
553    }
554
555    #[test]
556    fn fix_knock_on_affect_throughout_team() {
557        assert_suggestion_result(
558            "That decision had a knock-on affect throughout the team.",
559            NounVerbConfusion::default(),
560            "That decision had a knock-on effect throughout the team.",
561        );
562    }
563
564    #[test]
565    fn fix_greenhouse_affect_warms_planet() {
566        assert_suggestion_result(
567            "The greenhouse affect warms the planet.",
568            NounVerbConfusion::default(),
569            "The greenhouse effect warms the planet.",
570        );
571    }
572
573    #[test]
574    fn fix_apology_had_little_affect() {
575        assert_suggestion_result(
576            "Her apology had little affect.",
577            NounVerbConfusion::default(),
578            "Her apology had little effect.",
579        );
580    }
581
582    #[test]
583    fn fix_settings_go_into_affect() {
584        assert_suggestion_result(
585            "The new settings go into affect after a restart.",
586            NounVerbConfusion::default(),
587            "The new settings go into effect after a restart.",
588        );
589    }
590
591    #[test]
592    fn fix_put_plan_into_affect() {
593        assert_suggestion_result(
594            "They put the new plan into affect last week.",
595            NounVerbConfusion::default(),
596            "They put the new plan into effect last week.",
597        );
598    }
599
600    #[test]
601    fn fix_contract_comes_into_affect() {
602        assert_suggestion_result(
603            "The contract comes into affect at midnight.",
604            NounVerbConfusion::default(),
605            "The contract comes into effect at midnight.",
606        );
607    }
608
609    #[test]
610    fn fix_warning_had_no_affect_on_behavior() {
611        assert_suggestion_result(
612            "The warning had no affect on his behavior.",
613            NounVerbConfusion::default(),
614            "The warning had no effect on his behavior.",
615        );
616    }
617
618    #[test]
619    fn fix_inflation_had_opposite_affect() {
620        assert_suggestion_result(
621            "Inflation had the opposite affect than expected.",
622            NounVerbConfusion::default(),
623            "Inflation had the opposite effect than expected.",
624        );
625    }
626
627    #[test]
628    fn fix_regulation_remains_in_affect() {
629        assert_suggestion_result(
630            "The regulation remains in affect until further notice.",
631            NounVerbConfusion::default(),
632            "The regulation remains in effect until further notice.",
633        );
634    }
635
636    #[test]
637    fn fix_app_changes_take_affect() {
638        assert_suggestion_result(
639            "The app changes take affect next week.",
640            NounVerbConfusion::default(),
641            "The app changes take effect next week.",
642        );
643    }
644
645    #[test]
646    fn fix_sound_affects_were_added() {
647        assert_suggestion_result(
648            "Sound affects were added in post.",
649            NounVerbConfusion::default(),
650            "Sound effects were added in post.",
651        );
652    }
653
654    // Effect/affect-specific checks
655    // `effect` mistakenly used as the verb `affect`.
656    #[test]
657    fn corrects_noun_subject_effects_object() {
658        assert_suggestion_result(
659            "System outages effect our customers.",
660            NounVerbConfusion::default(),
661            "System outages affect our customers.",
662        );
663    }
664
665    #[test]
666    fn corrects_effects_variant() {
667        assert_suggestion_result(
668            "This policy effects employee morale.",
669            NounVerbConfusion::default(),
670            "This policy affects employee morale.",
671        );
672    }
673
674    #[test]
675    fn ignores_effect_change_idiom() {
676        assert_lint_count(
677            "Leaders work to effect change in their communities.",
678            NounVerbConfusion::default(),
679            0,
680        );
681    }
682
683    #[test]
684    fn ignores_effect_noun_phrase() {
685        assert_lint_count(
686            "The effect your plan had was dramatic.",
687            NounVerbConfusion::default(),
688            0,
689        );
690    }
691
692    #[test]
693    fn ignores_effect_as_result_noun() {
694        assert_lint_count(
695            "The effect was immediate and obvious.",
696            NounVerbConfusion::default(),
697            0,
698        );
699    }
700
701    #[test]
702    fn ignores_to_effect_substitutions() {
703        assert_lint_count(
704            "or it may be desired to effect substitutions",
705            NounVerbConfusion::default(),
706            0,
707        );
708    }
709
710    #[test]
711    fn ignores_effect_followed_by_of_phrase() {
712        assert_lint_count(
713            "We measured the effect of caffeine on sleep.",
714            NounVerbConfusion::default(),
715            0,
716        );
717    }
718
719    #[test]
720    fn ignores_side_effects_usage() {
721        assert_lint_count(
722            "Side effects may include mild nausea.",
723            NounVerbConfusion::default(),
724            0,
725        );
726    }
727
728    #[test]
729    fn ignores_special_effects_phrase() {
730        assert_lint_count(
731            "She admired the special effects in the film.",
732            NounVerbConfusion::default(),
733            0,
734        );
735    }
736
737    #[test]
738    fn ignores_effect_in_cause_and_effect() {
739        assert_lint_count(
740            "The diagram explains cause and effect relationships.",
741            NounVerbConfusion::default(),
742            0,
743        );
744    }
745
746    #[test]
747    fn ignores_effects_with_pronoun_subject() {
748        assert_lint_count(
749            "Those effects were less severe than expected.",
750            NounVerbConfusion::default(),
751            0,
752        );
753    }
754
755    #[test]
756    fn corrects_tariff_effect_import_prices() {
757        assert_suggestion_result(
758            "The new tariff will effect import prices next quarter.",
759            NounVerbConfusion::default(),
760            "The new tariff will affect import prices next quarter.",
761        );
762    }
763
764    #[test]
765    fn corrects_droughts_effect_crop_yields() {
766        assert_suggestion_result(
767            "Prolonged droughts severely effect crop yields across the valley.",
768            NounVerbConfusion::default(),
769            "Prolonged droughts severely affect crop yields across the valley.",
770        );
771    }
772
773    #[test]
774    fn corrects_caffeine_effect_sleep() {
775        assert_suggestion_result(
776            "Caffeine can effect your sleep architecture.",
777            NounVerbConfusion::default(),
778            "Caffeine can affect your sleep architecture.",
779        );
780    }
781
782    #[test]
783    fn corrects_bug_effect_devices() {
784        assert_suggestion_result(
785            "The firmware bug doesn't effect older devices.",
786            NounVerbConfusion::default(),
787            "The firmware bug doesn't affect older devices.",
788        );
789    }
790
791    #[test]
792    fn corrects_sarcasm_effect_morale() {
793        assert_suggestion_result(
794            "Her sarcasm seemed to effect the team's morale.",
795            NounVerbConfusion::default(),
796            "Her sarcasm seemed to affect the team's morale.",
797        );
798    }
799
800    #[test]
801    fn corrects_outage_effect_timeline() {
802        assert_suggestion_result(
803            "How will this outage effect our deployment timeline?",
804            NounVerbConfusion::default(),
805            "How will this outage affect our deployment timeline?",
806        );
807    }
808
809    #[test]
810    fn corrects_temperatures_effect_battery() {
811        assert_suggestion_result(
812            "Cold temperatures drastically effect lithium-ion battery performance.",
813            NounVerbConfusion::default(),
814            "Cold temperatures drastically affect lithium-ion battery performance.",
815        );
816    }
817
818    #[test]
819    fn corrects_policy_effect_eligibility() {
820        assert_suggestion_result(
821            "The policy change could effect your eligibility for benefits.",
822            NounVerbConfusion::default(),
823            "The policy change could affect your eligibility for benefits.",
824        );
825    }
826
827    #[test]
828    fn corrects_variables_effect_results() {
829        assert_suggestion_result(
830            "These confounding variables may effect the study's results.",
831            NounVerbConfusion::default(),
832            "These confounding variables may affect the study's results.",
833        );
834    }
835
836    #[test]
837    fn corrects_fans_effect_concentration() {
838        assert_suggestion_result(
839            "The noisy HVAC fans constantly effect concentration in the lab.",
840            NounVerbConfusion::default(),
841            "The noisy HVAC fans constantly affect concentration in the lab.",
842        );
843    }
844
845    #[test]
846    fn corrects_hormones_effect_immunity() {
847        assert_suggestion_result(
848            "Stress hormones can effect immune response during recovery.",
849            NounVerbConfusion::default(),
850            "Stress hormones can affect immune response during recovery.",
851        );
852    }
853
854    #[test]
855    fn corrects_pacing_effect_engagement() {
856        assert_suggestion_result(
857            "The instructor's pacing tended to effect student engagement.",
858            NounVerbConfusion::default(),
859            "The instructor's pacing tended to affect student engagement.",
860        );
861    }
862
863    #[test]
864    fn corrects_humidity_effect_paint() {
865        assert_suggestion_result(
866            "Humidity levels directly effect paint curing time.",
867            NounVerbConfusion::default(),
868            "Humidity levels directly affect paint curing time.",
869        );
870    }
871
872    #[test]
873    fn corrects_exchange_effect_invoice() {
874        assert_suggestion_result(
875            "The exchange rate will surely effect the final invoice.",
876            NounVerbConfusion::default(),
877            "The exchange rate will surely affect the final invoice.",
878        );
879    }
880
881    #[test]
882    fn corrects_brightness_effect_contrast() {
883        assert_suggestion_result(
884            "Screen brightness settings can effect perceived contrast.",
885            NounVerbConfusion::default(),
886            "Screen brightness settings can affect perceived contrast.",
887        );
888    }
889
890    #[test]
891    fn corrects_medication_effect_him() {
892        assert_suggestion_result(
893            "The medication didn't effect him the way the doctor expected.",
894            NounVerbConfusion::default(),
895            "The medication didn't affect him the way the doctor expected.",
896        );
897    }
898
899    #[test]
900    fn corrects_payments_effect_credit() {
901        assert_suggestion_result(
902            "Late payments will negatively effect your credit score.",
903            NounVerbConfusion::default(),
904            "Late payments will negatively affect your credit score.",
905        );
906    }
907
908    #[test]
909    fn corrects_wording_effect_interpretation() {
910        assert_suggestion_result(
911            "Minor wording tweaks shouldn't effect the legal interpretation.",
912            NounVerbConfusion::default(),
913            "Minor wording tweaks shouldn't affect the legal interpretation.",
914        );
915    }
916
917    #[test]
918    fn corrects_traffic_effect_delivery() {
919        assert_suggestion_result(
920            "Traffic patterns often effect delivery windows downtown.",
921            NounVerbConfusion::default(),
922            "Traffic patterns often affect delivery windows downtown.",
923        );
924    }
925
926    #[test]
927    fn corrects_rumor_effect_confidence() {
928        assert_suggestion_result(
929            "The rumor started to effect investor confidence by noon.",
930            NounVerbConfusion::default(),
931            "The rumor started to affect investor confidence by noon.",
932        );
933    }
934
935    #[test]
936    fn corrects_allergies_effect_productivity() {
937        assert_suggestion_result(
938            "Seasonal allergies badly effect her productivity each April.",
939            NounVerbConfusion::default(),
940            "Seasonal allergies badly affect her productivity each April.",
941        );
942    }
943
944    #[test]
945    fn corrects_feedback_effect_roadmap() {
946        assert_suggestion_result(
947            "Your feedback won't immediately effect the roadmap.",
948            NounVerbConfusion::default(),
949            "Your feedback won't immediately affect the roadmap.",
950        );
951    }
952
953    #[test]
954    fn corrects_rules_effect_honeypot() {
955        assert_suggestion_result(
956            "I cant seem to get my additional rules to effect the honeypot",
957            NounVerbConfusion::default(),
958            "I cant seem to get my additional rules to affect the honeypot",
959        );
960    }
961
962    #[test]
963    fn corrects_bandwidth_effect_video() {
964        assert_suggestion_result(
965            "Fluctuating bandwidth can effect video call quality.",
966            NounVerbConfusion::default(),
967            "Fluctuating bandwidth can affect video call quality.",
968        );
969    }
970
971    #[test]
972    fn corrects_gradient_effect_sensor() {
973        assert_suggestion_result(
974            "The temperature gradient might effect the sensor's calibration.",
975            NounVerbConfusion::default(),
976            "The temperature gradient might affect the sensor's calibration.",
977        );
978    }
979
980    #[test]
981    fn corrects_delays_effect_satisfaction() {
982        assert_suggestion_result(
983            "Even tiny delays can effect user satisfaction metrics.",
984            NounVerbConfusion::default(),
985            "Even tiny delays can affect user satisfaction metrics.",
986        );
987    }
988
989    #[test]
990    fn corrects_architecture_effect_gps() {
991        assert_suggestion_result(
992            "The surrounding architecture can effect GPS accuracy.",
993            NounVerbConfusion::default(),
994            "The surrounding architecture can affect GPS accuracy.",
995        );
996    }
997
998    #[test]
999    fn corrects_lighting_effect_color() {
1000        assert_suggestion_result(
1001            "Lighting conditions strongly effect color perception.",
1002            NounVerbConfusion::default(),
1003            "Lighting conditions strongly affect color perception.",
1004        );
1005    }
1006
1007    #[test]
1008    fn corrects_coach_effect_roles() {
1009        assert_suggestion_result(
1010            "The new coach's strategy will effect players' roles.",
1011            NounVerbConfusion::default(),
1012            "The new coach's strategy will affect players' roles.",
1013        );
1014    }
1015
1016    #[test]
1017    fn corrects_overtraining_effect_reaction() {
1018        assert_suggestion_result(
1019            "Overtraining can effect reaction time and coordination.",
1020            NounVerbConfusion::default(),
1021            "Overtraining can affect reaction time and coordination.",
1022        );
1023    }
1024
1025    #[test]
1026    fn corrects_label_effect_behavior() {
1027        assert_suggestion_result(
1028            "The warning label may effect how consumers use the product.",
1029            NounVerbConfusion::default(),
1030            "The warning label may affect how consumers use the product.",
1031        );
1032    }
1033
1034    // `affect` mistakenly used as the noun `effect`.
1035    #[test]
1036    fn corrects_because_affect_is() {
1037        assert_suggestion_result(
1038            "I worry because affect is hidden.",
1039            NounVerbConfusion::default(),
1040            "I worry because effect is hidden.",
1041        );
1042    }
1043
1044    #[test]
1045    fn ignores_psychology_usage() {
1046        assert_lint_count(
1047            "The patient's affect is flat.",
1048            NounVerbConfusion::default(),
1049            0,
1050        );
1051    }
1052
1053    #[test]
1054    fn corrects_positive_affect_on() {
1055        assert_suggestion_result(
1056            "The new law had a positive affect on small businesses.",
1057            NounVerbConfusion::default(),
1058            "The new law had a positive effect on small businesses.",
1059        );
1060    }
1061
1062    #[test]
1063    fn corrects_great_affect() {
1064        assert_suggestion_result(
1065            "badges that they provide to users to allow them to promote their projects to great affect",
1066            NounVerbConfusion::default(),
1067            "badges that they provide to users to allow them to promote their projects to great effect",
1068        );
1069    }
1070
1071    #[test]
1072    fn corrects_affect_of() {
1073        assert_suggestion_result(
1074            "We measured the affect of caffeine on reaction time.",
1075            NounVerbConfusion::default(),
1076            "We measured the effect of caffeine on reaction time.",
1077        );
1078    }
1079
1080    #[test]
1081    fn corrects_side_affects() {
1082        assert_suggestion_result(
1083            "The side affects included nausea and fatigue.",
1084            NounVerbConfusion::default(),
1085            "The side effects included nausea and fatigue.",
1086        );
1087    }
1088
1089    #[test]
1090    fn corrects_cause_and_affect() {
1091        assert_suggestion_result(
1092            "Cause and affect are not the same thing.",
1093            NounVerbConfusion::default(),
1094            "Cause and effect are not the same thing.",
1095        );
1096    }
1097
1098    #[test]
1099    fn corrects_have_an_affect_on() {
1100        assert_suggestion_result(
1101            "The change will have an affect on our revenue.",
1102            NounVerbConfusion::default(),
1103            "The change will have an effect on our revenue.",
1104        );
1105    }
1106
1107    #[test]
1108    fn corrects_took_affect() {
1109        assert_suggestion_result(
1110            "The medicine took affect within minutes.",
1111            NounVerbConfusion::default(),
1112            "The medicine took effect within minutes.",
1113        );
1114    }
1115
1116    #[test]
1117    fn corrects_come_into_affect() {
1118        assert_suggestion_result(
1119            "The policy will come into affect on October 1.",
1120            NounVerbConfusion::default(),
1121            "The policy will come into effect on October 1.",
1122        );
1123    }
1124
1125    #[test]
1126    fn corrects_in_affect_sentence() {
1127        assert_suggestion_result(
1128            "The rules are now in affect.",
1129            NounVerbConfusion::default(),
1130            "The rules are now in effect.",
1131        );
1132    }
1133
1134    #[test]
1135    fn corrects_with_immediate_affect() {
1136        assert_suggestion_result(
1137            "With immediate affect, the office is closed.",
1138            NounVerbConfusion::default(),
1139            "With immediate effect, the office is closed.",
1140        );
1141    }
1142
1143    #[test]
1144    fn corrects_special_affects() {
1145        assert_suggestion_result(
1146            "The director used stunning special affects.",
1147            NounVerbConfusion::default(),
1148            "The director used stunning special effects.",
1149        );
1150    }
1151
1152    #[test]
1153    fn corrects_placebo_affect() {
1154        assert_suggestion_result(
1155            "The placebo affect can be powerful.",
1156            NounVerbConfusion::default(),
1157            "The placebo effect can be powerful.",
1158        );
1159    }
1160
1161    #[test]
1162    fn corrects_ripple_affect() {
1163        assert_suggestion_result(
1164            "We felt the ripple affect across the entire market.",
1165            NounVerbConfusion::default(),
1166            "We felt the ripple effect across the entire market.",
1167        );
1168    }
1169
1170    #[test]
1171    fn corrects_snowball_affect() {
1172        assert_suggestion_result(
1173            "The snowball affect amplified the problem.",
1174            NounVerbConfusion::default(),
1175            "The snowball effect amplified the problem.",
1176        );
1177    }
1178
1179    #[test]
1180    fn corrects_knock_on_affect() {
1181        assert_suggestion_result(
1182            "That decision had a knock-on affect throughout the team.",
1183            NounVerbConfusion::default(),
1184            "That decision had a knock-on effect throughout the team.",
1185        );
1186    }
1187
1188    #[test]
1189    fn corrects_greenhouse_affect() {
1190        assert_suggestion_result(
1191            "The greenhouse affect warms the planet.",
1192            NounVerbConfusion::default(),
1193            "The greenhouse effect warms the planet.",
1194        );
1195    }
1196
1197    #[test]
1198    fn corrects_little_affect() {
1199        assert_suggestion_result(
1200            "Her apology had little affect.",
1201            NounVerbConfusion::default(),
1202            "Her apology had little effect.",
1203        );
1204    }
1205
1206    #[test]
1207    fn corrects_go_into_affect() {
1208        assert_suggestion_result(
1209            "The new settings go into affect after a restart.",
1210            NounVerbConfusion::default(),
1211            "The new settings go into effect after a restart.",
1212        );
1213    }
1214
1215    #[test]
1216    fn corrects_put_plan_into_affect() {
1217        assert_suggestion_result(
1218            "They put the new plan into affect last week.",
1219            NounVerbConfusion::default(),
1220            "They put the new plan into effect last week.",
1221        );
1222    }
1223
1224    #[test]
1225    fn corrects_contract_into_affect() {
1226        assert_suggestion_result(
1227            "The contract comes into affect at midnight.",
1228            NounVerbConfusion::default(),
1229            "The contract comes into effect at midnight.",
1230        );
1231    }
1232
1233    #[test]
1234    fn corrects_no_affect_on_behavior() {
1235        assert_suggestion_result(
1236            "The warning had no affect on his behavior.",
1237            NounVerbConfusion::default(),
1238            "The warning had no effect on his behavior.",
1239        );
1240    }
1241
1242    #[test]
1243    fn corrects_opposite_affect() {
1244        assert_suggestion_result(
1245            "Inflation had the opposite affect than expected.",
1246            NounVerbConfusion::default(),
1247            "Inflation had the opposite effect than expected.",
1248        );
1249    }
1250
1251    #[test]
1252    fn corrects_remains_in_affect() {
1253        assert_suggestion_result(
1254            "The regulation remains in affect until further notice.",
1255            NounVerbConfusion::default(),
1256            "The regulation remains in effect until further notice.",
1257        );
1258    }
1259
1260    #[test]
1261    fn corrects_take_affect_next_week() {
1262        assert_suggestion_result(
1263            "The app changes take affect next week.",
1264            NounVerbConfusion::default(),
1265            "The app changes take effect next week.",
1266        );
1267    }
1268
1269    #[test]
1270    fn corrects_sound_affects() {
1271        assert_suggestion_result(
1272            "Sound affects were added in post.",
1273            NounVerbConfusion::default(),
1274            "Sound effects were added in post.",
1275        );
1276    }
1277
1278    #[test]
1279    fn does_not_flag_best_affect() {
1280        assert_lint_count(
1281            "Using linear regression to predict and understand what factors best affect house price",
1282            NounVerbConfusion::default(),
1283            0,
1284        );
1285    }
1286
1287    #[test]
1288    fn does_not_flag_sound_affect() {
1289        assert_lint_count(
1290            "The goal of this study was to learn what properties of sound affect human focus the most.",
1291            NounVerbConfusion::default(),
1292            0,
1293        );
1294    }
1295
1296    #[test]
1297    fn corrects_sound_affect() {
1298        assert_suggestion_result(
1299            "Diesel Generator's animation returns to 'idle' state, but it's sound affect remains in the 'work' state.",
1300            NounVerbConfusion::default(),
1301            "Diesel Generator's animation returns to 'idle' state, but it's sound effect remains in the 'work' state.",
1302        );
1303    }
1304
1305    #[test]
1306    fn does_not_flag_affect_as_verb() {
1307        assert_lint_count(
1308            "The change will affect our revenue significantly.",
1309            NounVerbConfusion::default(),
1310            0,
1311        );
1312    }
1313
1314    #[test]
1315    fn does_not_flag_affects_as_verb() {
1316        assert_lint_count(
1317            "This policy directly affects remote workers.",
1318            NounVerbConfusion::default(),
1319            0,
1320        );
1321    }
1322
1323    #[test]
1324    fn does_not_flag_correct_effect_noun() {
1325        assert_lint_count(
1326            "The placebo effect can be powerful.",
1327            NounVerbConfusion::default(),
1328            0,
1329        );
1330    }
1331
1332    #[test]
1333    fn does_not_flag_sound_effects() {
1334        assert_lint_count(
1335            "Sound effects were added in post.",
1336            NounVerbConfusion::default(),
1337            0,
1338        );
1339    }
1340
1341    #[test]
1342    fn issue_1997() {
1343        assert_no_lints(
1344            "It depends on which sources it affects, what parameters it uses, etc.",
1345            NounVerbConfusion::default(),
1346        );
1347    }
1348
1349    #[test]
1350    fn issue_1996() {
1351        assert_no_lints(
1352            "Avoid effects outside of functions.",
1353            NounVerbConfusion::default(),
1354        );
1355    }
1356
1357    #[test]
1358    fn issue_2008() {
1359        assert_no_lints(
1360            "Changes that only affect static types, without breaking runtime behavior.",
1361            NounVerbConfusion::default(),
1362        );
1363    }
1364}