Skip to content

Commit 2df3f80

Browse files
author
Nichol Yip
committed
Implemented lint feature for EnvOp and TestSpec
Signed-off-by: Nichol Yip <[email protected]>
1 parent 58278c8 commit 2df3f80

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

crates/spk-schema/src/environ.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub enum OpKind {
3939
}
4040

4141
/// An operation performed to the environment
42-
#[derive(Clone, Debug, Eq, Hash, Lint, Ord, PartialEq, PartialOrd, Serialize)]
42+
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
4343
#[serde(untagged)]
4444
pub enum EnvOp {
4545
Append(AppendEnv),
@@ -367,7 +367,7 @@ impl<'de> serde::de::Visitor<'de> for EnvOpVisitor {
367367
///
368368
/// The separator used defaults to the path separator for the current
369369
/// host operating system (':' for unix, ';' for windows)
370-
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
370+
#[derive(Clone, Debug, Eq, Hash, Lint, Ord, PartialEq, PartialOrd, Serialize)]
371371
pub struct AppendEnv {
372372
pub append: String,
373373
pub value: String,
@@ -456,7 +456,7 @@ impl EnvPriority {
456456
///
457457
/// The separator used defaults to the path separator for the current
458458
/// host operating system (':' for unix, ';' for windows)
459-
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
459+
#[derive(Clone, Debug, Eq, Hash, Lint, Ord, PartialEq, PartialOrd, Serialize)]
460460
pub struct PrependEnv {
461461
pub prepend: String,
462462
pub value: String,
@@ -502,7 +502,7 @@ impl PrependEnv {
502502
}
503503

504504
/// Operates on an environment variable by setting it to a value
505-
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
505+
#[derive(Clone, Debug, Eq, Hash, Lint, Ord, PartialEq, PartialOrd, Serialize)]
506506
pub struct SetEnv {
507507
pub set: String,
508508
pub value: String,

crates/spk-schema/src/install_spec.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ where
3636
D: Default,
3737
{
3838
fn lints(&mut self) -> Vec<String> {
39-
// for env in self.environment.iter_mut() {
40-
// self.lints.extend(std::mem::take(&mut env.lints));
41-
// }
39+
for env in self.environment.iter_mut() {
40+
self.lints.extend(std::mem::take(
41+
&mut env.lints.iter().map(|l| env.item.lints(l)).collect_vec(),
42+
));
43+
}
44+
4245
std::mem::take(&mut self.lints)
4346
}
4447
}

crates/spk-schema/src/v0/spec.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,13 @@ impl<B, T> Lints for SpecVisitor<B, T> {
11131113

11141114
if let Some(tests) = self.tests.as_mut() {
11151115
for test in tests.iter_mut() {
1116-
lint_messages.extend(std::mem::take(&mut test.lints));
1116+
lint_messages.extend(std::mem::take(
1117+
&mut test
1118+
.lints
1119+
.iter()
1120+
.map(|l| test.item.generate_lints(l))
1121+
.collect_vec(),
1122+
));
11171123
}
11181124
}
11191125

crates/spk-schema/src/v0/test_spec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl<'de> serde::de::Visitor<'de> for TestSpecVisitor {
102102
"selectors" => self.selectors = map.next_value::<Vec<OptionMap>>()?,
103103
"requirements" => self.requirements = map.next_value::<Vec<Request>>()?,
104104
unknown_key => {
105-
// self.lints.push(self.generate_lints(unknown_key));
105+
self.lints.push(unknown_key.to_string());
106106
map.next_value::<serde::de::IgnoredAny>()?;
107107
}
108108
}

0 commit comments

Comments
 (0)