From de9928a5f813f2e450c1fbd14f0067ed8bddfacb Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 25 Jul 2024 09:14:30 -0500 Subject: [PATCH 1/2] test: Show countr behavior --- .../typos-cli/tests/cmd/false-positives.in/sample.cpp | 5 +++++ crates/typos-cli/tests/cmd/false-positives.toml | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 crates/typos-cli/tests/cmd/false-positives.in/sample.cpp diff --git a/crates/typos-cli/tests/cmd/false-positives.in/sample.cpp b/crates/typos-cli/tests/cmd/false-positives.in/sample.cpp new file mode 100644 index 0000000..40455b1 --- /dev/null +++ b/crates/typos-cli/tests/cmd/false-positives.in/sample.cpp @@ -0,0 +1,5 @@ +int main() { + uint8 i = 0; + std::countr_one(i); + return 0; +} diff --git a/crates/typos-cli/tests/cmd/false-positives.toml b/crates/typos-cli/tests/cmd/false-positives.toml index 324f41d..0df3d54 100644 --- a/crates/typos-cli/tests/cmd/false-positives.toml +++ b/crates/typos-cli/tests/cmd/false-positives.toml @@ -1,4 +1,12 @@ bin.name = "typos" stdin = "" -stdout = "" +stdout = """ +error: `countr` should be `counter`, `contour`, `country`, `county` + --> ./sample.cpp:3:10 + | +3 | std::countr_one(i); + | ^^^^^^ + | +""" stderr = "" +status.code = 2 From 5aa093dc25a6037583cf992a771e9ad099ac678a Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 25 Jul 2024 09:15:16 -0500 Subject: [PATCH 2/2] fix(dict): Don't correct countr_one Fixes #1061 --- crates/typos-cli/src/file_type_specifics.rs | 9 +++++++++ crates/typos-cli/tests/cmd/false-positives.toml | 10 +--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/crates/typos-cli/src/file_type_specifics.rs b/crates/typos-cli/src/file_type_specifics.rs index c93ab34..00fe1a9 100644 --- a/crates/typos-cli/src/file_type_specifics.rs +++ b/crates/typos-cli/src/file_type_specifics.rs @@ -7,6 +7,15 @@ pub(crate) const NO_CHECK_TYPES: &[&str] = &["cert", "lock"]; pub(crate) const TYPE_SPECIFIC_DICTS: &[(&str, StaticDictConfig)] = &[ + ( + "cpp", + StaticDictConfig { + ignore_idents: &[ + "countr_one", // `std::countr_one` + ], + ignore_words: &[], + }, + ), ( "css", StaticDictConfig { diff --git a/crates/typos-cli/tests/cmd/false-positives.toml b/crates/typos-cli/tests/cmd/false-positives.toml index 0df3d54..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: `countr` should be `counter`, `contour`, `country`, `county` - --> ./sample.cpp:3:10 - | -3 | std::countr_one(i); - | ^^^^^^ - | -""" +stdout = "" stderr = "" -status.code = 2