Skip to content

Dead Code Heatmap — Visualize code freshness using Git history #34

Description

@NK2552003

Static dead code detectors only flag unused exports. They don't show how recently code was touched or whether it's actively maintained. A visual freshness heatmap helps devs prioritize refactoring and cleanup.

Objective

Create line-level editor decorations that color-code code based on last modification date via git blame/git log.

Scope & Implementation Details

1. Git Integration

  • Execute: git log --format="%H %ai" -- <file>
  • Parse timestamps per line using git blame --line-porcelain or diff-based mapping
  • Cache results per file path + HEAD commit hash

2. Heat Mapping Logic

  • Calculate age per line: now - lastModified
  • Color thresholds:
    • $(green) < 7 days#4caf50
    • $(yellow) 7–30 days#ff9800
    • $(red) > 30 days#f44336
  • Gracefully fallback to gray for untracked files

3. Editor Decorations

  • Use vscode.window.createTextEditorDecorationType
  • Apply line ranges via setDecorations
  • Tooltip on hover: "Last modified: 42 days ago by @user"

4. Performance Safeguards

  • Skip files > 10,000 lines or outside workspace
  • Debounce decoration updates on save/scroll
  • Cache git output in workspaceState or memory map

Acceptance Criteria

  • Fetches accurate last-modified dates per line
  • Applies correct color thresholds
  • Hover tooltips show age + author (if available)
  • No editor lag on files ≤5k lines
  • Disables cleanly in non-git repositories

Technical Notes

  • Use child_process.exec with maxBuffer: 10 * 1024 * 1024
  • Run git commands off the main thread or via execAsync
  • Invalidate cache on workspace.onDidChangeTextDocument + save
  • Consider git log -L for range-specific history if blame is slow

(use codicons not emojis)

Metadata

Metadata

Assignees

Labels

P1-highHigh-impact work that significantly improves the product.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