Expand description
§Code Complexity Analysis Module
This module provides comprehensive code complexity metrics to enhance the heuristic scoring system with deeper analysis of code structure and maintainability.
§Complexity Metrics
- Cyclomatic Complexity: Measures the number of linearly independent paths through code
- Nesting Depth: Maximum depth of nested control structures
- Function Count: Number of functions/methods in a file
- Line Complexity: Analysis of code lines vs comment lines vs blank lines
- Cognitive Complexity: Human-focused complexity measure
- Maintainability Index: Composite metric for code maintainability
§Usage
use scribe_analysis::complexity::{ComplexityAnalyzer, ComplexityMetrics};
let analyzer = ComplexityAnalyzer::new();
let content = "fn main() { if x > 0 { println!(\"positive\"); } }";
let metrics = analyzer.analyze_content(content, "rust")?;
println!("Cyclomatic Complexity: {}", metrics.cyclomatic_complexity);
println!("Maintainability Index: {:.2}", metrics.maintainability_index);
Structs§
- Complexity
Analyzer - Core complexity analyzer
- Complexity
Config - Configuration for complexity analysis
- Complexity
Metrics - Comprehensive complexity metrics for a code file
- Complexity
Thresholds - Thresholds for complexity warnings
- Language
Specific Metrics - Language-specific complexity metrics