ferrous_forge/safety/checks/
mod.rs

1//! Safety check implementations
2//!
3//! This module contains individual check implementations for the safety pipeline.
4//! Each check module implements a specific validation (format, clippy, tests, etc.)
5
6use crate::Result;
7use std::path::Path;
8
9use super::report::CheckResult;
10
11pub mod audit;
12pub mod build;
13pub mod clippy;
14pub mod doc;
15pub mod format;
16pub mod license;
17pub mod publish;
18pub mod semver;
19pub mod standards;
20pub mod test;
21pub mod test_runner;
22
23/// Trait for implementing safety checks
24#[allow(async_fn_in_trait)]
25pub trait SafetyCheck {
26    /// Run the safety check
27    async fn run(project_path: &Path) -> Result<CheckResult>;
28
29    /// Get the name of this check
30    fn name() -> &'static str;
31
32    /// Get a description of what this check does
33    fn description() -> &'static str;
34}
35
36/// Registry of all available safety checks
37pub struct CheckRegistry;
38
39impl CheckRegistry {
40    /// Get all available check types
41    pub fn all_checks() -> Vec<super::CheckType> {
42        vec![
43            super::CheckType::Format,
44            super::CheckType::Clippy,
45            super::CheckType::Build,
46            super::CheckType::Test,
47            super::CheckType::Audit,
48            super::CheckType::Doc,
49            super::CheckType::PublishDryRun,
50            super::CheckType::Standards,
51            super::CheckType::DocCoverage,
52            super::CheckType::License,
53            super::CheckType::Semver,
54        ]
55    }
56
57    /// Get description for a check type
58    pub fn get_description(check_type: super::CheckType) -> &'static str {
59        match check_type {
60            super::CheckType::Format => "Validates code formatting with rustfmt",
61            super::CheckType::Clippy => "Runs clippy lints with strict warnings",
62            super::CheckType::Build => "Ensures project builds successfully",
63            super::CheckType::Test => "Runs the complete test suite",
64            super::CheckType::Audit => "Scans for security vulnerabilities",
65            super::CheckType::Doc => "Builds project documentation",
66            super::CheckType::PublishDryRun => "Validates crates.io publication",
67            super::CheckType::Standards => "Validates Ferrous Forge standards",
68            super::CheckType::DocCoverage => "Checks documentation coverage",
69            super::CheckType::License => "Validates license compatibility",
70            super::CheckType::Semver => "Checks semantic versioning compliance",
71        }
72    }
73}