From 5fd0df28816209a5c3f67eefb1920b77d6ab5951 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 25 Sep 2023 12:50:07 -0500 Subject: [PATCH] fix(cli): Dont correct O_WRONLY Realized we could just hard code this for now rather creating a general identifier dictionary. Fixes #744 --- crates/typos-cli/src/dict.rs | 7 +++++-- crates/typos-cli/tests/cmd/false-positives.toml | 10 +--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/crates/typos-cli/src/dict.rs b/crates/typos-cli/src/dict.rs index 33ea70d..7f09952 100644 --- a/crates/typos-cli/src/dict.rs +++ b/crates/typos-cli/src/dict.rs @@ -51,8 +51,11 @@ impl BuiltIn { #[cfg(feature = "dict")] impl BuiltIn { - fn correct_ident_with_dict<'s>(&self, _ident: &str) -> Option> { - None + fn correct_ident_with_dict<'s>(&self, ident: &str) -> Option> { + match ident { + "O_WRONLY" => Some(Status::Valid), + _ => None, + } } // Not using `Status` to avoid the allocations diff --git a/crates/typos-cli/tests/cmd/false-positives.toml b/crates/typos-cli/tests/cmd/false-positives.toml index a582f88..324f41d 100644 --- a/crates/typos-cli/tests/cmd/false-positives.toml +++ b/crates/typos-cli/tests/cmd/false-positives.toml @@ -1,12 +1,4 @@ bin.name = "typos" stdin = "" -stdout = """ -error: `WRONLY` should be `WRONGLY` - --> ./sample.py:5:12 - | -5 | print(os.O_WRONLY) # should work - | ^^^^^^ - | -""" +stdout = "" stderr = "" -status.code = 2