use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BestPracticeCheck {
pub name: String,
pub passed: bool,
pub category: CheckCategory,
pub details: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QualityTest {
pub passes_threshold: bool,
pub confidence_level: f64,
pub cv_check: bool,
pub skewness_check: bool,
pub score_check: bool,
pub details: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CorrelationInsight {
pub feature1: String,
pub feature2: String,
pub coefficient: f64,
pub strength: CorrelationStrength,
pub direction: CorrelationDirection,
pub interpretation: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BenchmarkComparison {
pub comparison: BenchmarkLevel,
pub property_count_percentile: f64,
pub complexity_percentile: f64,
pub documentation_percentile: f64,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum CorrelationStrength {
Weak,
Moderate,
Strong,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StatisticalAnomaly {
pub metric_name: String,
pub description: String,
pub deviation_score: f64,
pub severity: Severity,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PropertyCorrelationMatrix {
pub feature_names: Vec<String>,
pub correlation_matrix: Vec<Vec<f64>>,
pub insights: Vec<CorrelationInsight>,
pub method: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub enum Severity {
Info,
Warning,
Error,
Critical,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Anomaly {
pub anomaly_type: AnomalyType,
pub severity: Severity,
pub location: String,
pub description: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum CorrelationDirection {
Positive,
Negative,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DistributionStats {
pub mean: f64,
pub variance: f64,
pub std_dev: f64,
pub min: f64,
pub max: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Recommendation {
pub rec_type: RecommendationType,
pub severity: Severity,
pub target: String,
pub message: String,
pub suggested_action: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DependencyMetrics {
pub total_dependencies: usize,
pub avg_dependencies_per_property: f64,
pub max_dependency_depth: usize,
pub coupling_factor: f64,
pub cohesion_score: f64,
pub circular_dependencies: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DistributionAnalysis {
pub property_distribution: DistributionStats,
pub type_distribution: HashMap<String, usize>,
pub characteristic_distribution: HashMap<String, usize>,
pub optionality_ratio: f64,
pub collection_percentage: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BestPracticeReport {
pub passed_checks: usize,
pub total_checks: usize,
pub compliance_percentage: f64,
pub checks: Vec<BestPracticeCheck>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum BenchmarkLevel {
BelowAverage,
Average,
AboveAverage,
Excellent,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum AnomalyType {
HighPropertyCount,
MissingDocumentation,
InconsistentNaming,
DeepNesting,
HighCoupling,
UnusedEntity,
DuplicatePatterns,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StatisticalMetrics {
pub mean: f64,
pub median: f64,
pub std_dev: f64,
pub variance: f64,
pub mean_abs_deviation: f64,
pub median_abs_deviation: f64,
pub interquartile_range: f64,
pub coefficient_variation: f64,
pub skewness: f64,
pub kurtosis: f64,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum RecommendationType {
Refactoring,
Documentation,
Naming,
ComplexityReduction,
Performance,
BestPractice,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ComplexityAssessment {
pub structural: f64,
pub cognitive: f64,
pub cyclomatic: f64,
pub coupling: f64,
pub overall_level: ComplexityLevel,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ComplexityLevel {
Low,
Medium,
High,
VeryHigh,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum CheckCategory {
Naming,
Documentation,
Structure,
Types,
Metadata,
}