mod gating;
mod render;
mod resolve;
mod staged;
use std::path::Path;
use tempfile::TempDir;
use crate::analysis::findings::Severity;
use crate::cli::lint_docs::{LintDocsArgs, LintOutcome, analyze};
fn repo(files: &[(&str, &str)]) -> TempDir {
let dir = TempDir::new().expect("temp dir");
for (name, content) in files {
let path = dir.path().join(name);
if let Some(parent) = path.parent() {
std::fs::create_dir_all(parent).expect("mkdir");
}
std::fs::write(&path, content).expect("write");
}
dir
}
fn run_in(root: &Path, paths: &[&str], strict: bool) -> LintOutcome {
analyze(&args_for(root, paths, strict, None), root)
}
fn run_failing_on(root: &Path, paths: &[&str], severity: Severity) -> LintOutcome {
analyze(&args_for(root, paths, false, Some(severity)), root)
}
fn args_for(root: &Path, paths: &[&str], strict: bool, fail_on: Option<Severity>) -> LintDocsArgs {
LintDocsArgs {
paths: paths.iter().map(|p| root.join(p)).collect(),
staged: false,
strict,
fail_on,
}
}
fn walk(root: &Path) -> LintOutcome {
run_in(root, &[], false)
}