Skip to content

Commit 66585de

Browse files
simegclaude
andcommitted
Add technical-debt command for code complexity analysis
Implement comprehensive technical debt analysis with multiple metrics: - Large commits detection (>20 files changed) - File hotspots analysis (frequently modified files with risk levels) - Long-lived branches identification (>30 days old) - Code churn patterns (high add/delete ratios) - Binary files detection in repository Features styled output with emoji indicators, color-coded risk levels, and comprehensive test coverage including 11 unit tests and 9 integration tests. Updated documentation and cleaned up CI configuration. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1b516a0 commit 66585de

File tree

11 files changed

+1120
-12
lines changed

11 files changed

+1120
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,4 @@ jobs:
6161
with:
6262
token: ${{ secrets.CODECOV_TOKEN }}
6363
slug: simeg/git-x
64-
files: ./cobertura.xml
6564
fail_ci_if_error: false

Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ run: build
2323
test:
2424
$(CARGO) test -- --test-threads=1
2525

26-
## Run tests serially (useful for debugging test interference)
27-
test-serial:
28-
$(CARGO) test -- --test-threads=1
29-
3026
## Run test coverage analysis using tarpaulin
3127
coverage:
3228
$(CARGO) tarpaulin --workspace --timeout 120 --out Stdout
@@ -71,7 +67,6 @@ help:
7167
@echo " make build Build release binary"
7268
@echo " make run Run binary with ARGS=\"xinfo\""
7369
@echo " make test Run tests"
74-
@echo " make test-serial Run tests serially (for debugging)"
7570
@echo " make coverage Generate test coverage report"
7671
@echo " make fmt Format code"
7772
@echo " make fmt-check Check formatting"

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ It wraps common Git actions in muscle-memory-friendly, no-brainer commands — p
2929
- [`summary`](#summary)
3030
- [`switch-recent`](#switch-recent)
3131
- [`sync`](#sync)
32+
- [`technical-debt`](#technical-debt)
3233
- [`undo`](#undo)
3334
- [`upstream`](#upstream)
3435
- [`what [branch]`](#what-branch)
@@ -473,6 +474,48 @@ Automatically fetches from remote and integrates upstream changes into your curr
473474

474475
---
475476

477+
### `technical-debt`
478+
479+
> Analyze code complexity and technical debt metrics
480+
481+
```shell
482+
git x technical-debt
483+
```
484+
485+
#### Output:
486+
487+
```shell
488+
🔍 Technical Debt Analysis
489+
490+
📊 Large Commits (>20 files changed)
491+
✓ No large commits found
492+
493+
🔥 File Hotspots (frequently modified)
494+
1. 15 changes | HIGH | src/main.rs
495+
2. 8 changes | MED | src/lib.rs
496+
3. 6 changes | LOW | README.md
497+
498+
🌿 Long-lived Branches (>30 days)
499+
• feature/old-refactor | 3 months ago | Alice Smith
500+
• hotfix/legacy-fix | 6 weeks ago | Bob Jones
501+
502+
🔄 Code Churn (high add/delete ratio)
503+
1. +245 -189 | HIGH | src/parser.rs
504+
2. +156 -98 | MED | src/utils.rs
505+
506+
📦 Binary Files in Repository
507+
! 3 binary files found
508+
• assets/logo.png
509+
• docs/manual.pdf
510+
...
511+
512+
Analysis complete!
513+
```
514+
515+
Analyzes repository for technical debt indicators including large commits, file modification hotspots, long-lived branches, code churn patterns, and binary file usage.
516+
517+
---
518+
476519
### `undo`
477520

478521
> Undo the last commit (without losing changes)

cobertura.xml

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/command-internals.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,61 @@ This document explains how each `git-x` subcommand works under the hood. We aim
8383

8484
---
8585

86+
## `technical-debt`
87+
88+
### What it does:
89+
- Analyzes repository for technical debt indicators including large commits, file hotspots, long-lived branches, code churn, and binary files.
90+
91+
### Under the hood:
92+
- **Large Commits Analysis:**
93+
```shell
94+
git log --all --pretty=format:%h|%s|%an|%ad --date=short --numstat --since=6 months ago
95+
```
96+
- Parses commit history with file change statistics
97+
- Identifies commits with >20 file changes
98+
- Sorts by number of files changed
99+
100+
- **File Hotspots Analysis:**
101+
```shell
102+
git log --all --pretty=format: --name-only --since=6 months ago
103+
```
104+
- Counts modification frequency per file
105+
- Categorizes risk levels: HIGH (>50), MED (>20), LOW (>5)
106+
- Excludes dotfiles and shows top modified files
107+
108+
- **Long-lived Branches Analysis:**
109+
```shell
110+
git for-each-ref --format=%(refname:short)|%(committerdate:relative)|%(authorname) refs/heads/
111+
```
112+
- Identifies branches older than 30 days
113+
- Excludes main/master/develop branches
114+
- Estimates days from relative date strings
115+
116+
- **Code Churn Analysis:**
117+
```shell
118+
git log --all --pretty=format: --numstat --since=3 months ago
119+
```
120+
- Aggregates additions/deletions per file
121+
- Calculates churn ratio (total changes / line changes)
122+
- Highlights files with high modification-to-content ratios
123+
124+
- **Binary Files Detection:**
125+
```shell
126+
git ls-files
127+
```
128+
- Scans tracked files for binary extensions
129+
- Checks common binary types: images, videos, audio, archives, executables, documents
130+
- Reports count and sample file paths
131+
132+
### Key metrics:
133+
- Large commits indicate lack of atomic changes and potential review complexity
134+
- File hotspots suggest architectural issues or missing abstractions
135+
- Long-lived branches indicate potential merge conflicts and outdated code
136+
- High churn files may need refactoring or better change management
137+
- Binary files affect repository size and diff readability
138+
139+
---
140+
86141
## `prune-branches`
87142

88143
### What it does:

0 commit comments

Comments
 (0)