harper-core 2.4.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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
use crate::{
    CharStringExt, Dialect, IrregularNouns, Lint, Lrc, Token, TokenStringExt,
    expr::{Expr, FirstMatchOf, OwnedExprExt, SequenceExpr, SpelledNumberExpr},
    indefinite_article::{InitialSound, starts_with_vowel},
    linting::{
        ExprLinter, LintKind, Suggestion,
        expr_linter::{Sentence, followed_by_hyphen, followed_by_word},
    },
    regular_nouns,
    spell::Dictionary,
};

#[derive(PartialEq, Debug)]
enum Mismatch {
    SingularBePluralNoun,
    PluralBeSingularNoun,
}

impl Mismatch {
    fn from_be(be: &[char]) -> Self {
        if be.eq_any_ignore_ascii_case_str(&["are", "were"]) {
            PluralBeSingularNoun
        } else {
            SingularBePluralNoun
        }
    }
}
use Mismatch::*;

#[derive(PartialEq)]
enum WordOrder {
    Statement, // normal: there is, etc.
    Question,  // inverted: is there?, etc.
}
use WordOrder::*;

#[derive(PartialEq)]
enum Tense {
    Present,
    Past,
}
use Tense::*;

pub struct ThereIsAgreement<D> {
    expr: FirstMatchOf,
    dict: D,
}

impl<D: Dictionary> ThereIsAgreement<D> {
    pub fn new(dict: D) -> Self {
        let plural_noun = Lrc::new(|t: &Token, _: &[char]| t.kind.is_plural_noun());

        // reject singular nouns that are also: adjectives, "no", spelled numbers
        // TODO but this rejects "problem"
        // "two" etc. are sg. nouns even though they can also be plural quantifiers
        let singular_noun = Lrc::new(SequenceExpr::default().then_singular_noun().but_not(
            FirstMatchOf::new(vec![
                Box::new(|t: &Token, s: &[char]| {
                    t.kind.is_adjective()
                        || t.get_ch(s)
                            .eq_any_ignore_ascii_case_chars(&[&['n', 'o'], &['n', 'o', 't']])
                }),
                Box::new(SpelledNumberExpr),
            ]),
        ));

        let first_match_of: Vec<Box<dyn Expr>> = [
            (SingularBePluralNoun, Statement, Present),
            (SingularBePluralNoun, Statement, Past),
            (SingularBePluralNoun, Question, Present),
            (SingularBePluralNoun, Question, Past),
            (PluralBeSingularNoun, Statement, Present),
            (PluralBeSingularNoun, Statement, Past),
            (PluralBeSingularNoun, Question, Present),
            (PluralBeSingularNoun, Question, Past),
        ]
        .iter()
        .map(|(mismatch, word_order, tense)| {
            let be = match (mismatch, tense) {
                (SingularBePluralNoun, Present) => "is",
                (SingularBePluralNoun, Past) => "was",
                (PluralBeSingularNoun, Present) => "are",
                (PluralBeSingularNoun, Past) => "were",
            };
            let (first, second) = match word_order {
                Statement => ("there", be),
                Question => (be, "there"),
            };

            let seq = SequenceExpr::aco(first).t_ws().t_aco(second).t_ws();

            (match mismatch {
                SingularBePluralNoun => Box::new(seq.then(plural_noun.clone())),
                PluralBeSingularNoun => Box::new(seq.then(singular_noun.clone())),
            }) as Box<dyn Expr>
        })
        .chain(std::iter::once(Box::new(
            SequenceExpr::fixed_phrase("there's ").then(plural_noun.clone()),
        ) as Box<dyn Expr>))
        .collect();

        Self {
            expr: FirstMatchOf::new(first_match_of),
            dict,
        }
    }
}

impl<D: Dictionary> ExprLinter for ThereIsAgreement<D> {
    type Unit = Sentence;

    fn match_to_lint_with_context(
        &self,
        toks: &[Token],
        src: &[char],
        ctx: Option<(&[Token], &[Token])>,
    ) -> Option<super::Lint> {
        match_to_lint(&self.dict, toks, src, ctx)
    }

    fn expr(&self) -> &dyn Expr {
        &self.expr
    }

    fn description(&self) -> &str {
        "Checks for `is there` and its variants agreeing with singular vs plural subjects"
    }
}

fn match_to_lint<D: Dictionary>(
    dict: &D,
    toks: &[Token],
    src: &[char],
    ctx: Option<(&[Token], &[Token])>,
) -> Option<super::Lint> {
    let first = toks[0].span.get_content(src);
    let second = toks[2].span.get_content(src);

    const BE_FORMS: &[&str] = &["is", "are", "was", "were"];

    match (
        first.starts_with_ignore_ascii_case_str("there"),
        first.last(),
    ) {
        (false, _) if second.eq_str("there") => handle_question(toks, src, ctx, dict),
        (true, Some(&'s')) => handle_theres(toks, src, ctx, dict),
        (true, _) => handle_statement(toks, src, ctx, dict),
        _ => None, // unreachable
    }
}

// No need to allocate.
// Only four input words are possible, but lettercase can vary.
// Only grammatical number changes.
fn get_new_be(orig_be: &[char]) -> &[char] {
    let [first, second, ..] = orig_be else {
        return orig_be;
    };

    match (first.to_ascii_lowercase(), second.to_ascii_lowercase()) {
        ('i', 's') => &['a', 'r', 'e'],
        ('a', 'r') => &['i', 's'],
        ('w', 'a') => &['w', 'e', 'r', 'e'],
        ('w', 'e') => &['w', 'a', 's'],
        _ => orig_be,
    }
}

type NounFormGetters<D> = (
    fn(&[char]) -> Option<Vec<char>>,
    fn(&D, &[char]) -> Vec<Vec<char>>,
);

// Returns zero or more noun forms.
// Needs to allocate a vec for each noun and for the array of nouns.
// Each noun will be accompanied by an appropriate indefinite article.
// TODO does not yet handle words which take either/both "a"/"an"
fn get_new_nouns<'a, D: Dictionary>(
    dict: &D,
    orig_noun: &'a [char],
    mismatch_type: &Mismatch,
) -> Vec<(Vec<char>, &'a [char])> {
    let (irreg_func, reg_func): NounFormGetters<D> = match mismatch_type {
        PluralBeSingularNoun => (get_irregular_plural, regular_nouns::get_plurals),
        SingularBePluralNoun => (get_irregular_singular, regular_nouns::get_singulars),
    };
    let (irregular, regulars) = (irreg_func(orig_noun), reg_func(dict, orig_noun));

    irregular
        .into_iter()
        .chain(regulars)
        .collect::<Vec<_>>()
        .into_iter()
        .map(|n| {
            let art = match starts_with_vowel(&n, Dialect::American) {
                Some(InitialSound::Vowel) => &['a', 'n'][..],
                Some(InitialSound::Consonant) => &['a'][..],
                // Some(InitialSound::Either) => &[&['a'][..], &['a', 'n'][..]],
                _ => &['a'][..],
            };
            (n, art)
        })
        .collect()
}

fn get_irregular_plural(singular: &[char]) -> Option<Vec<char>> {
    IrregularNouns::curated()
        .get_plural_for_singular_chars(singular)
        .map(|s| s.chars().collect())
}

fn get_irregular_singular(plural: &[char]) -> Option<Vec<char>> {
    IrregularNouns::curated()
        .get_singular_for_plural_chars(plural)
        .map(|s| s.chars().collect())
}

fn handle_statement<D: Dictionary>(
    toks: &[Token],
    src: &[char],
    ctx: Option<(&[Token], &[Token])>,
    dict: &D,
) -> Option<Lint> {
    // Don't proceed if the next token is a hyphen, indicating a compound.
    // e.g. "function-like macros"
    if followed_by_hyphen(ctx) {
        return None;
    }

    // Or if the next word in a noun, also indicating a compound:
    // e.g. "there are config errors"
    if followed_by_word(ctx, |t| {
        (t.kind.is_noun()
            && !t.kind.is_verb_progressive_form()
            && !t
                .get_ch(src)
                .eq_any_ignore_ascii_case_str(&["but", "in", "like"]))
            // to allow "there are bug in ..." to be corrected
            || t.get_ch(src).eq_any_ignore_ascii_case_str(&["and", "or"])
    }) {
        return None;
    }

    // NOTE - for a statement we only need to replace two words.
    // NOTE - (there) "are man" -> "there is (a) man"
    //                          -> "there are men"
    let replacement_template = toks[2..=4].get_ch(src)?;

    // tok 2 is form of "be": is are was were
    // tok 4 is noun that doesn't agree in number with the form of "be"
    let orig_be = toks[2].get_ch(src);
    let orig_noun = toks[4].get_ch(src);

    let mismatch_type = Mismatch::from_be(orig_be);

    // fix 1 = change form of "be" to match the noun
    //         - suggestion is "corrected be" + noun
    let new_be = get_new_be(orig_be);

    // When PluralBeSingularNoun we need to look up the right
    // indefinite article for the original noun
    // and insert it before the noun (with a space between)
    let mut replacement_value: Vec<char> = new_be.to_vec();

    // Only add article and space for singular nouns
    if matches!(mismatch_type, PluralBeSingularNoun) {
        // get the indefinite article for the orig_noun
        let article = match starts_with_vowel(orig_noun, Dialect::American) {
            Some(InitialSound::Vowel) => &['a', 'n'][..],
            Some(InitialSound::Consonant) => &['a'][..],
            // TODO InitialSound::Either needs to return an array of ["a", "an"]
            _ => &['\u{1F170}', '\u{fe0f}', '\u{1F170}', '\u{fe0f}'][..],
        };
        replacement_value.extend(&[' ']);
        replacement_value.extend(article.iter());
    }

    replacement_value.push(' ');
    replacement_value.extend(orig_noun.iter());

    let be_suggestion =
        Suggestion::replace_with_match_case(replacement_value, replacement_template);

    // fix 2 = change noun to match the form of "be"
    //         - could be multiple
    //         - don't need a/an here because nouns are plural
    let new_nouns = get_new_nouns(dict, orig_noun, &mismatch_type);

    let article_noun_pairs = new_nouns
        .iter()
        .map(|(noun, article)| {
            let mut result: Vec<char> = orig_be.to_vec();

            if matches!(mismatch_type, SingularBePluralNoun) {
                result.extend(&[' ']);
                result.extend(article.iter());
            }

            result.extend(&[' ']);
            result.extend(noun.iter());

            result
        })
        .collect::<Vec<Vec<char>>>();

    let noun_suggestions: Vec<Suggestion> = article_noun_pairs
        .iter()
        .map(|sug_repl_value| {
            Suggestion::replace_with_match_case(sug_repl_value.to_vec(), replacement_template)
        })
        .collect();

    Some(Lint {
        span: toks[2..=4].span()?,
        message: "There is disagreement in number between the verb and the noun.".to_string(),
        suggestions: [vec![be_suggestion], noun_suggestions].concat(),
        lint_kind: LintKind::Agreement,
        ..Default::default()
    })
}

fn handle_theres<D: Dictionary>(
    toks: &[Token],
    src: &[char],
    _ctx: Option<(&[Token], &[Token])>,
    dict: &D,
) -> Option<Lint> {
    // NOTE - for there's we only need to replace two words.
    // NOTE - "there's men" -> there's a man
    //                      -> there are men

    let replacement_template = toks[0..=2].get_ch(src)?;

    // tok 0 is "there's" (with various types of apostrophe character)
    // tok 2 is noun that doesn't agree in number with "is" (the form of "be" encoded in "there's")
    let orig_there_be = toks[0].span.get_content(src);
    let orig_noun = toks[2].span.get_content(src);

    let mismatch_type = SingularBePluralNoun;

    // fix 1 = change "there's" to "there are" to match the noun
    //         - suggestion is "there are" + noun
    let new_there_be = &['t', 'h', 'e', 'r', 'e', ' ', 'a', 'r', 'e'][..];

    let replacement_value: Vec<char> = new_there_be
        .iter()
        .chain(&[' '])
        .chain(orig_noun.iter())
        .copied()
        .collect();

    let there_be_suggestion =
        Suggestion::replace_with_match_case(replacement_value, replacement_template);

    // fix 2
    let new_nouns = get_new_nouns(dict, orig_noun, &mismatch_type);

    let article_noun_pairs = new_nouns
        .iter()
        .map(|(noun, article)| {
            let mut result: Vec<char> = orig_there_be.to_vec();

            // there's is always SingularBePluralNoun
            result.extend(&[' ']);
            result.extend(article.iter());

            result.extend(&[' ']);
            result.extend(noun.iter());

            result
        })
        .collect::<Vec<Vec<char>>>();

    let noun_suggestions: Vec<Suggestion> = article_noun_pairs
        .iter()
        .map(|sug_repl_value| {
            Suggestion::replace_with_match_case(sug_repl_value.to_vec(), replacement_template)
        })
        .collect();

    Some(Lint {
        span: toks[0..=2].span()?,
        lint_kind: LintKind::Agreement,
        suggestions: [vec![there_be_suggestion], noun_suggestions].concat(),
        message: "`There's` means `there is`, which requires a singular noun.".to_string(),
        ..Default::default()
    })
}

fn handle_question<D: Dictionary>(
    toks: &[Token],
    src: &[char],
    ctx: Option<(&[Token], &[Token])>,
    dict: &D,
) -> Option<Lint> {
    // Don't proceed if the next token is a noun, indicating a compound:
    // e.g. "there are config errors"
    if followed_by_word(ctx, |t| {
        t.kind.is_noun()
            && !t.kind.is_verb_progressive_form()
            && !t.get_ch(src).eq_any_ignore_ascii_case_str(&["in", "or"])
    }) {
        return None;
    }

    // NOTE - for a question we must replace three words!
    // NOTE - "are there man" -> "is there (a) man"
    //                        -> "are there men"
    let replacement_template = toks[0..=4].get_ch(src)?;

    // tok 0 is form of "be": is are was were
    // tok 2 is "there"
    // tok 4 is noun that doesn't agree in number with the form of "be"
    let orig_be = toks[0].get_ch(src);
    let orig_noun = toks[4].get_ch(src);

    let mismatch_type = Mismatch::from_be(orig_be);

    // fix 1 = change form of "be" to match the noun
    //         - suggestion is "corrected be" + "there" + noun
    let new_be = get_new_be(orig_be);

    let mut replacement_value: Vec<char> = new_be
        .iter()
        .chain(&[' ', 't', 'h', 'e', 'r', 'e'])
        .copied()
        .collect();

    // Only add article and space for singular nouns
    if matches!(mismatch_type, PluralBeSingularNoun) {
        let article = match starts_with_vowel(orig_noun, Dialect::American) {
            Some(InitialSound::Vowel) => &['a', 'n'][..],
            Some(InitialSound::Consonant) => &['a'][..],
            // TODO InitialSound::Either needs to return an array of ["a", "an"]
            _ => &['\u{1F170}', '\u{fe0f}', '\u{1F170}', '\u{fe0f}'][..],
        };
        replacement_value.extend(&[' ']);
        replacement_value.extend(article.iter());
    }

    replacement_value.extend(&[' ']);
    replacement_value.extend(orig_noun.iter());

    let be_suggestion =
        Suggestion::replace_with_match_case(replacement_value, replacement_template);

    // fix 2
    let new_nouns = get_new_nouns(dict, orig_noun, &mismatch_type);
    let article_noun_pairs = new_nouns
        .iter()
        .map(|(noun, article)| {
            let mut result: Vec<char> = orig_be
                .iter()
                .chain(&[' ', 't', 'h', 'e', 'r', 'e'])
                .copied()
                .collect();

            // Only add article and space for singular nouns
            if matches!(mismatch_type, SingularBePluralNoun) {
                result.extend(&[' ']);
                result.extend(article.iter());
            }

            result.extend(&[' ']);
            result.extend(noun.iter());

            result
        })
        .collect::<Vec<_>>();

    let noun_suggestions = article_noun_pairs
        .iter()
        .map(|replacement_value| {
            Suggestion::replace_with_match_case(replacement_value.to_vec(), replacement_template)
        })
        .collect::<Vec<_>>();

    Some(Lint {
        span: toks[0..=4].span()?,
        lint_kind: LintKind::Agreement,
        suggestions: [vec![be_suggestion], noun_suggestions].concat(),
        message: "There is disagreement in number between the verb and the noun.".to_string(),
        ..Default::default()
    })
}

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

    use super::ThereIsAgreement;

    // basic functionality

    #[test]
    fn statement_present_pl_regular() {
        assert_good_and_bad_suggestions(
            "there is things",
            ThereIsAgreement::new(FstDictionary::curated()),
            &["there are things", "there is a thing"],
            &[],
        );
    }

    #[test]
    fn statement_present_sg_irregular() {
        assert_good_and_bad_suggestions(
            "there are person",
            ThereIsAgreement::new(FstDictionary::curated()),
            &["there are people", "there is a person"],
            &[],
        );
    }

    #[test]
    fn statement_present_theres_pl() {
        assert_good_and_bad_suggestions(
            "there's secrets",
            ThereIsAgreement::new(FstDictionary::curated()),
            &["there are secrets", "there's a secret"],
            &[],
        );
    }

    #[test]
    fn statement_past_pl_vowel() {
        assert_good_and_bad_suggestions(
            "there was ideas",
            ThereIsAgreement::new(FstDictionary::curated()),
            &["there were ideas", "there was an idea"],
            &[],
        );
    }

    #[test]
    fn statement_past_sg() {
        assert_good_and_bad_suggestions(
            "there were child",
            ThereIsAgreement::new(FstDictionary::curated()),
            &["there were children", "there was a child"],
            &[],
        );
    }

    #[test]
    // NOTE suggests "mans" and "manes" due to how the dictionary & annotations work
    fn question_pres_sg() {
        assert_good_and_bad_suggestions(
            "are there man",
            ThereIsAgreement::new(FstDictionary::curated()),
            &["are there men", "is there a man"],
            &[],
        );
    }

    #[test]
    fn question_pres_pl() {
        assert_good_and_bad_suggestions(
            "is there women",
            ThereIsAgreement::new(FstDictionary::curated()),
            &["are there women", "is there a woman"],
            &[],
        );
    }

    #[test]
    fn question_past_sg() {
        assert_good_and_bad_suggestions(
            "were there cow",
            ThereIsAgreement::new(FstDictionary::curated()),
            &["were there cows", "was there a cow"],
            &[],
        );
    }

    #[test]
    fn question_past_pl() {
        assert_good_and_bad_suggestions(
            "were there elephant",
            ThereIsAgreement::new(FstDictionary::curated()),
            &["were there elephants", "was there an elephant"],
            &[],
        );
    }

    #[test]
    fn dont_flag_there_are_hyphenated_compound_starts_singular() {
        assert_no_lints(
            "there are function-like macros",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    fn dont_flag_there_are_open_compound_starts_singular() {
        assert_no_lints(
            "there are config errors",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    fn a_or_an_depends_on_dialect_herb() {
        assert_good_and_bad_suggestions(
            "there's herbs.",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "there are herbs.",
                // "there'ss a herb.", // TODO: This module does not yet accept a `Dialect`, `American` is hard-coded for now.
                "there's an herb.",
            ],
            &[],
        )
    }

    #[test]
    fn a_or_an_depends_on_dialect_hotel() {
        assert_good_and_bad_suggestions(
            "There are hotel.",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "There are hotels.",
                "There is a hotel.",
                // "There is an hotel.", // TODO: Dialect, preference, or both?
            ],
            &[],
        )
    }

    // Real-world tests

    // there is plural: fix

    #[test]
    fn fix_there_is_errors() {
        assert_good_and_bad_suggestions(
            "Hi, when I make the code, there is errors",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Hi, when I make the code, there are errors",
                "Hi, when I make the code, there is an error",
            ],
            &["Hi, when I make the code, there is a error"],
        );
    }

    #[test]
    fn fix_there_is_warnings() {
        assert_good_and_bad_suggestions(
            "There is warnings from kotlin and dart, as reference: Elvis operator (?:) always returns the left operand of non-nullable type String.",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "There are warnings from kotlin and dart, as reference: Elvis operator (?:) always returns the left operand of non-nullable type String.",
                "There is a warning from kotlin and dart, as reference: Elvis operator (?:) always returns the left operand of non-nullable type String.",
            ],
            &[],
        );
    }

    #[test]
    fn fix_there_is_problems() {
        assert_good_and_bad_suggestions(
            "Problem is that if there is a project that has a csproj file, then there is problems with the history folder.",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Problem is that if there is a project that has a csproj file, then there are problems with the history folder.",
                "Problem is that if there is a project that has a csproj file, then there is a problem with the history folder.",
            ],
            &[],
        );
    }

    #[test]
    #[ignore = "`replace_with_match_case` matching case char-by-char causes the wrong letters to be uppercased"]
    fn fix_there_is_commands() {
        assert_good_and_bad_suggestions(
            "Additionally if there is Commands that can be used on multiple Resources at the same time.",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Additionally if there are Commands that can be used on multiple Resources at the same time.",
                "Additionally if there is a Command that can be used on multiple Resources at the same time.",
            ],
            &[],
        );
    }

    #[test]
    fn fix_there_is_values() {
        assert_suggestion_result(
            "This mean there would not be a single cache, but as many caches as there is values for the second argument.",
            ThereIsAgreement::new(FstDictionary::curated()),
            "This mean there would not be a single cache, but as many caches as there are values for the second argument.",
        );
    }

    #[test]
    fn fix_there_is_strings() {
        assert_good_and_bad_suggestions(
            "I can image other cases (tools different from SPSS) in which there is strings in both sides of the dictionary",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "I can image other cases (tools different from SPSS) in which there are strings in both sides of the dictionary",
                "I can image other cases (tools different from SPSS) in which there is a string in both sides of the dictionary",
            ],
            &[],
        );
    }

    #[test]
    fn fix_there_is_things() {
        assert_good_and_bad_suggestions(
            "even though we can check whether there is things running in Node, we can not do it for Chromium's message loops",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "even though we can check whether there are things running in Node, we can not do it for Chromium's message loops",
                "even though we can check whether there is a thing running in Node, we can not do it for Chromium's message loops",
            ],
            &[],
        );
    }

    #[test]
    fn fix_there_is_people() {
        // TODO `assert_good_and_bad_suggestions`` fails with more than two correct answers because
        // TODO it hasn't been converted to the new logic in `assert_suggestion_result`
        // assert_good_and_bad_suggestions(
        //     "there is people making projects, there is people doing tutorials",
        //     ThereIsAgreement::new(FstDictionary::curated(),
        //     &[
        //         "there are people making projects, there are people doing tutorials",
        //         "there is a person making projects, there is a person doing tutorials",
        //     ],
        //     &[],
        // );
        assert_suggestion_result(
            "there is people making projects, there is people doing tutorials",
            ThereIsAgreement::new(FstDictionary::curated()),
            "there are people making projects, there are people doing tutorials",
        );
        assert_suggestion_result(
            "there is people making projects, there is people doing tutorials",
            ThereIsAgreement::new(FstDictionary::curated()),
            "there is a person making projects, there is a person doing tutorials",
        );
    }

    #[test]
    fn fix_there_is_instructions() {
        assert_good_and_bad_suggestions(
            "I am just wondering if there is instructions somewhere for handling deep linking while using Redux.",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "I am just wondering if there are instructions somewhere for handling deep linking while using Redux.",
                "I am just wondering if there is an instruction somewhere for handling deep linking while using Redux.",
            ],
            &[],
        );
    }

    #[test]
    fn fix_there_is_packages() {
        assert_suggestion_result(
            "if there is packages that handle such protocols installed",
            ThereIsAgreement::new(FstDictionary::curated()),
            "if there are packages that handle such protocols installed",
        );
    }

    // there is plural: don't flag

    #[test]
    // NOTE: This actually does pass because "who" is marked as a noun
    // NOTE:   because the dictionary is case-folded and "WHO" is a proper noun.
    #[ignore = "TODO: abort if next word is a relative pronoun like `who`"]
    fn dont_flag_there_is_people_who_have_done_xyz() {
        assert_no_lints(
            "The main expectation there is people who have a deprecated app installed will then get an error if it's disabled",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    #[ignore = "TODO: abort if next token is `/`"]
    fn dont_flag_there_is_packages_part_of_dir() {
        assert_no_lints(
            "For example there is packages/vite/src/node , but no packages/vite/src/deno",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    // there are singular: fix

    #[test]
    fn fix_there_are_bug() {
        assert_good_and_bad_suggestions(
            "there are bug in svelte 3.0 that axios from 0.22.0 version undefined",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "there is a bug in svelte 3.0 that axios from 0.22.0 version undefined",
                "there are bugs in svelte 3.0 that axios from 0.22.0 version undefined",
            ],
            &[],
        );
    }

    #[test]
    fn fix_there_are_description() {
        assert_good_and_bad_suggestions(
            "there are description regarding thread safety in zmq document.",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "there is a description regarding thread safety in zmq document.",
                "there are descriptions regarding thread safety in zmq document.",
            ],
            &[],
        );
    }

    #[test]
    fn fix_there_are_issue() {
        assert_good_and_bad_suggestions(
            "Seems like if there are issue with OpenAI, it is still trying to call chat completion and giving type error.",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Seems like if there are issues with OpenAI, it is still trying to call chat completion and giving type error.",
                "Seems like if there is an issue with OpenAI, it is still trying to call chat completion and giving type error.",
            ],
            &[],
        );
    }

    #[test]
    #[ignore = "TODO: 'problem' is being rejected as an adjective as well as a singular noun"]
    fn fix_there_are_problem() {
        assert_good_and_bad_suggestions(
            "There are problem with official serving docker image gpu version",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "There is a problem with official serving docker image gpu version",
                "There are problems with official serving docker image gpu version",
            ],
            &[],
        );
    }

    // there are singular: don't flag

    #[test]
    fn dont_flag_there_are_dep_conflicts() {
        assert_no_lints(
            "Wrong advice when there are dependency conflicts",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    fn dont_flag_there_are_dep_errs() {
        assert_no_lints(
            "If there are dependency errors they will be immediately logged out to you.",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    #[ignore = "'definition syntax' looks singular but the full np is the plural 'definition syntax errors'"]
    fn dont_flag_there_are_def_syntax_errs() {
        assert_no_lints(
            "New Campaign Properties dialog loses changes if there are definition syntax errors",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    fn dont_flag_there_are_description_and_instruction_keys() {
        assert_no_lints(
            "There are description and instruction keys for the classes.",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    fn dont_flag_there_are_function_like() {
        assert_no_lints(
            "clang-format indents class member functions oddly if there are function-like macro invocations",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    // there was pl: fix

    #[test]
    fn fix_there_was_configs() {
        assert_good_and_bad_suggestions(
            "I did see that there was configs for it before but it isn't in the configs anymore.",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "I did see that there were configs for it before but it isn't in the configs anymore.",
                "I did see that there was a config for it before but it isn't in the configs anymore.",
            ],
            &[],
        );
    }

    #[test]
    fn fix_there_was_examples() {
        assert_good_and_bad_suggestions(
            "It would be awesome if there was examples on how to include inline citations",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "It would be awesome if there were examples on how to include inline citations",
                "It would be awesome if there was an example on how to include inline citations",
            ],
            &[],
        );
    }

    #[test]
    fn fix_there_was_functions() {
        assert_good_and_bad_suggestions(
            "I noticed in the AXP2101_Class for the unified library that there was functions like \"isPekeyShortPressIrq()\"",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "I noticed in the AXP2101_Class for the unified library that there were functions like \"isPekeyShortPressIrq()\"",
                "I noticed in the AXP2101_Class for the unified library that there was a function like \"isPekeyShortPressIrq()\"",
            ],
            &[],
        );
    }

    #[test]
    fn fix_there_was_issues() {
        assert_good_and_bad_suggestions(
            "Restored to a Snapshot, but there was issues with Hyprland.",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Restored to a Snapshot, but there were issues with Hyprland.",
                "Restored to a Snapshot, but there was an issue with Hyprland.",
            ],
            &[],
        );
    }

    #[test]
    fn fix_there_was_settings() {
        assert_good_and_bad_suggestions(
            "I also tried creating a fresh page on the same site, and there was settings but only 2 pages of settings",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "I also tried creating a fresh page on the same site, and there were settings but only 2 pages of settings",
                "I also tried creating a fresh page on the same site, and there was a setting but only 2 pages of settings",
            ],
            &[],
        );
    }

    // there were sg: fix

    #[test]
    fn fix_there_were_function() {
        assert_good_and_bad_suggestions(
            "Instead, it would be helpful if there were function in the autoloader capable of taking the a list of names of packages to enable.",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Instead, it would be helpful if there were functions in the autoloader capable of taking the a list of names of packages to enable.",
                "Instead, it would be helpful if there was a function in the autoloader capable of taking the a list of names of packages to enable.",
                // TODO we don't support subjunctive "were" in contexts after "if"
                // "Instead, it would be helpful if there were a function in the autoloader capable of taking the a list of names of packages to enable.",
            ],
            &[],
        );
    }

    #[test]
    fn fix_there_were_hint() {
        assert_good_and_bad_suggestions(
            "there were hint that this could break the build",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "there were hints that this could break the build",
                "there was a hint that this could break the build",
            ],
            &[],
        );
    }

    #[test]
    fn fix_there_were_issue() {
        assert_good_and_bad_suggestions(
            "there were issue with using venv and it was pulled",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "there were issues with using venv and it was pulled",
                "there was an issue with using venv and it was pulled",
            ],
            &[],
        );
    }

    #[test]
    #[ignore = "TODO: 'problem' is being rejected as an adjective as well as a singular noun"]
    fn fix_there_were_problem_about() {
        assert_good_and_bad_suggestions(
            "there were problem about version but this error is solved by correcting version in these files",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "there were problems about version but this error is solved by correcting version in these files",
                "there was a problem about version but this error is solved by correcting version in these files",
            ],
            &[],
        );
    }

    #[test]
    #[ignore = "TODO: 'problem' is being rejected as an adjective as well as a singular noun"]
    fn fix_there_were_problem_with() {
        assert_good_and_bad_suggestions(
            "there were problem with page alignment crossing",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "there were problems with page alignment crossing",
                "there was a problem with page alignment crossing",
            ],
            &[],
        );
    }

    // there were sg: don't flag

    #[test]
    // "two" is a technically a singular noun, but we avoid flagging numbers
    fn dont_flag_alice_there_were_two() {
        assert_no_lints(
            "This time there were two little shrieks, and more sounds of broken glass.",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    fn dont_flag_gatsby_there_were_twinkle_bells() {
        assert_no_lints(
            "When he realized what I was talking about, that there were twinkle-bells of sunshine in the room, he smiled like a weather man",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    #[ignore = "We can't detect first name + surname, especially for rare surnames like 'Waize'"]
    fn dont_flag_gatsby_there_were_a_and_b() {
        assert_no_lints(
            "Of theatrical people there were Gus Waize and Horace O’Donavan and Lester Myer and George Duckweed and Francis",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    // is there plural

    #[test]
    fn fix_is_there_apps() {
        assert_good_and_bad_suggestions(
            "Ok, but is there apps that actually do that?",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Ok, but are there apps that actually do that?",
                "Ok, but is there an app that actually do that?",
            ],
            &[],
        );
    }

    #[test]
    fn fix_is_there_ideas() {
        assert_suggestion_result(
            "Is there ideas to make regular page to listen for api (POST/PUT/.. etc requests)",
            ThereIsAgreement::new(FstDictionary::curated()),
            "Are there ideas to make regular page to listen for api (POST/PUT/.. etc requests)",
        );
    }

    #[test]
    fn fix_is_there_people() {
        assert_suggestion_result(
            "please guys tell me, is there people really making money with bot?",
            ThereIsAgreement::new(FstDictionary::curated()),
            "please guys tell me, are there people really making money with bot?",
        );
    }

    #[test]
    fn fix_is_there_solutions() {
        assert_good_and_bad_suggestions(
            "Run-as binary without the suid bit set, is there solutions?",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Run-as binary without the suid bit set, are there solutions?",
                "Run-as binary without the suid bit set, is there a solution?",
            ],
            &[],
        );
    }

    #[test]
    fn fix_is_there_things() {
        assert_suggestion_result(
            "is there things you could change to make it a more general product",
            ThereIsAgreement::new(FstDictionary::curated()),
            "are there things you could change to make it a more general product",
        );
    }

    #[test]
    fn fix_is_there_tools() {
        assert_good_and_bad_suggestions(
            "Is there tools or documentation how to recover / rebuild /run fsck on the failed replicas.",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Are there tools or documentation how to recover / rebuild /run fsck on the failed replicas.",
                "Is there a tool or documentation how to recover / rebuild /run fsck on the failed replicas.",
            ],
            &[],
        );
    }

    // are there singular: fix

    #[test]
    #[ignore = "TODO: 'problem' is being rejected as an adjective as well as a singular noun"]
    fn fix_are_there_problem() {
        assert_good_and_bad_suggestions(
            "Is it just the namespace or are there problem in the use statements as well?",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Is it just the namespace or are there problems in the use statements as well?",
                "Is it just the namespace or is there a problem in the use statements as well?",
            ],
            &[],
        );
    }

    #[test]
    fn fix_are_there_solution() {
        assert_good_and_bad_suggestions(
            "Are there solution for making lsws using h2 protocol in client browsers?",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Are there solutions for making lsws using h2 protocol in client browsers?",
                "Is there a solution for making lsws using h2 protocol in client browsers?",
            ],
            &[],
        );
    }

    #[test]
    fn fix_are_there_solution_slash_workaround() {
        assert_good_and_bad_suggestions(
            "are there solution/workaround ?",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                // TODO the ideal fix pluralizes each word separated by `/`
                // "are there solutions/workarounds ?",
                "are there solutions/workaround ?",
                "is there a solution/workaround ?",
            ],
            &[],
        );
    }

    #[test]
    fn fix_are_there_concept() {
        assert_good_and_bad_suggestions(
            "So, what is a external interface in C++? are there concept of interface in C++?",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "So, what is a external interface in C++? are there concepts of interface in C++?",
                "So, what is a external interface in C++? is there a concept of interface in C++?",
            ],
            &[],
        );
    }

    #[test]
    fn fix_are_there_object() {
        assert_good_and_bad_suggestions(
            "He check are there object with same id, if there is no object with same id he creates new and add to array",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "He check are there objects with same id, if there is no object with same id he creates new and add to array",
                "He check is there an object with same id, if there is no object with same id he creates new and add to array",
            ],
            &[],
        );
    }

    #[test]
    #[ignore = "variable is being rejected as an adjective as well as a singular noun"]
    fn fix_are_there_variable() {
        assert_good_and_bad_suggestions(
            "Are there variable in side it or is it some sort of dataset?",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Are there variables in side it or is it some sort of dataset?",
                "Is there a variable in side it or is it some sort of dataset?",
            ],
            &[],
        );
    }

    // are there singular: don't flag

    #[test]
    fn ignore_are_there_answer_generation_errors() {
        assert_no_lints(
            "Are there Answer Generation Errors?",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    fn ignore_are_there_application_objects() {
        assert_no_lints(
            "Are there application objects assigned to non-existent sites",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    fn ignore_are_there_code_files() {
        assert_no_lints(
            "Why are there code files more than 10k lines long?",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    fn ignore_are_there_error_logs() {
        assert_no_lints(
            "Are there error logs in your worker when flows fail?",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    fn ignore_are_there_tool_specific() {
        assert_no_lints(
            "Are there tool specific constraints for RM tool exchange for EA?",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    // was there plural: fix

    #[test]
    fn fix_was_there_bugs() {
        assert_good_and_bad_suggestions(
            "Was there bugs, and goofed-up quests?",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Were there bugs, and goofed-up quests?",
                "Was there a bug, and goofed-up quests?",
            ],
            &[],
        );
    }

    #[test]
    fn fix_was_there_hints() {
        assert_good_and_bad_suggestions(
            "Was there hints in the game that points you to it?",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Were there hints in the game that points you to it?",
                "Was there a hint in the game that points you to it?",
            ],
            &[],
        );
    }

    #[test]
    fn fix_was_there_issues() {
        assert_good_and_bad_suggestions(
            "I saw you closed that PR, was there issues getting it merged upstream?",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "I saw you closed that PR, were there issues getting it merged upstream?",
                "I saw you closed that PR, was there an issue getting it merged upstream?",
            ],
            &[],
        );
    }

    #[test]
    fn fix_was_there_problems() {
        assert_good_and_bad_suggestions(
            "Was there problems with other files that you had written to the SD card (PRG/CRT)?",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Were there problems with other files that you had written to the SD card (PRG/CRT)?",
                "Was there a problem with other files that you had written to the SD card (PRG/CRT)?",
            ],
            &[],
        );
    }

    // was there plural: don't flag

    #[test]
    fn dont_flag_last_time_i_was_there() {
        assert_no_lints(
            "Last time I was there flags were on almost every house or fence.",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    #[ignore = "Harper cannot detect this construction"]
    fn dont_flag_the_grate_was_there() {
        assert_no_lints(
            "Saying the grate was there helps him avoid a lawsuit.",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    fn dont_flag_when_he_was_there() {
        assert_no_lints(
            "When he was there tips were going way, way up.",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    // were there sg: fix

    #[test]
    fn were_there_description() {
        assert_good_and_bad_suggestions(
            "Were there pictures of the Primarchs around before then? Were there description?",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Were there pictures of the Primarchs around before then? Were there descriptions?",
                "Were there pictures of the Primarchs around before then? Was there a description?",
            ],
            &[],
        );
    }

    // were there sg: don't flag

    #[test]
    fn font_flag_were_there_bomb_drills() {
        assert_no_lints(
            "Were there bomb drills in school?",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    fn dont_flag_were_there_set_rules() {
        assert_no_lints(
            "For instance, were there set rules as to the funds that candidates would have to have acquired",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    fn dont_flag_were_there_tour_buses() {
        assert_no_lints(
            "Were there tour buses and different hotels and parties each night? Yep.",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    // there's plural

    #[test]
    fn fix_theres_children() {
        assert_good_and_bad_suggestions(
            "now, check whether there's children",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "now, check whether there's a child",
                "now, check whether there are children",
            ],
            &[],
        );
    }

    #[test]
    fn fix_theres_ideas() {
        assert_good_and_bad_suggestions(
            "there's ideas how it should behave for some media etc.",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "there's an idea how it should behave for some media etc.",
                "there are ideas how it should behave for some media etc.",
            ],
            &[],
        );
    }

    #[test]
    fn fix_theres_people() {
        assert_good_and_bad_suggestions(
            "Currently there's people helping out, and it's fairly easy to find someone if you need something.",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "Currently there are people helping out, and it's fairly easy to find someone if you need something.",
                "Currently there's a person helping out, and it's fairly easy to find someone if you need something.",
            ],
            &[],
        );
    }

    #[test]
    fn fix_theres_problems() {
        assert_good_and_bad_suggestions(
            "there's problems when using WSL::Ubuntu",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "there are problems when using WSL::Ubuntu",
                "there's a problem when using WSL::Ubuntu",
            ],
            &[],
        );
    }

    #[test]
    fn fix_theres_things() {
        assert_good_and_bad_suggestions(
            "If there's things you love/hate about Vidstack please let us know",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "If there are things you love/hate about Vidstack please let us know",
                "If there's a thing you love/hate about Vidstack please let us know",
            ],
            &[],
        );
    }

    #[test]
    fn fix_theres_urls() {
        assert_good_and_bad_suggestions(
            "so you're not suprised if there's urls missing or your data isn't being refreshed daily",
            ThereIsAgreement::new(FstDictionary::curated()),
            &[
                "so you're not suprised if there are urls missing or your data isn't being refreshed daily",
                "so you're not suprised if there's a url missing or your data isn't being refreshed daily",
                // "so you're not suprised if there's an url missing or your data isn't being refreshed daily",
            ],
            &[],
        );
    }

    #[test]
    fn fix_browser_console_3066() {
        assert_no_lints(
            "Finally, I’ve checked the browser’s developer console for any JavaScript errors, but there are none.",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    fn fix_there_was_none_3066() {
        assert_no_lints(
            "There were none.",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }

    #[test]
    fn fix_none_related_to_3066() {
        assert_no_lints(
            "I’ve inspected the browser console for JavaScript errors, and there are none related to WooCommerce or the product variation functionality.",
            ThereIsAgreement::new(FstDictionary::curated()),
        );
    }
}