Skip to content

Complexity Growth Tracker — Warn when functions increase in complexity over time #35

Description

@NK2552003

Developers only see current cyclomatic complexity. There's no visibility into how complexity evolves across commits, leading to gradual debt accumulation.

Objective

Track function-level complexity trends over Git history and warn when growth exceeds configurable thresholds.

Scope & Implementation Details

1. Complexity Calculation

  • Parse file AST using @typescript-eslint/typescript-estree or tree-sitter
  • Compute Cyclomatic Complexity (CC) per function/method
  • Store: { name, range, cc, filePath }

2. Git Comparison

  • Fetch historical snapshots: git log --follow -p -- <file>
  • Extract function CC at each commit
  • Compare current CC vs 5/10/30-day averages

3. Warning System

  • Inline decoration on function name if growth > threshold (default: 50%)
  • Status bar notification: "⚠️ Function complexity grew +85% in 14 days"
  • Hover tooltip shows trend chart (text-based or simple markdown table)

4. Configuration

  • complexityTracker.thresholdPercent (default: 50)
  • complexityTracker.lookbackDays (default: 14)
  • complexityTracker.ignoredFunctions (string[])

Acceptance Criteria

  • Computes CC accurately for TS/JS functions
  • Compares against historical Git states
  • Triggers warning when growth exceeds threshold
  • Shows inline decoration + hover details
  • Runs asynchronously without blocking saves

Technical Notes

  • Use git show <commit>:<file> to parse historical ASTs
  • Cache AST parses to avoid re-running on unchanged files
  • Limit history depth to last 20 commits to prevent slowdowns
  • Handle syntax errors gracefully (skip malformed files)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2-mediumImportant but not urgent. Can be scheduled after high-priority tasks are completed.advancedComplex features involving deep logic, architecture decisions, or integration with multiple systems.enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions