Skip to main content

reposcry_graph/
metrics.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct FileMetrics {
5    pub file_path: String,
6    pub fan_in: u32,
7    pub fan_out: u32,
8    pub churn_score: f64,
9    pub complexity_score: f64,
10    pub risk_score: f64,
11    pub loc: u32,
12    pub num_symbols: u32,
13    pub num_tests: u32,
14}
15
16impl FileMetrics {
17    pub fn compute_risk(&mut self) {
18        self.risk_score = self.fan_in as f64 * 0.30
19            + self.fan_out as f64 * 0.15
20            + self.churn_score * 0.25
21            + self.complexity_score * 0.20
22            + (if self.num_symbols > 10 { 1.0 } else { 0.0 }) * 0.10;
23    }
24}