Code Complexity
Analyzes code complexity and provides metrics
LLA Code Complexity Plugin
Analyze code complexity with live metrics.
Features
- Multiple metrics: cyclomatic, cognitive, maintainability index
- Function/class summaries
- Thresholds with colors
- Live stats and detailed reports
Default Configuration
Complexity Thresholds
- Low: < 10.0
- Medium: < 20.0
- High: < 30.0
- Very High: ≥ 40.0
Language Support (Default: Rust)
- Function:
fn - Class:
struct,impl,trait - Branch:
if,match,else - Loop:
for,while,loop - Comments:
//,/* - Max Line Length: 100
- Max Function Length: 50 lines
Usage
# Set complexity thresholds
lla plugin --name code_complexity --action set-thresholds --args 10 20 30 40
# Show report
lla plugin --name code_complexity --action show-reportDisplay Formats
Default
[Complexity: 12 (MI: 85.3)]Long
[Complexity: 12 (MI: 85.3)]
├── Lines: 150
├── Functions: 5
├── Classes: 2
├── Branches: 8
├── Loops: 4
├── Comments: 20
└── Long functions:
├── process_data (55 lines)
└── analyze_results (60 lines)Configuration
Config file: ~/.config/lla/code_complexity/config.toml
Language Settings
[languages.Rust]
extensions = ["rs"]
function_patterns = ["fn "]
class_patterns = ["struct ", "impl ", "trait "]
branch_patterns = ["if ", "match ", "else"]
loop_patterns = ["for ", "while ", "loop"]
comment_patterns = ["//", "/*"]
max_line_length = 100
max_function_lines = 50Thresholds
[thresholds]
low = 10.0
medium = 20.0
high = 30.0
very_high = 40.0Colors
[colors]
low = "bright_green"
medium = "bright_yellow"
high = "bright_red"
very_high = "red"