diff --git a/crates/spk-schema/src/build_spec.rs b/crates/spk-schema/src/build_spec.rs index c16c6c402..b8031599d 100644 --- a/crates/spk-schema/src/build_spec.rs +++ b/crates/spk-schema/src/build_spec.rs @@ -507,7 +507,7 @@ impl<'de> serde::de::Visitor<'de> for BuildSpecVisitor { "auto_host_vars" => unchecked.auto_host_vars = map.next_value::()?, unknown_key => { self.lints.push(Lint::Key(UnknownKey::new( - unknown_key, + &format!("build.{unknown_key}"), BuildSpec::FIELD_NAMES_AS_ARRAY.to_vec(), ))); map.next_value::()?; diff --git a/crates/spk-schema/src/environ.rs b/crates/spk-schema/src/environ.rs index 385f02675..d01933352 100644 --- a/crates/spk-schema/src/environ.rs +++ b/crates/spk-schema/src/environ.rs @@ -526,4 +526,4 @@ impl SetEnv { pub fn tcsh_source(&self) -> String { format!("setenv {} \"{}\"", self.set, self.value) } -} \ No newline at end of file +} diff --git a/crates/spk-schema/src/install_spec.rs b/crates/spk-schema/src/install_spec.rs index 66143bdfa..37eda5588 100644 --- a/crates/spk-schema/src/install_spec.rs +++ b/crates/spk-schema/src/install_spec.rs @@ -6,10 +6,10 @@ use std::marker::PhantomData; use serde::{Deserialize, Serialize}; use spk_schema_foundation::ident_component::Component; +use spk_schema_foundation::option_map::Stringified; use spk_schema_foundation::spec_ops::Named; use spk_schema_foundation::IsDefault; use spk_schema_ident::{BuildIdent, OptVersionIdent}; -use spk_schema_foundation::option_map::Stringified; use struct_field_names_as_array::FieldNamesAsArray; use crate::component_embedded_packages::ComponentEmbeddedPackage; @@ -19,8 +19,8 @@ use crate::{ EmbeddedPackagesList, EnvOp, EnvOpList, - LintedItem, Lint, + LintedItem, Lints, OpKind, Package, @@ -271,7 +271,6 @@ where deserializer.deserialize_seq(EnvConfVisitor) } - impl<'de, D> serde::de::Visitor<'de> for InstallSpecVisitor where D: Default + From>, @@ -279,7 +278,7 @@ where type Value = D; fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str("a package specification") + f.write_str("an install spec") } fn visit_map(mut self, mut map: A) -> std::result::Result @@ -294,7 +293,7 @@ where "environment" => self.environment = map.next_value::()?, unknown_key => { self.lints.push(Lint::Key(UnknownKey::new( - unknown_key, + &format!("install.{unknown_key}"), InstallSpecVisitor::::FIELD_NAMES_AS_ARRAY.to_vec(), ))); map.next_value::()?; diff --git a/crates/spk-schema/src/lints.rs b/crates/spk-schema/src/lints.rs index cae7221d2..b64dc5073 100644 --- a/crates/spk-schema/src/lints.rs +++ b/crates/spk-schema/src/lints.rs @@ -21,6 +21,7 @@ impl UnknownKey { } pub fn generate_message(&self) -> String { + let key: &str = self.unknown_key.split('.').last().unwrap_or_default(); let mut message = format!("Unrecognized key: {}. ", self.unknown_key); let mut corpus = CorpusBuilder::new().finish(); @@ -28,10 +29,9 @@ impl UnknownKey { corpus.add_text(field); } - match corpus.search(&self.unknown_key, 0.6).first() { + match corpus.search(key, 0.6).first() { Some(s) => message.push_str(format!("(Did you mean: '{}'?)", s.text).as_str()), - None => message - .push_str(format!("(No similar keys found for: {}.)", self.unknown_key).as_str()), + None => message.push_str(format!("(No similar keys found for: {}.)", key).as_str()), }; message.to_string() diff --git a/crates/spk-schema/src/metadata/meta.rs b/crates/spk-schema/src/metadata/meta.rs index f43d0eed8..7704f0cf4 100644 --- a/crates/spk-schema/src/metadata/meta.rs +++ b/crates/spk-schema/src/metadata/meta.rs @@ -7,8 +7,8 @@ use std::process::{Command, Stdio}; use serde::{Deserialize, Serialize}; use spk_config::Metadata; -use spk_schema_foundation::IsDefault; use spk_schema_foundation::option_map::Stringified; +use spk_schema_foundation::IsDefault; use struct_field_names_as_array::FieldNamesAsArray; use crate::{Error, Lint, LintedItem, Lints, Result, UnknownKey}; @@ -153,7 +153,7 @@ impl<'de> serde::de::Visitor<'de> for MetaVisitor { "labels" => self.labels = Some(map.next_value::>()?), unknown_key => { self.lints.push(Lint::Key(UnknownKey::new( - unknown_key, + &format!("meta.{unknown_key}"), MetaVisitor::FIELD_NAMES_AS_ARRAY.to_vec(), ))); map.next_value::()?; diff --git a/crates/spk-schema/src/option.rs b/crates/spk-schema/src/option.rs index 995ff94a8..13cc6c786 100644 --- a/crates/spk-schema/src/option.rs +++ b/crates/spk-schema/src/option.rs @@ -328,7 +328,7 @@ impl<'de> serde::de::Visitor<'de> for UncheckedOptVisitor { } unknown_key => { self.lints.push(Lint::Key(UnknownKey::new( - unknown_key, + &format!("options.{unknown_key}"), UncheckedOptVisitor::FIELD_NAMES_AS_ARRAY.to_vec(), ))); map.next_value::()?; diff --git a/crates/spk-schema/src/source_spec.rs b/crates/spk-schema/src/source_spec.rs index dcb7cd5dd..da16a493b 100644 --- a/crates/spk-schema/src/source_spec.rs +++ b/crates/spk-schema/src/source_spec.rs @@ -175,7 +175,7 @@ impl<'de> serde::de::Visitor<'de> for SourceSpecVisitor { "subdir" => self.subdir = Some(map.next_value::()?.0), unknown_key => { self.lints.push(Lint::Key(UnknownKey::new( - unknown_key, + &format!("sources.{unknown_key}"), SourceSpecVisitor::FIELD_NAMES_AS_ARRAY.to_vec(), ))); map.next_value::()?; diff --git a/crates/spk-schema/src/v0/test_spec.rs b/crates/spk-schema/src/v0/test_spec.rs index 88c58c375..5d6da0efe 100644 --- a/crates/spk-schema/src/v0/test_spec.rs +++ b/crates/spk-schema/src/v0/test_spec.rs @@ -3,8 +3,8 @@ // https://github.com/spkenv/spk use serde::{Deserialize, Serialize}; -use spk_schema_ident::{RequestedBy, VersionIdent}; use spk_schema_foundation::option_map::Stringified; +use spk_schema_ident::{RequestedBy, VersionIdent}; use struct_field_names_as_array::FieldNamesAsArray; use crate::ident::Request; @@ -124,7 +124,7 @@ impl<'de> serde::de::Visitor<'de> for TestSpecVisitor { "requirements" => self.requirements = map.next_value::>()?, unknown_key => { self.lints.push(Lint::Key(UnknownKey::new( - unknown_key, + &format!("sources.{unknown_key}"), TestSpecVisitor::FIELD_NAMES_AS_ARRAY.to_vec(), ))); map.next_value::()?;