//! Report generation for scan results.
// Skeleton phase: allow unused until report pipeline is wired up
#![allow(dead_code)]
//!
//! Supports multiple output formats:
//! - `table`: Terminal table output (default)
//! - `json`: JSON for programmatic consumption
//! - `sarif`: SARIF for CI integration (GitHub, GitLab, Azure DevOps)
//! - `markdown`: Markdown for documentation

mod json;
mod markdown;
mod sarif;
mod table;

pub use json::JsonReport;
pub use markdown::MarkdownReport;
pub use sarif::SarifReport;
pub use table::TableReport;

use crate::types::ScanResult;

/// Trait for report formatters.
pub trait ReportFormatter {
    /// Format the scan result as a string.
    fn format(&self, result: &ScanResult) -> String;
}

/// Get a report formatter by name.
pub fn get_formatter(name: &str) -> Box<dyn ReportFormatter> {
    match name {
        "json" => Box::new(JsonReport),
        "sarif" => Box::new(SarifReport),
        "markdown" => Box::new(MarkdownReport),
        _ => Box::new(TableReport),
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use std::path::PathBuf;

    #[test]
    fn test_get_formatter_table() {
        let formatter = get_formatter("table");
        let result = ScanResult::stub(&PathBuf::from("."), "table");
        let output = formatter.format(&result);
        assert!(output.contains("Scanning"));
    }

    #[test]
    fn test_get_formatter_unknown_defaults_to_table() {
        let formatter = get_formatter("unknown");
        let result = ScanResult::stub(&PathBuf::from("."), "table");
        let output = formatter.format(&result);
        assert!(output.contains("Scanning"));
    }
}
