Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: warn user when unused features are defined #762

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/project/manifest/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ impl ProjectManifest {
}
}

// Check if all features are used in environments, warn if not.
let mut features_used = HashSet::new();
for env in self.environments.values() {
for feature in env.features.iter() {
features_used.insert(feature);
}
}
for (name, _feature) in self.features.iter() {
if name != &FeatureName::Default && !features_used.contains(&name.to_string()) {
tracing::warn!(
"The feature '{}' is defined but not used in any environment",
console::style(name).bold().blue()
);
}
}

// parse the SPDX license expression to make sure that it is a valid expression.
if let Some(spdx_expr) = &self.project.license {
spdx::Expression::parse(spdx_expr)
Expand Down
Loading