Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jerbly committed Mar 23, 2024
1 parent d9817c8 commit 9417ff7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "honey-health"
version = "0.4.2"
version = "0.4.3"
edition = "2021"
authors = ["Jeremy Blythe <[email protected]>"]
repository = "https://github.com/jerbly/honey-health"
Expand Down
39 changes: 34 additions & 5 deletions src/semconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -252,12 +252,41 @@ impl SemanticConventions {

fn similar(&self, input: &str) -> Option<Vec<String>> {
// See if there are some obvious similarities
let similars: Vec<String> = self

// Collect all the keys from the attribute_map and templates except
// those that are deprecated
let mut similars: Vec<String> = 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::<Vec<String>>(),
);

if !similars.is_empty() {
Some(similars)
} else {
Expand Down

0 comments on commit 9417ff7

Please sign in to comment.