pub const HYBRID_STANDALONE_THRESHOLD: usize = 50;
pub const HYBRID_DOMINANCE_RATIO: usize = 3;
pub const RESERVED_KEYWORDS: &[&str] = &[
"mod", "pub", "use", "type", "impl", "trait", "fn", "let", "mut", "const", "static", "self",
"Self", "super", "crate", "as", "break", "continue", "else", "enum", "extern", "false", "for",
"if", "in", "loop", "match", "move", "ref", "return", "struct", "true", "unsafe", "while",
"where", "async", "await", "dyn", "import", "from", "def", "class", "if", "elif", "else", "for", "while", "try", "except",
"finally", "with", "lambda", "yield", "return", "pass", "break", "continue", "raise", "assert",
"global", "nonlocal", "del", "and", "or", "not", "is", "in", "None", "True", "False",
];
pub fn is_reserved_keyword(name: &str) -> bool {
RESERVED_KEYWORDS.contains(&name)
}
pub fn ensure_not_reserved(mut name: String) -> String {
if is_reserved_keyword(&name) {
name.push_str("_module");
}
name
}
#[derive(Debug, Clone)]
pub struct GodObjectThresholds {
pub max_methods: usize,
pub max_fields: usize,
pub max_traits: usize,
pub max_lines: usize,
pub max_complexity: u32,
}
impl Default for GodObjectThresholds {
fn default() -> Self {
Self {
max_methods: 20,
max_fields: 15,
max_traits: 5,
max_lines: 1000,
max_complexity: 200,
}
}
}
impl GodObjectThresholds {
pub fn for_rust() -> Self {
Self {
max_methods: 20,
max_fields: 15,
max_traits: 5,
max_lines: 1000,
max_complexity: 200,
}
}
pub fn for_python() -> Self {
Self {
max_methods: 15,
max_fields: 10,
max_traits: 3,
max_lines: 500,
max_complexity: 150,
}
}
pub fn for_javascript() -> Self {
Self {
max_methods: 15,
max_fields: 20,
max_traits: 3,
max_lines: 500,
max_complexity: 150,
}
}
}
#[derive(Debug, Clone)]
pub struct ComplexityThresholds {
pub target_avg_complexity: f64,
pub max_method_complexity: u32,
pub target_total_complexity: f64,
}
impl Default for ComplexityThresholds {
fn default() -> Self {
Self {
target_avg_complexity: 5.0,
max_method_complexity: 15,
target_total_complexity: 75.0, }
}
}
impl ComplexityThresholds {
pub fn for_rust() -> Self {
Self {
target_avg_complexity: 5.0,
max_method_complexity: 15,
target_total_complexity: 100.0, }
}
pub fn for_python() -> Self {
Self {
target_avg_complexity: 4.0,
max_method_complexity: 12,
target_total_complexity: 60.0, }
}
pub fn for_javascript() -> Self {
Self {
target_avg_complexity: 4.0,
max_method_complexity: 12,
target_total_complexity: 60.0,
}
}
}