garbage-code-hunter 0.1.1

A humorous Rust code quality detector that roasts your garbage code
Documentation

๐Ÿ—‘๏ธ Garbage Code Hunter

Rust License Crates.io Tests

A humorous Rust code quality detector that roasts your garbage code with style! ๐Ÿ”ฅ

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

Unlike traditional linters that give you dry, boring warnings, Garbage Code Hunter delivers sarcastic, witty, and brutally honest feedback about your code quality. It's like having a sassy code reviewer who isn't afraid to hurt your feelings (in a good way).

โœจ Features

  • ๐ŸŽญ Humorous Code Analysis: Get roasted with style while learning better coding practices
  • ๐ŸŒ Multi-language Support: Available in English and Chinese (more languages coming soon!)
  • ๐ŸŽฏ Smart Detection: Identifies common code smells and anti-patterns
  • ๐Ÿ“Š Professional Reports: Generate detailed analysis reports in multiple formats
  • ๐Ÿ”ง Highly Configurable: Customize output, filtering, and analysis depth
  • ๐Ÿ“ Markdown Export: Perfect for documentation and CI/CD integration
  • ๐Ÿš€ Fast & Lightweight: Built with Rust for maximum performance

๐ŸŽฏ Scoring System

Garbage Code Hunter includes a comprehensive scientific scoring system that evaluates your Rust code quality on a scale of 0-100, where:

  • Lower scores = Better code quality ๐Ÿ†
  • Higher scores = More problematic code ๐Ÿ’€

๐Ÿ“Š Score Ranges & Quality Levels

Score Range Quality Level Emoji Description
0-20 Excellent ๐Ÿ† Outstanding code quality with minimal issues
21-40 Good ๐Ÿ‘ Good code quality with minor improvements needed
41-60 Average ๐Ÿ˜ Average code quality with room for improvement
61-80 Poor ๐Ÿ˜Ÿ Poor code quality, refactoring recommended
81-100 Terrible ๐Ÿ’€ Critical code quality issues, rewrite urgently needed

๐Ÿงฎ Scoring Algorithm

The scoring system uses a multi-factor algorithm that considers:

1. Base Score Calculation

Each detected issue contributes to the base score using:

Issue Score = Rule Weight ร— Severity Weight

2. Rule Weights (Impact Factor)

Different types of issues have different weights based on their impact:

Category Rule Weight Rationale
Safety Critical unsafe-abuse 5.0 Memory safety violations
FFI Critical ffi-abuse 4.5 Foreign function interface risks
Runtime Critical unwrap-abuse 4.0 Potential panic sources
Architecture lifetime-abuse 3.5 Complex lifetime management
Async/Concurrency async-abuse 3.5 Async pattern misuse
Complexity deep-nesting 3.0 Code maintainability
Performance unnecessary-clone 2.0 Runtime efficiency
Readability terrible-naming 2.0 Code comprehension

3. Severity Weights

Issues are classified by severity with corresponding multipliers:

  • Nuclear (๐Ÿ’ฅ): 10.0ร— - Critical issues that can cause crashes or security vulnerabilities
  • Spicy (๐ŸŒถ๏ธ): 5.0ร— - Serious issues affecting maintainability or performance
  • Mild (๐Ÿ˜): 2.0ร— - Minor issues with style or best practices

4. Density Penalties

Additional penalties based on issue concentration:

  • Issue Density: Problems per 1000 lines of code

    • >50 issues/1000 lines: +25 penalty
    • >30 issues/1000 lines: +15 penalty
    • >20 issues/1000 lines: +10 penalty
    • >10 issues/1000 lines: +5 penalty
  • File Complexity: Average issues per file

    • >20 issues/file: +15 penalty
    • >10 issues/file: +10 penalty
    • >5 issues/file: +5 penalty

5. Severity Distribution Penalties

Extra penalties for problematic patterns:

  • Nuclear Issues: First nuclear issue +20, each additional +5
  • Spicy Issues: After 5 spicy issues, each additional +2
  • Mild Issues: After 20 mild issues, each additional +0.5

๐Ÿ“ˆ Metrics Included

The scoring system provides detailed metrics:

  • Total Score: Overall code quality score (0-100)
  • Category Scores: Breakdown by issue categories
  • Issue Density: Problems per 1000 lines of code
  • Severity Distribution: Count of nuclear/spicy/mild issues
  • File Count: Number of analyzed Rust files
  • Total Lines: Total lines of code analyzed

๐ŸŽฏ Interpretation Guide

For Excellent Code (0-20):

  • Minimal issues detected
  • Strong adherence to Rust best practices
  • Good architecture and safety patterns

For Good Code (21-40):

  • Few minor issues
  • Generally well-structured
  • Minor optimizations possible

For Average Code (41-60):

  • Moderate number of issues
  • Some refactoring beneficial
  • Focus on complexity reduction

For Poor Code (61-80):

  • Significant issues present
  • Refactoring strongly recommended
  • Address safety and complexity concerns

For Terrible Code (81-100):

  • Critical issues requiring immediate attention
  • Consider rewriting problematic sections
  • Focus on safety, correctness, and maintainability

๐Ÿ”ฌ Scientific Approach

The scoring system is designed to be:

  • Objective: Based on measurable code metrics
  • Weighted: Critical issues have higher impact
  • Contextual: Considers code size and complexity
  • Actionable: Provides specific improvement areas
  • Consistent: Reproducible results across runs

๐ŸŽช What It Detects

Naming Disasters

  • Terrible variable names (data, temp, info, obj)
  • Single-letter variables (except common loop counters)
  • Generic meaningless identifiers

Code Structure Issues

  • Deep nesting (Russian doll syndrome)
  • Overly long functions
  • Complex conditional logic

Rust-Specific Anti-patterns

  • unwrap() abuse (panic bombs ๐Ÿ’ฃ)
  • Unnecessary clone() calls (memory waste)
  • Poor error handling patterns

๐Ÿš€ Installation

From Source

git clone https://github.com/yourusername/garbage-code-hunter.git
cd garbage-code-hunter
make install

Using Cargo

cargo install garbage-code-hunter

๐Ÿ“– Usage

Basic Usage

# Analyze current directory
cargo run

# Analyze specific file or directory
cargo run -- src/main.rs
cargo run -- src/

# Use make targets for convenience
make run ARGS="src/ --verbose"
make demo

Language Options

# Chinese output (default)
garbage-code-hunter --lang zh-CN src/

# English output
garbage-code-hunter --lang en-US src/

Advanced Options

# Verbose analysis with top 3 problematic files
garbage-code-hunter --verbose --top 3 --issues 5 src/

# Only show summary
garbage-code-hunter --summary src/

# Generate Markdown report
garbage-code-hunter --markdown src/ > code-quality-report.md

# Exclude files/directories
garbage-code-hunter --exclude "test_*" --exclude "target/*" src/

# Show only serious issues
garbage-code-hunter --harsh src/

๐ŸŽจ Sample Output

English Mode

๐Ÿ—‘๏ธ  Garbage Code Hunter ๐Ÿ—‘๏ธ
Preparing to roast your code...

๐Ÿ“Š Code Quality Report
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Found some areas for improvement:

๐Ÿ“ˆ Issue Statistics:
   1 ๐Ÿ”ฅ Nuclear Issues (fix immediately)
   138 ๐ŸŒถ๏ธ  Spicy Issues (should fix)
   34 ๐Ÿ˜ Mild Issues (can ignore)
   173 ๐Ÿ“ Total

๐Ÿ† Code Quality Score
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   ๐Ÿ“Š Score: 60.9/100 ๐Ÿ˜
   ๐ŸŽฏ Level: Average
   ๐Ÿ“ Lines of Code: 260
   ๐Ÿ“ Files: 1
   ๐Ÿ” Issue Density: 66 issues/1k lines

   ๐ŸŽญ Issue Distribution:
      ๐Ÿ’ฅ Nuclear: 1
      ๐ŸŒถ๏ธ  Spicy: 138
      ๐Ÿ˜ Mild: 34

๐Ÿ† Files with Most Issues
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   1. func.rs (173 issues)

๐Ÿ“ func.rs
  ๐Ÿ“ฆ Nesting depth issues: 20 (depth 4-9)
  ๐Ÿ”„ Code duplication issues: 9 (6 instances)
  ๐Ÿท๏ธ Variable naming issues: 128 (a, b, c, d, e, ...)
  ๐Ÿท๏ธ Variable naming issues: 13 (a, b, c, d, e, ...)
  โš ๏ธ long function: 1


๐Ÿ“Š Scoring Details
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
๐Ÿ“‹ Category Scores:
  โš  ๐Ÿท๏ธ Naming 90     Terrible, urgent fixes needed
    ๐Ÿ’ฌ Congrats! Variables harder to understand than comments ๐Ÿ†
  โš  ๐Ÿงฉ Complexity 90     Terrible, urgent fixes needed
    ๐Ÿ’ฌ Complexity off the charts! Even AI gave up ๐Ÿค–
  โš  ๐Ÿ”„ Duplication 90     Terrible, urgent fixes needed
    ๐Ÿ’ฌ Suggest renaming to ctrl-c-ctrl-v.rs ๐Ÿ“‹
  โœ“โœ“ ๐Ÿฆ€ Rust Basics 0     Excellent, keep it up
  โœ“โœ“ โšก Advanced Rust 0     Excellent, keep it up
  โ€ข ๐Ÿš€ Rust Features 69     Poor, refactoring recommended
    ๐Ÿ’ฌ More macros than my excuses ๐ŸŽญ
  โœ“โœ“ ๐Ÿ—๏ธ Code Structure 0     Excellent, keep it up

๐Ÿงฎ Weighted Calculation:
  Score calculation: (90.0ร—0.25 + 90.0ร—0.20 + 90.0ร—0.15 + 0.0ร—0.15 + 0.0ร—0.10 + 69.4ร—0.10 + 0.0ร—0.05) รท 1.00 = 60.9

๐Ÿ“ Scoring Scale (higher score = worse code):
  ๐Ÿ’€ 81-100: Terrible    ๐Ÿ”ฅ 61-80: Poor    โš ๏ธ 41-60: Average
  โœ… 21-40: Good         ๐ŸŒŸ 0-20: Excellent
๐Ÿ“‹ Summary
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
๐Ÿ˜ Average code quality, Score: 60.9/100, room for improvement

Found some serious issues, suggest fixing nuclear problems first ๐Ÿ”ฅ

๐Ÿ’ก Suggestions
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   ๐Ÿ’ก Use meaningful variable names that make code self-documenting (e.g., user_count instead of data)
   ๐ŸŽฏ Variable names should describe what they store, not the data type
   ๐Ÿ”ง Reduce nesting levels, consider extracting functions or using early returns (guard clauses)
   ๐Ÿ—๏ธ Complex conditional logic can be split into multiple small functions
   โœ‚๏ธ Split long functions into smaller ones, follow the single responsibility principle
   ๐Ÿ“ A function should ideally not exceed 20-30 lines for better understanding and testing
   ๐Ÿ”„ Extract common code into functions to follow the DRY principle
   ๐Ÿ—๏ธ Consider creating utility functions or modules for repeated logic

Keep working hard to make your code better! ๐Ÿš€

Chinese Mode

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

๐Ÿ“Š ๅžƒๅœพไปฃ็ ๆฃ€ๆต‹ๆŠฅๅ‘Š
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
ๅ‘็Žฐไบ†ไธ€ไบ›้œ€่ฆๆ”น่ฟ›็š„ๅœฐๆ–น๏ผš

๐Ÿ“ˆ ้—ฎ้ข˜็ปŸ่ฎก:
   1 ๐Ÿ”ฅ ๆ ธๅผน็บง้—ฎ้ข˜ (้œ€่ฆ็ซ‹ๅณไฟฎๅค)
   138 ๐ŸŒถ๏ธ  ่พฃ็œผ็›้—ฎ้ข˜ (ๅปบ่ฎฎไฟฎๅค)
   34 ๐Ÿ˜ ่ฝปๅพฎ้—ฎ้ข˜ (ๅฏไปฅๅฟฝ็•ฅ)
   173 ๐Ÿ“ ๆ€ป่ฎก

๐Ÿ† ไปฃ็ ่ดจ้‡่ฏ„ๅˆ†
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   ๐Ÿ“Š ๆ€ปๅˆ†: 60.9/100 ๐Ÿ˜
   ๐ŸŽฏ ็ญ‰็บง: ไธ€่ˆฌ
   ๐Ÿ“ ไปฃ็ ่กŒๆ•ฐ: 260
   ๐Ÿ“ ๆ–‡ไปถๆ•ฐ้‡: 1
   ๐Ÿ” ้—ฎ้ข˜ๅฏ†ๅบฆ: 66 ้—ฎ้ข˜/ๅƒ่กŒ

   ๐ŸŽญ ้—ฎ้ข˜ๅˆ†ๅธƒ:
      ๐Ÿ’ฅ ๆ ธๅผน็บง: 1
      ๐ŸŒถ๏ธ  ไธฅ้‡: 138
      ๐Ÿ˜ ่ฝปๅพฎ: 34

๐Ÿ† ้—ฎ้ข˜ๆœ€ๅคš็š„ๆ–‡ไปถ
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   1. func.rs (173 issues)

๐Ÿ“ func.rs
  ๐Ÿ“ฆ ๅตŒๅฅ—ๆทฑๅบฆ้—ฎ้ข˜: 20 (deep nesting)
  ๐Ÿ”„ ไปฃ็ ้‡ๅค้—ฎ้ข˜: 9 (20 instances)
  ๐Ÿท๏ธ ๅ˜้‡ๅ‘ฝๅ้—ฎ้ข˜: 128 (a, b, c, d, e, ...)
  ๐Ÿท๏ธ ๅ˜้‡ๅ‘ฝๅ้—ฎ้ข˜: 13 (a, b, c, d, e, ...)
  โš ๏ธ long function: 1


๐Ÿ“Š ่ฏ„ๅˆ†่ฏฆๆƒ…
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
๐Ÿ“‹ ๅˆ†็ฑป่ฏ„ๅˆ†่ฏฆๆƒ…:
  โš  ๐Ÿท๏ธ ๅ‘ฝๅ่ง„่Œƒ 90ๅˆ†     ็ณŸ็ณ•๏ผŒๆ€ฅ้œ€ไฟฎๅค
    ๐Ÿ’ฌ ๆญๅ–œ๏ผไฝ ๆˆๅŠŸ่ฎฉๅ˜้‡ๅๆฏ”ๆณจ้‡Š่ฟ˜้šพๆ‡‚ ๐Ÿ†
  โš  ๐Ÿงฉ ๅคๆ‚ๅบฆ 90ๅˆ†     ็ณŸ็ณ•๏ผŒๆ€ฅ้œ€ไฟฎๅค
    ๐Ÿ’ฌ ๅคๆ‚ๅบฆ็ˆ†่กจ๏ผ่ฟžAI้ƒฝ็œ‹ไธๆ‡‚ไบ† ๐Ÿค–
  โš  ๐Ÿ”„ ไปฃ็ ้‡ๅค 90ๅˆ†     ็ณŸ็ณ•๏ผŒๆ€ฅ้œ€ไฟฎๅค
    ๐Ÿ’ฌ ๅปบ่ฎฎๆ”นๅไธบcopy-paste.rs ๐Ÿ“‹
  โœ“โœ“ ๐Ÿฆ€ RustๅŸบ็ก€ 0ๅˆ†     ไผ˜็ง€๏ผŒ็ปง็ปญไฟๆŒ
  โœ“โœ“ โšก ้ซ˜็บง็‰นๆ€ง 0ๅˆ†     ไผ˜็ง€๏ผŒ็ปง็ปญไฟๆŒ
  โ€ข ๐Ÿš€ RustๅŠŸ่ƒฝ 69ๅˆ†     ่พƒๅทฎ๏ผŒๅปบ่ฎฎ้‡ๆž„
    ๐Ÿ’ฌ ๅฎๅฎšไน‰ๆฏ”ๆˆ‘็š„ๅ€Ÿๅฃ่ฟ˜ๅคš ๐ŸŽญ
  โœ“โœ“ ๐Ÿ—๏ธ ไปฃ็ ็ป“ๆž„ 0ๅˆ†     ไผ˜็ง€๏ผŒ็ปง็ปญไฟๆŒ

๐Ÿงฎ ๅŠ ๆƒ่ฎก็ฎ—:
  ่ฏ„ๅˆ†่ฎก็ฎ—: (90.0ร—0.25 + 90.0ร—0.20 + 90.0ร—0.15 + 0.0ร—0.15 + 0.0ร—0.10 + 69.4ร—0.10 + 0.0ร—0.05) รท 1.00 = 60.9

๐Ÿ“ ่ฏ„ๅˆ†ๆ ‡ๅ‡† (ๅˆ†ๆ•ฐ่ถŠ้ซ˜ไปฃ็ ่ถŠ็ƒ‚):
  ๐Ÿ’€ 81-100: ็ณŸ็ณ•    ๐Ÿ”ฅ 61-80: ่พƒๅทฎ    โš ๏ธ 41-60: ไธ€่ˆฌ
  โœ… 21-40: ่‰ฏๅฅฝ     ๐ŸŒŸ 0-20: ไผ˜็ง€
๐Ÿ“‹ ๆ€ป็ป“
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
๐Ÿ˜ ไปฃ็ ่ดจ้‡ไธ€่ˆฌ๏ผŒ่ฏ„ๅˆ†: 60.9/100๏ผŒ่ฟ˜ๆœ‰ๆ”น่ฟ›็ฉบ้—ด

ๅ‘็Žฐไบ†ไธ€ไบ›ไธฅ้‡้—ฎ้ข˜๏ผŒๅปบ่ฎฎไผ˜ๅ…ˆไฟฎๅคๆ ธๅผน็บง้—ฎ้ข˜ ๐Ÿ”ฅ

๐Ÿ’ก ๆ”น่ฟ›ๅปบ่ฎฎ
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   ๐Ÿ’ก ไฝฟ็”จๆœ‰ๆ„ไน‰็š„ๅ˜้‡ๅ๏ผŒ่ฎฉไปฃ็ ่‡ช่งฃ้‡Š๏ผˆๆฏ”ๅฆ‚็”จ user_count ่€Œไธๆ˜ฏ data๏ผ‰
   ๐ŸŽฏ ๅ˜้‡ๅๅบ”่ฏฅๆ่ฟฐๅฎƒๅญ˜ๅ‚จ็š„ๅ†…ๅฎน๏ผŒ่€Œไธๆ˜ฏๆ•ฐๆฎ็ฑปๅž‹
   ๐Ÿ”ง ๅ‡ๅฐ‘ๅตŒๅฅ—ๅฑ‚ๆ•ฐ๏ผŒ่€ƒ่™‘ๆๅ–ๅ‡ฝๆ•ฐๆˆ–ไฝฟ็”จๆ—ฉๆœŸ่ฟ”ๅ›ž๏ผˆguard clauses๏ผ‰
   ๐Ÿ—๏ธ ๅคๆ‚็š„ๆกไปถ้€ป่พ‘ๅฏไปฅๆ‹†ๅˆ†ๆˆๅคšไธชๅฐๅ‡ฝๆ•ฐ
   โœ‚๏ธ ๅฐ†้•ฟๅ‡ฝๆ•ฐๆ‹†ๅˆ†ๆˆๅคšไธชๅฐๅ‡ฝๆ•ฐ๏ผŒ้ตๅพชๅ•ไธ€่Œ่ดฃๅŽŸๅˆ™
   ๐Ÿ“ ไธ€ไธชๅ‡ฝๆ•ฐๆœ€ๅฅฝไธ่ถ…่ฟ‡ 20-30 ่กŒ๏ผŒ่ฟ™ๆ ทๆ›ดๅฎนๆ˜“็†่งฃๅ’Œๆต‹่ฏ•

็ปง็ปญๅŠชๅŠ›๏ผŒ่ฎฉไปฃ็ ๅ˜ๅพ—ๆ›ดๅฅฝ๏ผ๐Ÿš€

๐Ÿ› ๏ธ Command Line Options

Option Short Description
--help -h Show help message
--verbose -v Show detailed analysis report
--top N -t N Show top N files with most issues (default: 5)
--issues N -i N Show N issues per file (default: 5)
--summary -s Only show summary conclusion
--markdown -m Output Markdown format report
--lang LANG -l LANG Output language (zh-CN, en-US)
--exclude PATTERN -e PATTERN Exclude file/directory patterns
--harsh Show only the worst offenders

๐Ÿ”ง Development

Prerequisites

  • Rust 1.70 or later
  • Cargo

Building

# Debug build
make build

# Release build
make release

# Run tests
make test

# Format code
make fmt

# Run linter
make clippy

Running Demo

make demo

This creates a sample file with intentionally bad code and runs the analyzer on it.

๐ŸŽฏ Examples

CI/CD Integration

# GitHub Actions example
- name: Code Quality Check
  run: |
    cargo install garbage-code-hunter
    garbage-code-hunter --markdown --lang en-US src/ > quality-report.md
    # Upload report as artifact or comment on PR

Pre-commit Hook

#!/bin/bash
# .git/hooks/pre-commit
garbage-code-hunter --harsh --summary src/
if [ $? -ne 0 ]; then
    echo "Code quality issues detected. Please fix before committing."
    exit 1
fi

๐Ÿค Contributing

We welcome contributions! Here's how you can help:

  1. Add New Rules: Implement additional code smell detection
  2. Language Support: Add translations for more languages
  3. Improve Messages: Make the roasts even funnier (but still helpful)
  4. Documentation: Help improve docs and examples
  5. Bug Reports: Found a bug? Let us know!

Adding New Detection Rules

  1. Create a new rule in src/rules/
  2. Implement the Rule trait
  3. Add humorous messages in src/i18n.rs
  4. Add tests
  5. Submit a PR!

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Inspired by the need for more entertaining code reviews
  • Built with โค๏ธ and a lot of โ˜•
  • Thanks to all the developers who write garbage code (we've all been there!)

๐Ÿ”— Links


Remember: The goal isn't to shame developers, but to make code quality improvement fun and memorable. Happy coding! ๐Ÿš€