use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct LanguagesConfig {
pub enabled: Vec<String>,
#[serde(default)]
pub rust: Option<LanguageFeatures>,
#[serde(default)]
pub python: Option<LanguageFeatures>,
#[serde(default)]
pub javascript: Option<LanguageFeatures>,
#[serde(default)]
pub typescript: Option<LanguageFeatures>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LanguageFeatures {
#[serde(default = "default_detect_dead_code")]
pub detect_dead_code: bool,
#[serde(default = "default_detect_complexity")]
pub detect_complexity: bool,
#[serde(default = "default_detect_duplication")]
pub detect_duplication: bool,
}
impl Default for LanguageFeatures {
fn default() -> Self {
Self {
detect_dead_code: default_detect_dead_code(),
detect_complexity: default_detect_complexity(),
detect_duplication: default_detect_duplication(),
}
}
}
pub fn default_detect_dead_code() -> bool {
false
}
pub fn default_detect_complexity() -> bool {
true
}
pub fn default_detect_duplication() -> bool {
true
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EntropyConfig {
#[serde(default = "default_entropy_enabled")]
pub enabled: bool,
#[serde(default = "default_entropy_weight")]
pub weight: f64,
#[serde(default = "default_entropy_min_tokens")]
pub min_tokens: usize,
#[serde(default = "default_entropy_pattern_threshold")]
pub pattern_threshold: f64,
#[serde(default = "default_entropy_threshold")]
pub entropy_threshold: f64,
#[serde(default)]
pub use_classification: Option<bool>,
#[serde(default = "default_branch_threshold")]
pub branch_threshold: f64,
#[serde(default = "default_max_repetition_reduction")]
pub max_repetition_reduction: f64,
#[serde(default = "default_max_entropy_reduction")]
pub max_entropy_reduction: f64,
#[serde(default = "default_max_branch_reduction")]
pub max_branch_reduction: f64,
#[serde(default = "default_max_combined_reduction")]
pub max_combined_reduction: f64,
}
impl Default for EntropyConfig {
fn default() -> Self {
Self {
enabled: default_entropy_enabled(),
weight: default_entropy_weight(),
min_tokens: default_entropy_min_tokens(),
pattern_threshold: default_entropy_pattern_threshold(),
entropy_threshold: default_entropy_threshold(),
use_classification: None, branch_threshold: default_branch_threshold(),
max_repetition_reduction: default_max_repetition_reduction(),
max_entropy_reduction: default_max_entropy_reduction(),
max_branch_reduction: default_max_branch_reduction(),
max_combined_reduction: default_max_combined_reduction(),
}
}
}
pub fn default_entropy_enabled() -> bool {
true }
pub fn default_entropy_weight() -> f64 {
1.0 }
pub fn default_entropy_min_tokens() -> usize {
20
}
pub fn default_entropy_pattern_threshold() -> f64 {
0.7
}
pub fn default_entropy_threshold() -> f64 {
0.4 }
pub fn default_branch_threshold() -> f64 {
0.8 }
pub fn default_max_repetition_reduction() -> f64 {
0.20 }
pub fn default_max_entropy_reduction() -> f64 {
0.15 }
pub fn default_max_branch_reduction() -> f64 {
0.25 }
pub fn default_max_combined_reduction() -> f64 {
0.30 }