mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-22 00:51:11 -05:00
test(dict): Report more cases to user
This commit is contained in:
parent
09f096a096
commit
a9d9fc03a2
1 changed files with 12 additions and 3 deletions
|
@ -91,11 +91,20 @@ fn generate<W: std::io::Write>(file: &mut W, dict: &[u8]) {
|
||||||
current.extend(good);
|
current.extend(good);
|
||||||
}
|
}
|
||||||
|
|
||||||
let corrections: std::collections::HashSet<_> =
|
let corrections: HashMap<_, _> = dict
|
||||||
dict.values().flatten().map(ToOwned::to_owned).collect();
|
.iter()
|
||||||
|
.flat_map(|(bad, good)| good.iter().map(|good| (good.to_owned(), bad.to_owned())))
|
||||||
|
.collect();
|
||||||
let rows: Vec<_> = dict
|
let rows: Vec<_> = dict
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|(typo, _)| !corrections.contains(typo.as_str()))
|
.filter(|(typo, _)| {
|
||||||
|
if let Some(correction) = corrections.get(typo.as_str()) {
|
||||||
|
eprintln!("{typo} <-> {correction} cycle detected");
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut wtr = csv::WriterBuilder::new().flexible(true).from_writer(file);
|
let mut wtr = csv::WriterBuilder::new().flexible(true).from_writer(file);
|
||||||
|
|
Loading…
Reference in a new issue