Skip to main content

tokmd_analysis_types/complexity/
halstead.rs

1//! Halstead software science DTOs for complexity receipts.
2//!
3//! These serde-stable contract types remain re-exported from the crate root.
4
5use serde::{Deserialize, Serialize};
6
7/// Halstead software science metrics computed from operator/operand token counts.
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct HalsteadMetrics {
10    /// Number of distinct operators (n1).
11    pub distinct_operators: usize,
12    /// Number of distinct operands (n2).
13    pub distinct_operands: usize,
14    /// Total number of operators (N1).
15    pub total_operators: usize,
16    /// Total number of operands (N2).
17    pub total_operands: usize,
18    /// Program vocabulary: n1 + n2.
19    pub vocabulary: usize,
20    /// Program length: N1 + N2.
21    pub length: usize,
22    /// Volume: N * log2(n).
23    pub volume: f64,
24    /// Difficulty: (n1/2) * (N2/n2).
25    pub difficulty: f64,
26    /// Effort: D * V.
27    pub effort: f64,
28    /// Estimated programming time in seconds: E / 18.
29    pub time_seconds: f64,
30    /// Estimated number of bugs: V / 3000.
31    pub estimated_bugs: f64,
32}