code_passenger 0.4.8

Scans a Rust workspace with klepto and does the writing: feature gates across every crate from one features document, proven by cargo check, Cargo.toml edits, file headers from the plan, and the history of it.
Documentation
//! `lint` (rule R2 in `GATE_RULES.md`).

use crate::commands::klepto_for;
use crate::error::{PassengerError, Result};
use klepto::{run_pipeline, Policy, Verdict};
use std::path::Path;

/// Rule R2: the policy used when none is given.
pub const DEFAULT_POLICY: &str = "[levels]\nKLEP010 = \"deny\"\nKLEP011 = \"deny\"\nKLEP001 = \"allow\"\nKLEP012 = \"allow\"\n";

/// Rule R2.
pub fn run(root: &Path, policy: Option<&Path>) -> Result<Verdict> {
    let text = match policy {
        Some(p) => std::fs::read_to_string(p)?,
        None => DEFAULT_POLICY.to_string(),
    };
    let policy = Policy::parse(&text).map_err(|e| PassengerError::unsupported(e.to_string()))?;
    let k = klepto_for(root)?;
    Ok(run_pipeline(&k, &policy))
}