use crate::cli::commands::AnalyzeCommands;
use anyhow::Result;
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub async fn handle_duplicates(cmd: AnalyzeCommands) -> Result<()> {
crate::cli::handlers::route_analyze_command(cmd).await
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub async fn handle_name_similarity(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_duplicates_signature() {
let _fn_ref: fn(AnalyzeCommands) -> _ = handle_duplicates;
}
#[test]
fn test_handle_name_similarity_signature() {
let _fn_ref: fn(AnalyzeCommands) -> _ = handle_name_similarity;
}
#[test]
fn test_module_exports_all_handlers() {
fn _verify_exports() {
let _duplicates: fn(AnalyzeCommands) -> _ = handle_duplicates;
let _name_similarity: fn(AnalyzeCommands) -> _ = handle_name_similarity;
}
}
#[test]
fn test_result_type_compatibility() {
fn _check_result_type() -> Result<()> {
Ok(())
}
assert!(_check_result_type().is_ok());
}
#[test]
fn test_handlers_are_async() {
fn _verify_async_duplicates() {
}
fn _verify_async_name_similarity() {
}
}
#[test]
fn test_module_organization() {
assert!(true); }
#[test]
fn test_handlers_delegate_pattern() {
assert!(true); }
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod coverage_tests {
use super::*;
use crate::cli::enums::{DuplicateOutputFormat, DuplicateType};
use std::path::PathBuf;
#[tokio::test]
async fn test_handle_duplicates_basic() {
let cmd = AnalyzeCommands::Duplicates {
path: PathBuf::from("/nonexistent/path/for/dup/test"),
project_path: None,
detection_type: DuplicateType::All,
threshold: 0.85,
min_lines: 5,
max_tokens: 128,
format: DuplicateOutputFormat::Summary,
perf: false,
include: None,
exclude: None,
output: None,
top_files: 10,
};
let result = handle_duplicates(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[tokio::test]
async fn test_handle_duplicates_exact_with_filters() {
let cmd = AnalyzeCommands::Duplicates {
path: PathBuf::from("/tmp/test-dup"),
project_path: None,
detection_type: DuplicateType::Exact,
threshold: 0.9,
min_lines: 3,
max_tokens: 256,
format: DuplicateOutputFormat::Json,
perf: true,
include: Some("**/*.rs".to_string()),
exclude: Some("**/target/**".to_string()),
output: Some(PathBuf::from("/tmp/dup-output.json")),
top_files: 5,
};
let result = handle_duplicates(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[tokio::test]
async fn test_handle_duplicates_semantic() {
let cmd = AnalyzeCommands::Duplicates {
path: PathBuf::from("/nonexistent"),
project_path: None,
detection_type: DuplicateType::Semantic,
threshold: 0.75,
min_lines: 10,
max_tokens: 64,
format: DuplicateOutputFormat::Detailed,
perf: false,
include: None,
exclude: None,
output: None,
top_files: 20,
};
let result = handle_duplicates(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[tokio::test]
async fn test_handle_name_similarity_basic() {
use crate::cli::enums::{NameSimilarityOutputFormat, SearchScope};
let cmd = AnalyzeCommands::NameSimilarity {
path: PathBuf::from("/nonexistent/path/for/name/test"),
project_path: None,
query: "handle_request".to_string(),
top_k: 10,
phonetic: false,
scope: SearchScope::All,
threshold: 0.3,
format: NameSimilarityOutputFormat::Summary,
include: None,
exclude: None,
output: None,
perf: false,
fuzzy: false,
case_sensitive: false,
};
let result = handle_name_similarity(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[tokio::test]
async fn test_handle_name_similarity_phonetic_fuzzy() {
use crate::cli::enums::{NameSimilarityOutputFormat, SearchScope};
let cmd = AnalyzeCommands::NameSimilarity {
path: PathBuf::from("/tmp/test-similarity"),
project_path: None,
query: "processData".to_string(),
top_k: 20,
phonetic: true,
scope: SearchScope::Functions,
threshold: 0.5,
format: NameSimilarityOutputFormat::Json,
include: Some("src/**".to_string()),
exclude: Some("tests/**".to_string()),
output: Some(PathBuf::from("/tmp/similarity.json")),
perf: true,
fuzzy: true,
case_sensitive: true,
};
let result = handle_name_similarity(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[tokio::test]
async fn test_handle_name_similarity_types_scope() {
use crate::cli::enums::{NameSimilarityOutputFormat, SearchScope};
let cmd = AnalyzeCommands::NameSimilarity {
path: PathBuf::from("/nonexistent"),
project_path: None,
query: "Config".to_string(),
top_k: 5,
phonetic: false,
scope: SearchScope::Types,
threshold: 0.4,
format: NameSimilarityOutputFormat::Markdown,
include: None,
exclude: None,
output: None,
perf: false,
fuzzy: false,
case_sensitive: false,
};
let result = handle_name_similarity(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[test]
fn test_handler_function_signatures() {
let _: fn(AnalyzeCommands) -> _ = handle_duplicates;
let _: fn(AnalyzeCommands) -> _ = handle_name_similarity;
}
}