From 83dc9dcb5f1f72a6db075e125f8b9cb92fa06204 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Sat, 23 Oct 2021 09:24:05 -0500 Subject: [PATCH 1/4] fix(config): Overlay default/overrides with type-config --- src/policy.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/policy.rs b/src/policy.rs index 5c85e83..87787c8 100644 --- a/src/policy.rs +++ b/src/policy.rs @@ -194,7 +194,11 @@ impl<'s> ConfigEngine<'s> { } } - let type_config = self.init_file_config(type_engine.engine); + let mut engine = default.clone(); + engine.update(&type_engine.engine); + engine.update(&overrides); + + let type_config = self.init_file_config(engine); types.insert(type_name, type_config); } default.update(&overrides); From 29ebe5ab48cc9841293e4ad28d0dba5f55c5f123 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Sat, 23 Oct 2021 08:42:21 -0500 Subject: [PATCH 2/4] fix(config): Skip lock files by default Part of #362 --- src/config.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/config.rs b/src/config.rs index 2a21607..f400e7c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -167,6 +167,15 @@ impl TypeEngineConfig { pub fn patterns(&self) -> impl Iterator { let mut patterns = self.patterns.clone(); + patterns + .entry("lock".into()) + .or_insert_with(|| GlobEngineConfig { + extend_glob: Vec::new(), + engine: EngineConfig { + check_file: Some(false), + ..Default::default() + }, + }); patterns.entry("cert".into()).or_insert_with(|| { GlobEngineConfig { extend_glob: vec![ From b7812e616c101ce0f979be62c6d601dddc212b3f Mon Sep 17 00:00:00 2001 From: Ed Page Date: Sat, 23 Oct 2021 08:42:30 -0500 Subject: [PATCH 3/4] fix(config): Check project files with language For `rg`, keeping the file types strict makes sense, For spell checking, `Cargo.toml` is a lot more closely related in handling to `*.rs` than it is to `pyproject.toml` due to ecosystem package names. Part of #362 --- src/config.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/config.rs b/src/config.rs index f400e7c..6fcf1e7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -176,6 +176,24 @@ impl TypeEngineConfig { ..Default::default() }, }); + patterns + .entry("rust".into()) + .or_insert_with(|| GlobEngineConfig { + // From a spell-check perspective, these are more closely related to Rust than Toml + extend_glob: vec!["Cargo.toml".into()], + engine: EngineConfig { + ..Default::default() + }, + }); + patterns + .entry("python".into()) + .or_insert_with(|| GlobEngineConfig { + // From a spell-check perspective, these are more closely related to Python than Toml + extend_glob: vec!["pyproject.toml".into()], + engine: EngineConfig { + ..Default::default() + }, + }); patterns.entry("cert".into()).or_insert_with(|| { GlobEngineConfig { extend_glob: vec![ From 1046b892089884c5f8c26a6a34a8a2a7dff82664 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Sat, 23 Oct 2021 08:58:13 -0500 Subject: [PATCH 4/4] fix(config): Avoid correcting Rust names Part of #362 --- Cargo.toml | 2 +- src/config.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 47422a9..3e266fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,13 +87,13 @@ serde_json = "1.0" encoding = "0.2" kstring = "1.0" typed-arena = "2.0.1" +maplit = "1.0" [dev-dependencies] assert_fs = "1.0" assert_cmd = "2.0" predicates = "2.0" criterion = "0.3" -maplit = "1.0" [profile.dev] panic = "abort" diff --git a/src/config.rs b/src/config.rs index 6fcf1e7..ae099da 100644 --- a/src/config.rs +++ b/src/config.rs @@ -182,6 +182,13 @@ impl TypeEngineConfig { // From a spell-check perspective, these are more closely related to Rust than Toml extend_glob: vec!["Cargo.toml".into()], engine: EngineConfig { + dict: Some(DictConfig { + extend_words: maplit::hashmap! { + "flate".into() => "flate".into(), + "ser".into() => "ser".into(), + }, + ..Default::default() + }), ..Default::default() }, });