harper-core 2.13.0

The language checker for developers.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
use crate::linting::LintGroup;

use super::MapPhraseLinter;

pub fn lint_group() -> LintGroup {
    let mut group = LintGroup::empty();

    macro_rules! add_compound_mappings {
        ($group:expr, { $($name:expr => ($bads:expr, $good:expr)),+ $(,)? }) => {
            $(
                $group.add(
                    $name,
                    Box::new(MapPhraseLinter::new_closed_compound($bads, $good)),
                );
            )+
        };
    }

    // These are compound words that should be condensed.
    // The first column is the name of the rule (which shows up in settings).
    // The second column is the incorrect form of the word and the third column is the correct
    // form.
    add_compound_mappings!(group, {
        "Anybody"         => (&["any body"][..], "anybody"),
        "Anyhow"          => (&["any how"][..], "anyhow"),
        "Anywhere"        => (&["any where"][..], "anywhere"),
        "Backplane"       => (&["back plane"][..], "backplane"),
        "Bypass"          => (&["by pass"][..], "bypass"),
        "Chalkboard"      => (&["chalk board"][..], "chalkboard"),
        "Codebase"        => (&["code base"][..], "codebase"),
        "Codebases"       => (&["code bases"][..], "codebases"),
        "Deadlift"        => (&["dead lift"][..], "deadlift"),
        "Desktop"         => (&["desk top"][..], "desktop"),
        "Devops"          => (&["dev ops"][..], "devops"),
        "Everybody"       => (&["every body"][..], "everybody"),
        "Everyone"        => (&["every one"][..], "everyone"),
        "Everywhere"      => (&["every where"][..], "everywhere"),
        "Furthermore"     => (&["further more"][..], "furthermore"),
        "Guesswork"       => (&["guess work"][..], "guesswork"),
        "Henceforth"      => (&["hence forth"][..], "henceforth"),
        "However"         => (&["how ever"][..], "however"),
        "Insofar"         => (&["in so far"][..], "insofar"),
        "Instead"         => (&["in stead"][..], "instead"),
        "Intact"          => (&["in tact"][..], "intact"),
        "Itself"          => (&["it self"][..], "itself"),
        "Keystroke"       => (&["key stoke", "key stroke"][..], "keystroke"),
        "Keystrokes"      => (&["key stokes", "key strokes"][..], "keystrokes"),
        "Laptop"          => (&["lap top"][..], "laptop"),
        "Lifetime"        => (&["life time"][..], "lifetime"),
        "Middleware"      => (&["middle ware"][..], "middleware"),
        "Meanwhile"       => (&["mean while"][..], "meanwhile"),
        "Misunderstand"   => (&["miss understand"][..], "misunderstand"),
        "Misunderstood"   => (&["miss understood"][..], "misunderstood"),
        "Misuse"          => (&["miss use"][..], "misuse"),
        "Misused"         => (&["miss used"][..], "misused"),
        "Multicore"       => (&["multi core"][..], "multicore"),
        "Multimedia"      => (&["multi media"][..], "multimedia"),
        "Multithreading"  => (&["multi threading"][..], "multithreading"),
        "Myself"          => (&["my self"][..], "myself"),
        "Nonetheless"     => (&["none the less"][..], "nonetheless"),
        "Nothing"         => (&["no thing"][..], "nothing"),
        "Notwithstanding" => (&["not with standing"][..], "notwithstanding"),
        "Nowhere"         => (&["no where"][..], "nowhere"),
        "Oftentimes"      => (&["often times"][..], "oftentimes"),
        "Overall"         => (&["over all"][..], "overall"),
        "Overclocking"    => (&["over clocking"][..], "overclocking"),
        "Overload"        => (&["over load"][..], "overload"),
        "Overnight"       => (&["over night"][..], "overnight"),
        "Postpone"        => (&["post pone"][..], "postpone"),
        "Proofread"       => (&["proof read"][..], "proofread"),
        "Regardless"      => (&["regard less"][..], "regardless"),
        "Shortcoming"     => (&["short coming"][..], "shortcoming"),
        "Shortcomings"    => (&["short comings"][..], "shortcomings"),
        "Somebody"        => (&["some body"][..], "somebody"),
        "Somehow"         => (&["some how"][..], "somehow"),
        "Someone"         => (&["some one"][..], "someone"),
        "Somewhere"       => (&["some where"][..], "somewhere"),
        "Straightforward" => (&["straight forward"][..], "straightforward"),
        "Tenfold"         => (&["ten fold"][..], "tenfold"),
        "There"           => (&["the re"][..], "there"),
        "Therefore"       => (&["there fore"][..], "therefore"),
        "Thereupon"       => (&["there upon"][..], "thereupon"),
        "Tradeoff"        => (&["trade off"][..], "tradeoff"),
        "Underclock"      => (&["under clock"][..], "underclock"),
        "Upset"           => (&["up set"][..], "upset"),
        "Upward"          => (&["up ward"][..], "upward"),
        "Whereupon"       => (&["where upon"][..], "whereupon"),
        "Widespread"      => (&["wide spread"][..], "widespread"),
        "Without"         => (&["with out"][..], "without"),
        "Worldwide"       => (&["world wide"][..], "worldwide"),
        "Worthwhile"      => (&["worth while", "worth-while"][..], "worthwhile"),
    });

    group.set_all_rules_to(Some(true));

    group
}

#[cfg(test)]
mod tests {
    use crate::linting::tests::{assert_no_lints, assert_suggestion_result};

    use super::lint_group;

    #[test]
    fn it_self() {
        let test_sentence = "The project, it self, was quite challenging.";
        let expected = "The project, itself, was quite challenging.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn my_self() {
        let test_sentence = "He treated my self with respect.";
        let expected = "He treated myself with respect.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn there_fore() {
        let test_sentence = "This is the reason; there fore, this is true.";
        let expected = "This is the reason; therefore, this is true.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn mis_understood() {
        let test_sentence = "She miss understood the instructions.";
        let expected = "She misunderstood the instructions.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn mis_use() {
        let test_sentence = "He tends to miss use the tool.";
        let expected = "He tends to misuse the tool.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn mis_used() {
        let test_sentence = "The software was miss used.";
        let expected = "The software was misused.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn mean_while() {
        let test_sentence = "Mean while, the team kept working.";
        let expected = "Meanwhile, the team kept working.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn world_wide() {
        let test_sentence = "The world wide impact was significant.";
        let expected = "The worldwide impact was significant.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn over_all() {
        let test_sentence = "The over all performance was good.";
        let expected = "The overall performance was good.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn how_ever() {
        let test_sentence = "This is true, how ever, details matter.";
        let expected = "This is true, however, details matter.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn wide_spread() {
        let test_sentence = "The news was wide spread throughout the region.";
        let expected = "The news was widespread throughout the region.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn not_with_standing() {
        let test_sentence = "They decided to proceed not with standing any further delay.";
        let expected = "They decided to proceed notwithstanding any further delay.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn any_how() {
        let test_sentence = "She solved the problem any how, even under pressure.";
        let expected = "She solved the problem anyhow, even under pressure.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn none_the_less() {
        let test_sentence = "The results were disappointing, none the less, they continued.";
        let expected = "The results were disappointing, nonetheless, they continued.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn there_upon() {
        let test_sentence = "A decision was made there upon reviewing the data.";
        let expected = "A decision was made thereupon reviewing the data.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn in_so_far() {
        let test_sentence = "This rule applies in so far as it covers all cases.";
        let expected = "This rule applies insofar as it covers all cases.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn where_upon() {
        let test_sentence = "They acted where upon the circumstances allowed.";
        let expected = "They acted whereupon the circumstances allowed.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn up_ward() {
        let test_sentence = "The temperature moved up ward during the afternoon.";
        let expected = "The temperature moved upward during the afternoon.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn hence_forth() {
        let test_sentence = "All new policies apply hence forth immediately.";
        let expected = "All new policies apply henceforth immediately.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn regard_less() {
        let test_sentence = "The decision was made, regard less of the opposition.";
        let expected = "The decision was made, regardless of the opposition.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn over_night() {
        let test_sentence = "They set off on their journey over night.";
        let expected = "They set off on their journey overnight.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn by_pass() {
        let test_sentence = "Please by pass this check for now.";
        let expected = "Please bypass this check for now.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn dead_lift() {
        let test_sentence = "I can dead lift 200 kg.";
        let expected = "I can deadlift 200 kg.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn chalk_board() {
        let test_sentence = "The teacher wrote the equation on the chalk board.";
        let expected = "The teacher wrote the equation on the chalkboard.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn key_stoke() {
        let test_sentence = "Use this key stoke to open search.";
        let expected = "Use this keystroke to open search.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn in_tact() {
        let test_sentence = "The code remains in tact after the merge.";
        let expected = "The code remains intact after the merge.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn intact_is_allowed() {
        assert_no_lints("The data set remains intact.", lint_group());
    }

    #[test]
    fn key_stokes() {
        let test_sentence = "These key stokes are hard to memorize.";
        let expected = "These keystrokes are hard to memorize.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn key_strokes() {
        let test_sentence = "There may have been a missing key stroke.";
        let expected = "There may have been a missing keystroke.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn with_out() {
        let test_sentence = "We left with out a map.";
        let expected = "We left without a map.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn the_re() {
        let test_sentence = "The re are too many popups on this page.";
        let expected = "There are too many popups on this page.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn short_coming() {
        let test_sentence = "That bug is a short coming in the current release.";
        let expected = "That bug is a shortcoming in the current release.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn short_comings() {
        let test_sentence = "We listed three short comings in the postmortem.";
        let expected = "We listed three shortcomings in the postmortem.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn worth_while() {
        let test_sentence =
            "It's worth while documenting all the clientside events that the eventsService emits?";
        let expected =
            "It's worthwhile documenting all the clientside events that the eventsService emits?";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn worth_hyphen_while() {
        let test_sentence = "I feel that the special case of looping over sequences that follow a standard iterator protocol (i.e. optionals) is important enough to be worth-while.";
        let expected = "I feel that the special case of looping over sequences that follow a standard iterator protocol (i.e. optionals) is important enough to be worthwhile.";
        assert_suggestion_result(test_sentence, lint_group(), expected);
    }

    #[test]
    fn tenfold() {
        assert_suggestion_result(
            "If Andrew Kelly has done something wrong hasn’t Theo done that ten fold",
            lint_group(),
            "If Andrew Kelly has done something wrong hasn’t Theo done that tenfold",
        )
    }

    #[test]
    fn codebase() {
        assert_suggestion_result(
            "Having trouble communicating the problems in your code base?",
            lint_group(),
            "Having trouble communicating the problems in your codebase?",
        )
    }

    #[test]
    fn codebases() {
        assert_suggestion_result(
            "Tools to visualize large code bases in different ways.",
            lint_group(),
            "Tools to visualize large codebases in different ways.",
        )
    }

    #[test]
    fn straightforward() {
        assert_suggestion_result(
            "This new vulnerability has a somewhat straight forward path to exploitation and prints funds out of thin air.",
            lint_group(),
            "This new vulnerability has a somewhat straightforward path to exploitation and prints funds out of thin air.",
        )
    }

    #[test]
    fn lifetime() {
        assert_suggestion_result(
            "In a life time it's gone up by more than 10 fold.",
            lint_group(),
            "In a lifetime it's gone up by more than 10 fold.",
        );
    }

    #[test]
    fn tradeoff() {
        assert_suggestion_result(
            "But the trade off was that specific details about the invention, how it worked and how it's made were entered openly for anyone to look up.",
            lint_group(),
            "But the tradeoff was that specific details about the invention, how it worked and how it's made were entered openly for anyone to look up.",
        );
    }

    #[test]
    fn guesswork() {
        assert_suggestion_result(
            "Yes this is guess work and we need more evidence of the dangers but at the same time we need evidence of safety.",
            lint_group(),
            "Yes this is guesswork and we need more evidence of the dangers but at the same time we need evidence of safety.",
        );
    }

    #[test]
    fn oftentimes() {
        assert_suggestion_result(
            "the rust compiler is fast, but often times it has to perform a lot of unnecessary checks because crates contain more stuff than needed",
            lint_group(),
            "the rust compiler is fast, but oftentimes it has to perform a lot of unnecessary checks because crates contain more stuff than needed",
        );
    }
}