diff --git a/src/problem/npv_170.rs b/src/problem/npv_170.rs index 61d4dcb..6614951 100644 --- a/src/problem/npv_170.rs +++ b/src/problem/npv_170.rs @@ -1,19 +1,25 @@ use std::fmt; use derive_new::new; +use relative_path::RelativePathBuf; #[derive(Clone, new)] pub struct ByNamePackegPrefixedWithNumber { #[new(into)] - attribute_name: String, + package_name: String, + #[new(into)] + relative_package_dir: RelativePathBuf, } impl fmt::Display for ByNamePackegPrefixedWithNumber { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let Self { attribute_name } = self; + let Self { + package_name, + relative_package_dir, + } = self; write!( f, - r#"- pkgs.{attribute_name}: "Attribute names should not be number-prefixed. It is suggestet to `"`-wrap this name"# + r#"- {relative_package_dir}: Attribute `{package_name}` should not be number-prefixed. It is suggestet to `"`-wrap this name"# ) } } diff --git a/src/structure.rs b/src/structure.rs index c7996f1..5e19da8 100644 --- a/src/structure.rs +++ b/src/structure.rs @@ -145,12 +145,17 @@ fn check_package( .next() .is_some_and(|c| c.is_ascii_digit()) { - npv_170::ByNamePackegPrefixedWithNumber::new(package_name.clone()).into() + npv_170::ByNamePackegPrefixedWithNumber::new( + package_name.clone(), + relative_package_dir.clone(), + ) + .into() } else { npv_141::InvalidPackageDirectoryName::new( package_name.clone(), relative_package_dir.clone(), - ).into() + ) + .into() } } else { Success(()) diff --git a/tests/by-name-numprefix/expected b/tests/by-name-numprefix/expected index e76e502..1e4daf6 100644 --- a/tests/by-name-numprefix/expected +++ b/tests/by-name-numprefix/expected @@ -1,4 +1,4 @@ trace: This should be on stderr! @REDACTED@error: This is an error!@REDACTED@ -- Nix evaluation failed for some package in `pkgs/by-name`, see error above +- pkgs/by-name/_1/10foo: Attribute `10foo` should not be number-prefixed. It is suggestet to `"`-wrap this name This PR introduces the problems listed above. Please fix them before merging, otherwise the base branch would break.