Skip to content

Commit

Permalink
Initial NixOS#107 work
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-PH committed Oct 29, 2024
1 parent 02db8e4 commit 5006491
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/problem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
19 changes: 19 additions & 0 deletions src/problem/npv_170.rs
Original file line number Diff line number Diff line change
@@ -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"#
)
}
}

0 comments on commit 5006491

Please sign in to comment.