From 5006491c45a902fa47da596f81d541d20d74300b Mon Sep 17 00:00:00 2001 From: Ben-PH Date: Tue, 29 Oct 2024 08:54:38 +0100 Subject: [PATCH] Initial #107 work --- src/problem/mod.rs | 5 +++++ src/problem/npv_170.rs | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/problem/npv_170.rs 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"# + ) + } +}