use crate::cli::commands::AnalyzeCommands;
use anyhow::Result;
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub async fn handle_defect_prediction(cmd: AnalyzeCommands) -> Result<()> {
crate::cli::handlers::route_analyze_command(cmd).await
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod property_tests {
use proptest::prelude::*;
proptest! {
#[test]
fn basic_property_stability(_input in ".*") {
prop_assert!(true);
}
#[test]
fn module_consistency_check(_x in 0u32..1000) {
prop_assert!(_x < 1001);
}
}
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod unit_tests {
use super::*;
#[test]
fn test_handle_defect_prediction_signature() {
let _fn_ref: fn(AnalyzeCommands) -> _ = handle_defect_prediction;
}
#[test]
fn test_module_exports_handler() {
fn _verify_export() {
let _defect_prediction: fn(AnalyzeCommands) -> _ = handle_defect_prediction;
}
}
#[test]
fn test_result_type_compatibility() {
fn _check_result_type() -> Result<()> {
Ok(())
}
assert!(_check_result_type().is_ok());
}
#[test]
fn test_handler_is_async() {
fn _verify_async_nature() {
}
}
#[test]
fn test_module_organization() {
assert!(true); }
#[test]
fn test_handler_delegates_pattern() {
assert!(true); }
#[test]
fn test_module_documentation() {
assert!(true); }
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod coverage_tests {
use super::*;
use crate::cli::enums::DefectPredictionOutputFormat;
use std::path::PathBuf;
#[tokio::test]
async fn test_handle_defect_prediction_basic() {
let cmd = AnalyzeCommands::DefectPrediction {
path: PathBuf::from("/nonexistent/path/for/defect/test"),
project_path: None,
confidence_threshold: 0.5,
min_lines: 10,
include_low_confidence: false,
format: DefectPredictionOutputFormat::Summary,
high_risk_only: false,
include_recommendations: false,
include: None,
exclude: None,
output: None,
perf: false,
top_files: 10,
};
let result = handle_defect_prediction(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[tokio::test]
async fn test_handle_defect_prediction_high_risk_with_recommendations() {
let cmd = AnalyzeCommands::DefectPrediction {
path: PathBuf::from("/tmp/test-defect"),
project_path: None,
confidence_threshold: 0.7,
min_lines: 5,
include_low_confidence: false,
format: DefectPredictionOutputFormat::Json,
high_risk_only: true,
include_recommendations: true,
include: Some("**/*.rs".to_string()),
exclude: Some("**/target/**".to_string()),
output: Some(PathBuf::from("/tmp/defect-output.json")),
perf: true,
top_files: 5,
};
let result = handle_defect_prediction(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[tokio::test]
async fn test_handle_defect_prediction_include_low_confidence() {
let cmd = AnalyzeCommands::DefectPrediction {
path: PathBuf::from("/nonexistent"),
project_path: None,
confidence_threshold: 0.3,
min_lines: 20,
include_low_confidence: true,
format: DefectPredictionOutputFormat::Detailed,
high_risk_only: false,
include_recommendations: true,
include: None,
exclude: None,
output: None,
perf: false,
top_files: 20,
};
let result = handle_defect_prediction(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[tokio::test]
async fn test_handle_defect_prediction_markdown() {
let cmd = AnalyzeCommands::DefectPrediction {
path: PathBuf::from("/tmp/test-defect-md"),
project_path: None,
confidence_threshold: 0.5,
min_lines: 10,
include_low_confidence: false,
format: DefectPredictionOutputFormat::Detailed,
high_risk_only: false,
include_recommendations: false,
include: None,
exclude: Some("tests/**".to_string()),
output: Some(PathBuf::from("/tmp/defect-report.md")),
perf: false,
top_files: 0,
};
let result = handle_defect_prediction(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[test]
fn test_handler_function_signature() {
let _: fn(AnalyzeCommands) -> _ = handle_defect_prediction;
}
}