harper_core/linting/lets_confusion/
mod.rs

1mod let_us_redundancy;
2mod no_contraction_with_verb;
3
4use super::merge_linters::merge_linters;
5use let_us_redundancy::LetUsRedundancy;
6use no_contraction_with_verb::NoContractionWithVerb;
7
8// See also:
9// harper-core/src/linting/compound_nouns/implied_ownership_compound_nouns.rs
10// harper-core/src/linting/lets_confusion/let_us_redundancy.rs
11// harper-core/src/linting/lets_confusion/no_contraction_with_verb.rs
12// harper-core/src/linting/pronoun_contraction/should_contract.rs
13merge_linters!(LetsConfusion => LetUsRedundancy, NoContractionWithVerb => "It's often hard to determine where the subject should go with the word `let`. This rule attempts to find common errors with redundancy and contractions that may lead to confusion for readers.");
14
15#[cfg(test)]
16mod tests {
17    use crate::linting::tests::{assert_lint_count, assert_suggestion_result};
18
19    use super::LetsConfusion;
20
21    #[test]
22    fn walking() {
23        assert_suggestion_result(
24            "The crutch let's him walk.",
25            LetsConfusion::default(),
26            "The crutch lets him walk.",
27        );
28    }
29
30    #[test]
31    fn issue_426_us() {
32        assert_suggestion_result("let's us do", LetsConfusion::default(), "lets us do");
33    }
34
35    #[test]
36    fn issue_426_me() {
37        assert_suggestion_result("let's me do", LetsConfusion::default(), "lets me do");
38    }
39
40    #[test]
41    fn from_harper_docs() {
42        assert_suggestion_result(
43            "Often the longest and the shortest words are the most helpful, so lets push them first.",
44            LetsConfusion::default(),
45            "Often the longest and the shortest words are the most helpful, so let's push them first.",
46        );
47    }
48
49    #[test]
50    #[ignore = "\"play\" is also a noun so in a context like \"Sometimes the umpire lets play continue\""]
51    fn issue_470_missing_apostrophe_play() {
52        assert_suggestion_result("lets play", LetsConfusion::default(), "let's play");
53    }
54
55    #[test]
56    #[ignore]
57    fn issue_470_missing_subject_play() {
58        assert_suggestion_result("let play", LetsConfusion::default(), "let's play");
59    }
60
61    #[test]
62    fn issue_470_missing_apostrophe_proceed() {
63        assert_suggestion_result("lets proceed", LetsConfusion::default(), "let's proceed");
64    }
65
66    #[test]
67    fn issue_470_missing_subject_proceed() {
68        assert_suggestion_result("let proceed", LetsConfusion::default(), "let's proceed");
69    }
70
71    #[test]
72    fn issue_548() {
73        assert_lint_count(
74            "A simple web app that lets you fetch random issues.",
75            LetsConfusion::default(),
76            0,
77        );
78    }
79}