Module complexity

Module complexity 

Source
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§

ComplexityAnalyzer
Core complexity analyzer
ComplexityConfig
Configuration for complexity analysis
ComplexityMetrics
Comprehensive complexity metrics for a code file
ComplexityThresholds
Thresholds for complexity warnings
LanguageSpecificMetrics
Language-specific complexity metrics