From 9417ff71cb4f1c2ec0600f6651ca3a985736ed68 Mon Sep 17 00:00:00 2001 From: jerbly Date: Sat, 23 Mar 2024 12:21:52 -0400 Subject: [PATCH] bug fixes --- CHANGELOG.md | 5 +++++ Cargo.lock | 2 +- Cargo.toml | 2 +- src/semconv.rs | 39 ++++++++++++++++++++++++++++++++++----- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ce08e0..0a10b66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 0.4.3 + +- Fixed: "Similar" suggestions were including deprecated attributes. +- Fixed: "Extends" suggestions were not including all namespaces. + # 0.4.2 - Deprecated attributes will now show as `Bad` columns with the deprecation message. e.g. "`http.scheme` Bad - Deprecated: Replaced by `url.scheme` instead." diff --git a/Cargo.lock b/Cargo.lock index 06ada31..129dc1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -471,7 +471,7 @@ checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "honey-health" -version = "0.4.2" +version = "0.4.3" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 7aea391..0572a72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "honey-health" -version = "0.4.2" +version = "0.4.3" edition = "2021" authors = ["Jeremy Blythe "] repository = "https://github.com/jerbly/honey-health" diff --git a/src/semconv.rs b/src/semconv.rs index 363975f..717032d 100644 --- a/src/semconv.rs +++ b/src/semconv.rs @@ -199,12 +199,12 @@ impl SemanticConventions { let is_template = attribute.is_template(); if let Some(id) = &attribute.id { let attribute_name = format!("{}.{}", prefix, id); + self.insert_prefixes(&attribute_name); if is_template { self.templates.insert(attribute_name, Some(attribute)); } else { self.attribute_map.insert(attribute_name, Some(attribute)); } - self.insert_prefixes(&prefix); } } } @@ -252,12 +252,41 @@ impl SemanticConventions { fn similar(&self, input: &str) -> Option> { // See if there are some obvious similarities - let similars: Vec = self + + // Collect all the keys from the attribute_map and templates except + // those that are deprecated + let mut similars: Vec = self .attribute_map - .keys() - .filter(|&key| jaro(input, key) > 0.85) - .cloned() + .iter() + .filter_map(|(key, value)| { + if let Some(attribute) = value { + if attribute.deprecated.is_none() && (jaro(input, key) > 0.85) { + Some(key.clone()) + } else { + None + } + } else { + None + } + }) .collect(); + similars.extend( + self.templates + .iter() + .filter_map(|(key, value)| { + if let Some(attribute) = value { + if attribute.deprecated.is_none() && (jaro(input, key) > 0.85) { + Some(key.clone()) + } else { + None + } + } else { + None + } + }) + .collect::>(), + ); + if !similars.is_empty() { Some(similars) } else {