Skip to main content

fallow_config/config/
health.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4const fn default_max_cyclomatic() -> u16 {
5    20
6}
7
8const fn default_max_cognitive() -> u16 {
9    15
10}
11
12/// Configuration for complexity health metrics (`fallow health`).
13#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
14#[serde(rename_all = "camelCase")]
15pub struct HealthConfig {
16    /// Maximum allowed cyclomatic complexity per function (default: 20).
17    /// Functions exceeding this threshold are reported.
18    #[serde(default = "default_max_cyclomatic")]
19    pub max_cyclomatic: u16,
20
21    /// Maximum allowed cognitive complexity per function (default: 15).
22    /// Functions exceeding this threshold are reported.
23    #[serde(default = "default_max_cognitive")]
24    pub max_cognitive: u16,
25
26    /// Glob patterns to exclude from complexity analysis.
27    #[serde(default)]
28    pub ignore: Vec<String>,
29}
30
31impl Default for HealthConfig {
32    fn default() -> Self {
33        Self {
34            max_cyclomatic: default_max_cyclomatic(),
35            max_cognitive: default_max_cognitive(),
36            ignore: vec![],
37        }
38    }
39}