Skip to main content

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
11/// Dependency vulnerability auditing via `cargo audit`.
12pub mod audit;
13/// Build verification check.
14pub mod build;
15/// Clippy lint analysis check.
16pub mod clippy;
17/// Documentation generation and coverage check.
18pub mod doc;
19/// Code formatting verification via `rustfmt`.
20pub mod format;
21/// License compliance validation.
22pub mod license;
23/// Publish readiness verification for crates.io.
24pub mod publish;
25/// Semver compatibility check for public API changes.
26pub mod semver;
27/// Ferrous Forge coding standards enforcement.
28pub mod standards;
29/// Test suite execution and result validation.
30pub mod test;
31/// Test runner infrastructure for safety checks.
32pub mod test_runner;
33
34/// Trait for implementing safety checks
35#[allow(async_fn_in_trait)]
36pub trait SafetyCheck {
37    /// Run the safety check
38    async fn run(project_path: &Path) -> Result<CheckResult>;
39
40    /// Get the name of this check
41    fn name() -> &'static str;
42
43    /// Get a description of what this check does
44    fn description() -> &'static str;
45}
46
47/// Registry of all available safety checks
48pub struct CheckRegistry;
49
50impl CheckRegistry {
51    /// Get all available check types
52    pub fn all_checks() -> Vec<super::CheckType> {
53        vec![
54            super::CheckType::Format,
55            super::CheckType::Clippy,
56            super::CheckType::Build,
57            super::CheckType::Test,
58            super::CheckType::Audit,
59            super::CheckType::Doc,
60            super::CheckType::PublishDryRun,
61            super::CheckType::Standards,
62            super::CheckType::DocCoverage,
63            super::CheckType::License,
64            super::CheckType::Semver,
65        ]
66    }
67
68    /// Get description for a check type
69    pub fn get_description(check_type: super::CheckType) -> &'static str {
70        match check_type {
71            super::CheckType::Format => "Validates code formatting with rustfmt",
72            super::CheckType::Clippy => "Runs clippy lints with strict warnings",
73            super::CheckType::Build => "Ensures project builds successfully",
74            super::CheckType::Test => "Runs the complete test suite",
75            super::CheckType::Audit => "Scans for security vulnerabilities",
76            super::CheckType::Doc => "Builds project documentation",
77            super::CheckType::PublishDryRun => "Validates crates.io publication",
78            super::CheckType::Standards => "Validates Ferrous Forge standards",
79            super::CheckType::DocCoverage => "Checks documentation coverage",
80            super::CheckType::License => "Validates license compatibility",
81            super::CheckType::Semver => "Checks semantic versioning compliance",
82        }
83    }
84}