diff --git a/src/problem/mod.rs b/src/problem/mod.rs index 981c0ea..0550903 100644 --- a/src/problem/mod.rs +++ b/src/problem/mod.rs @@ -34,6 +34,8 @@ pub mod npv_161; pub mod npv_162; pub mod npv_163; +pub mod npv_170; + #[derive(Clone, Display, EnumFrom)] pub enum Problem { /// NPV-100: attribute is not defined but it should be defined automatically @@ -123,6 +125,9 @@ pub enum Problem { NewTopLevelPackageShouldBeByNameWithCustomArgument( npv_163::NewTopLevelPackageShouldBeByNameWithCustomArgument, ), + + /// NPV-170: by-name package cannot be number prefixed + ByNamePackegPrefixedWithNumber(npv_170::ByNamePackegPrefixedWithNumber), } fn indent_definition(column: usize, definition: &str) -> String { diff --git a/src/problem/npv_170.rs b/src/problem/npv_170.rs new file mode 100644 index 0000000..61d4dcb --- /dev/null +++ b/src/problem/npv_170.rs @@ -0,0 +1,19 @@ +use std::fmt; + +use derive_new::new; + +#[derive(Clone, new)] +pub struct ByNamePackegPrefixedWithNumber { + #[new(into)] + attribute_name: String, +} + +impl fmt::Display for ByNamePackegPrefixedWithNumber { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let Self { attribute_name } = self; + write!( + f, + r#"- pkgs.{attribute_name}: "Attribute names should not be number-prefixed. It is suggestet to `"`-wrap this name"# + ) + } +}