garbage-code-hunter 0.2.1

A humorous Rust code quality detector that roasts your garbage code
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
# Garbage Code Hunter

[![CI/CD](https://github.com/TimWood0x10/garbage-code-hunter/actions/workflows/ci.yml/badge.svg)](https://github.com/TimWood0x10/garbage-code-hunter/actions/workflows/ci.yml)
[![Crates.io](https://img.shields.io/crates/v/garbage-code-hunter.svg)](https://crates.io/crates/garbage-code-hunter)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-yellow.svg)](https://opensource.org/licenses/Apache-2.0)
[![Rust Version](https://img.shields.io/badge/rust-stable-orange.svg)](https://www.rust-lang.org/)

[English]README.md | [ไธญๆ–‡]./README_zh.md

A humorous code quality detector that roasts your garbage code with style!

> **Inspiration**: https://github.com/Done-0/fuck-u-code.git

## What is this?

Garbage Code Hunter is a CLI toolkit for code quality analysis. Unlike traditional linters that give you dry warnings, we tell you how bad your code is in a **sarcastic witty and brutally honest** way.

## Tool Collection

| Tool | Command | Alias | What it does |
|---|---|---|---|
| **Code Hunter** | `analyze` (default) | - | Static analysis: naming, nesting, unwrap abuse, duplication |
| **Commit Roaster** | `commit-roaster` | `cr` | Roast bad commit messages from git history |
| **Deps Shamer** | `deps-shamer` | `ds` | Shame bad dependency practices |
| **PR Title Hunter** | `pr-title-hunter` | `pr` | Roast low-quality PR titles |
| **Full Scan** | `scan` | - | Run all tools, get combined score |
| **Badge** | `badge` | - | Generate SVG score badge |
| **Trend** | `trend` | - | Show quality score trend over time |
| **Last Words** | `last-words` | `lw` | Find legacy TODO/FIXME/HACK comments and their age |
| **Debt Invoice** | `debt-invoice` | `debt` | Generate a technical debt invoice with cost estimates |
| **Personality** | `personality` | - | Analyze your developer personality based on code patterns |
| **Decay** | `decay` | - | Analyze project quality decay over git history |
| **Autopsy** | `autopsy` | - | Generate a code autopsy report (root cause analysis) |
| **Radar** | `radar` | - | Generate a code smell radar chart (SVG) |
| **CI Bot** | `ci-bot` | - | Generate a CI-style PR review comment |
| **Persona** | `persona` | - | Analyze code with a specific roast personality |
| **Danger Zone** | `danger-zone` | `dz` | Identify the most dangerous files in the codebase |
| **Team Roast** | `team-roast` | - | Per-developer team analysis and roasting |

## Architecture

```mermaid
graph TB
    CLI["garbage-code-hunter<br/>CLI Entry (clap)"]

    subgraph Core["Core Engine"]
        TS["Tree-Sitter Engine<br/>AST Parsing (11 languages)"]
        GA["Generic Analyzer<br/>Regex-based fallback"]
        AN["CodeAnalyzer<br/>Unified analysis pipeline"]
        CTX["Context System<br/>File type detection"]
    end

    subgraph Rules["Rule Engine (tree-sitter)"]
        BR["Base Rules<br/>nesting, naming, length"]
        CR_R["Complex Rules<br/>god-function, duplication"]
        RR["Rust Rules<br/>unwrap, lifetime, macro"]
        REM["Remaining Rules<br/>magic-number, dead-code"]
    end

    subgraph Tools["18 Analysis Tools"]
        CH["Code Hunter<br/>Static Analysis"]
        CMR["Commit Roaster<br/>Git History"]
        DS["Deps Shamer<br/>5 Ecosystems"]
        PR["PR Title Hunter<br/>Local + GitHub"]
    end

    subgraph FunTools["Fun Tools"]
        LW["Last Words"]
        DI["Debt Invoice"]
        PE["Personality"]
        DC["Decay"]
        AU["Autopsy"]
        RD["Radar SVG"]
        CB["CI Bot"]
        PA["Persona"]
        DZ["Danger Zone"]
        TR["Team Roast"]
    end

    subgraph Output["Output"]
        TERM["Terminal<br/>Colored"]
        JSON["JSON"]
        SVG["SVG<br/>Badge/Radar"]
    end

    CLI --> AN
    AN --> TS
    AN --> GA
    TS --> BR & CR_R & RR & REM
    AN --> CTX
    CLI --> CH & CMR & DS & PR
    CLI --> FunTools
    CH & CMR & DS & PR --> TERM & JSON
    RD & BADGE --> SVG
```

```mermaid
graph LR
    subgraph DepsShamer["Deps Shamer - Multi-Ecosystem"]
        direction TB
        CARGO["Cargo.toml<br/>Rust"]
        NPM["package.json<br/>Node.js"]
        GOMOD["go.mod<br/>Go"]
        PIP["requirements.txt<br/>Python"]
        PYPROJ["pyproject.toml<br/>Python"]
    end

    subgraph Rules["Rule Engine"]
        direction TB
        TRAIT["DepRule / PrRule / Rule<br/>Trait Interface"]
        DEFAULT["default_rules()<br/>Built-in Rules"]
        CUSTOM["TOML Config<br/>Custom Rules"]
    end

    subgraph PRMode["PR Title Hunter Modes"]
        direction TB
        LOCAL["Local Mode<br/>git2 merge commits"]
        REMOTE["Remote Mode<br/>GitHub API"]
    end

    DepsShamer --> TRAIT
    TRAIT --> DEFAULT
    TRAIT --> CUSTOM
    PRMode --> LOCAL
    PRMode --> REMOTE
```

## Features

- **18 tools**: Static analysis, git roasting, dependency shaming, PR review, and 11 entertainment tools
- **Multi-ecosystem deps**: Cargo.toml, package.json, go.mod, requirements.txt, pyproject.toml
- **GitHub API**: PR Title Hunter supports remote repos (`--repo owner/repo`)
- **Historical trends**: Track quality over time with ASCII charts
- **SVG badges**: Generate shields.io-style badges for READMEs
- **Code smell radar**: SVG radar chart for README visualization
- **Developer personality**: Profile your coding style with fun personas
- **Technical debt invoice**: Estimate the real cost of your code smells
- **Code autopsy**: Root cause analysis of codebase problems
- **Danger zone**: Identify the riskiest files by churn, complexity, and contributors
- **Team roast**: Per-developer analysis with commit habit roasting
- **CI comment bot**: Generate PR review comments for GitHub Actions
- **Multiple personas**: Roast as Linux Kernel Maintainer, Silicon Valley CTO, Japanese Enterprise Engineer, or Rust Evangelist
- **Context-aware**: Adjusts sensitivity for test/example/UI code
- **Dual output**: Colored terminal or JSON for all commands
- **Bilingual**: English and Chinese roasts
- **LLM powered**: Optional Ollama integration for creative roasts
- **VSCode extension**: Real-time analysis in your editor
- **11 languages**: Rust, C, C++, Python, JavaScript, TypeScript, Go, Java, Ruby, Swift, Zig

## How to Play

### Level 1: Quick Roast (30 seconds)
```bash
# Install
cargo install garbage-code-hunter

# Analyze current project โ€” get roasted immediately
garbage-code-hunter

# Chinese mode
garbage-code-hunter --lang zh-CN
```

### Level 2: Full Scan (2 minutes)
```bash
# Run ALL 18 tools โ€” get a combined garbage score
garbage-code-hunter scan

# Save to history for trend tracking
garbage-code-hunter scan --save

# Check your score trend
garbage-code-hunter trend
```

### Level 3: Deep Dive (5 minutes)
```bash
# Roast your commit history
garbage-code-hunter cr --limit 100

# Shame your dependencies
garbage-code-hunter ds

# Find your worst files
garbage-code-hunter dz

# Generate a radar chart
garbage-code-hunter radar --output radar.svg
```

### Level 4: Team Battle
```bash
# Who's the worst committer?
garbage-code-hunter team-roast

# What's your developer personality?
garbage-code-hunter personality

# Generate a technical debt invoice
garbage-code-hunter debt-invoice
```

### Level 5: CI Integration
```bash
# Generate PR review comments
garbage-code-hunter ci-bot -f json

# Generate a score badge for your README
garbage-code-hunter badge -o badge.svg
```

## Real Project Reports

### Self-Analysis: garbage-code-hunter (this project)

```
๐Ÿ“Š Garbage Scan Report
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

  code-hunter       0/100   (44,836 issues in 93 files)
  commit-roaster   57/100   (50 commits analyzed)
  deps-shamer     100/100   (29 dependencies โ€” clean!)
  pr-title-hunter 100/100   (0 PRs checked)
  last-words       64/100   (7,085 TODO/FIXME found)
  debt-invoice      0/100   ($89,069 estimated debt)
  personality       0/100   (The Copy-Paste Artist)
  decay            50/100   (Declining)
  autopsy          97/100   (1 root cause found)
  radar            58/100   (6 dimensions scored)
  danger-zone      52/100   (10 dangerous files)
  team-roast       98/100   (2 team members)

  Overall Score: 39/100 (Grade: B)
```

**Developer Personality**: The Copy-Paste Artist
> "Ctrl+C, Ctrl+V is your IDE's most used shortcut. Why abstract when you can duplicate?"

**Code Smell Radar**:
```
  Complexity         100 โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
  Duplication        100 โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
  Naming              30 โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
  Panic Risk          20 โ–ˆโ–ˆโ–ˆโ–ˆ
  Dep Hell             0
  Legacy Smell       100 โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
```

**Team Stats**:
```
  #1 Timwood0x10    53 commits | 36% fix rate | worst: "fix ci"
  #2 Marky-Shi       5 commits | 60% fix rate | worst: "fix: Add debugging..."
```

**Top 5 Most Dangerous Files**:
```
  1. mod.rs           (6,352 issues โ€” i18n roast messages)
  2. rust_rules.rs    (2,260 issues โ€” tree-sitter rules)
  3. complex_rules.rs (2,050 issues โ€” complex patterns)
  4. display.rs       (1,997 issues โ€” report formatting)
  5. duplication.rs   (1,804 issues โ€” dup detection)
```

### Example: Rust Project Analysis

```bash
$ garbage-code-hunter --lang zh-CN src/

๐Ÿ—‘๏ธ  ๅžƒๅœพไปฃ็ ็ŒŽไบบ ๐Ÿ—‘๏ธ
ๆญฃๅœจๅ‡†ๅค‡ๅๆงฝไฝ ็š„ไปฃ็ ...

๐Ÿ“Š ๅžƒๅœพไปฃ็ ๆฃ€ๆต‹ๆŠฅๅ‘Š
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
๐Ÿ“ˆ ้—ฎ้ข˜็ปŸ่ฎก:
   12 ๐Ÿ”ฅ ๆ ธๅผน็บง้—ฎ้ข˜ (้œ€่ฆ็ซ‹ๅณไฟฎๅค)
  228 ๐ŸŒถ๏ธ  ่พฃ็œผ็›้—ฎ้ข˜ (ๅปบ่ฎฎไฟฎๅค)
  44596 ๐Ÿ˜ ่ฝปๅพฎ้—ฎ้ข˜ (ๅฏไปฅๅฟฝ็•ฅ)

๐Ÿ† ไปฃ็ ่ดจ้‡่ฏ„ๅˆ†: 30.0/100 ๐Ÿ‘ (่‰ฏๅฅฝ)
๐Ÿ“ ไปฃ็ ่กŒๆ•ฐ: 22,946 | ๐Ÿ“ ๆ–‡ไปถ: 93 | ๐Ÿ” ๅฏ†ๅบฆ: 19 ้—ฎ้ข˜/ๅƒ่กŒ
```

### JSON Output (for CI/CD integration)

```bash
$ garbage-code-hunter scan -f json | jq '.overall_score'
39.18

$ garbage-code-hunter cr -f json | jq '.score'
57.0

$ garbage-code-hunter ds -f json | jq '.issues | length'
0
```

## Quick Start

### Install

```bash
cargo install garbage-code-hunter
```

### Subcommands

#### Code Analysis (default)
```bash
garbage-code-hunter                    # Analyze current directory
garbage-code-hunter src/main.rs        # Analyze specific file
garbage-code-hunter --lang zh-CN src/  # Chinese roasts
garbage-code-hunter --markdown src/    # Markdown report for AI tools
garbage-code-hunter --educational      # Show how-to-fix advice
garbage-code-hunter --hall-of-shame    # Show worst files ranking
```

#### Commit Roaster
```bash
garbage-code-hunter commit-roaster              # Last 50 commits
garbage-code-hunter cr --limit 100              # Last 100 commits
garbage-code-hunter cr --author "john" --since 2024-01-01
garbage-code-hunter cr -f json                  # JSON output
```

#### Deps Shamer
```bash
garbage-code-hunter deps-shamer          # Current directory
garbage-code-hunter ds /path/to/project  # Specific project
garbage-code-hunter ds -f json           # JSON output
```

#### PR Title Hunter
```bash
# Local mode (from merge commits)
garbage-code-hunter pr --limit 100

# Remote mode (GitHub API)
garbage-code-hunter pr --repo owner/repo
garbage-code-hunter pr --repo owner/repo --state open --limit 50
garbage-code-hunter pr --repo owner/repo --token $GITHUB_TOKEN
garbage-code-hunter pr --repo owner/repo --author "username"
```

#### Full Scan
```bash
garbage-code-hunter scan              # Run all tools
garbage-code-hunter scan --save       # Run and save to history
garbage-code-hunter scan -f json      # JSON output
```

#### Badge
```bash
garbage-code-hunter badge                         # Auto-score + badge.svg
garbage-code-hunter badge --score 72              # Use specific score
garbage-code-hunter badge -o quality.svg          # Custom output path
garbage-code-hunter badge --style plastic         # Plastic style
```

#### Trend
```bash
garbage-code-hunter trend              # Show last 10 scans
garbage-code-hunter trend --last 20    # Show last 20 scans
garbage-code-hunter trend -f json      # JSON output
```

#### Last Words
```bash
garbage-code-hunter last-words         # Find TODO/FIXME/HACK comments
garbage-code-hunter lw --age           # Include age via git blame (slower)
garbage-code-hunter lw -f json         # JSON output
```

#### Debt Invoice
```bash
garbage-code-hunter debt-invoice       # Generate cost estimate
garbage-code-hunter debt -f json       # JSON output
```

#### Personality
```bash
garbage-code-hunter personality        # Analyze developer personality
garbage-code-hunter personality -f json
```

#### Decay
```bash
garbage-code-hunter decay              # Analyze quality over git history
garbage-code-hunter decay -f json
```

#### Autopsy
```bash
garbage-code-hunter autopsy            # Root cause analysis
garbage-code-hunter autopsy -f json
```

#### Radar
```bash
garbage-code-hunter radar              # Show code smell radar
garbage-code-hunter radar --output radar.svg  # Generate SVG chart
```

#### CI Bot
```bash
garbage-code-hunter ci-bot             # Generate PR review comment
garbage-code-hunter ci-bot -f json     # JSON with Markdown comment
```

#### Persona
```bash
garbage-code-hunter persona --persona linux-kernel
garbage-code-hunter persona --persona silicon-valley
garbage-code-hunter persona --persona japanese-enterprise
garbage-code-hunter persona --persona rust-fanatic
```

#### Danger Zone
```bash
garbage-code-hunter danger-zone        # Find most dangerous files
garbage-code-hunter dz -f json
```

#### Team Roast
```bash
garbage-code-hunter team-roast         # Per-developer analysis
garbage-code-hunter team-roast --limit 200
```

### Output Formats

All subcommands support `terminal` (default, colored) and `json` output:
```bash
garbage-code-hunter cr -f json | jq '.score'
garbage-code-hunter ds -f json | jq '.issues | length'
garbage-code-hunter trend -f json | jq '.records[-1].overall_score'
```

## Example Output

### Commit Roaster
```
Commit Roast Report
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
Scanned 50 commits, found 12 issues

Critical (2)
  * abc1234 "" -- The commit message is empty. Were you sleepwalking?
  * def5678 "asdf" -- Keyboard mashing is not a commit strategy.

High (5)
  * ghi9012 "fix" -- Fix WHAT? 'fix' is not a description, it's a cry for help.

Score: 76/100 (B)
```

### Trend
```
Quality Trend
  (showing last 5 scans)

  Score
    85 |   โ—
       |   |
    80 | --+
       |
        05-01  05-08  05-13

Breakdown
  Overall              75 -> 85 (+10) UP
  code-hunter          65 -> 78 (+13) UP
  commit-roaster       80 -> 82 (+2)  RIGHT

Recent Scans
  2026-05-13T10:00:00  85  .
  2026-05-08T14:30:00  80  .
  2026-05-01T09:00:00  75  .
```

### Full Scan
```
Running Full Garbage Scan...
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
  code-hunter: 72/100 (23 issues in 15 files)
  commit-roaster: 85/100 (50 commits analyzed)
  deps-shamer: 90/100 (45 dependencies)
  pr-title-hunter: 95/100 (30 PRs checked)

Garbage Report
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

  Tool Summary
  code-hunter          72/100  (23 items)
  commit-roaster       85/100  (50 items)
  deps-shamer          90/100  (45 items)
  pr-title-hunter      95/100  (30 items)

  Overall Garbage Score: 86/100
```

## Tool Details

### Code Hunter Rules (Rust)
- Single-letter variable names
- Meaningless names (data, temp, foo, bar)
- Deep nesting (>4 levels)
- Long functions (>50 lines)
- `unwrap()` abuse
- Magic numbers
- Duplicate code blocks
- Cross-file duplication detection
- Context-aware: reduced sensitivity for test/example code

### Commit Roaster Rules
- Empty messages, single-word commits
- WIP commits on shared branches
- Generic messages: "fix", "update", "change"
- Keyboard mashing (asdf, qwer)
- ALL CAPS, excessive exclamation marks
- Version bump only, default merge messages
- Configurable via TOML rule files

### Deps Shamer Rules
- Too many dependencies (>50)
- Git-based dependencies
- Wildcard or star versions
- Pre-release versions in production
- Deprecated packages (per-ecosystem lists)
- Duplicate dependencies
- Too many dev/optional deps

### PR Title Hunter Rules
- Empty or too-short titles (<5 chars)
- Generic titles ("fix", "update", "WIP")
- Ticket-only titles ("PROJ-123", "#456")
- ALL CAPS, excessive exclamation marks
- Keyboard mashing
- Lowercase start (skips conventional commits)

## VSCode Extension

Get real-time roasting in VSCode:

1. Install the `garbage-code-hunter` CLI
2. Search "Garbage Code Hunter" in VSCode marketplace
3. Analysis triggers automatically when you save Rust files

## License

Apache License 2.0

---

**Remember**: We roast the code, not you. Let's make code reviews a bit more fun!