A pre-commit Git hook that analyzes your code, judges its quality, and generates hilarious memes to either celebrate your coding excellence or shame your questionable decisions.
This is a pre-commit hook that runs whenever you make a Git commit. Instead of just silently checking your code or displaying boring errors, it:
- Analyzes the quality of your code changes
- Generates a shocking and stylish meme tailored to your code quality
- Shows you terminal ASCII art for immediate feedback
- Offers to open a real meme in your browser
- Keeps a history of your coding quality over time
- 😎 Stylish Terminal Output: Colorful ASCII art and emoji-rich feedback
- 🤣 Quality-Based Memes: Different meme templates based on how "good" or "terrible" your code is
- 🔍 Code Analysis: Checks for common issues like:
- Long lines
- TODO comments that will never be addressed
- Empty catch blocks
- Nested conditionals
- Long functions
- Debug statements left in production code
- And more!
- 📊 Score Tracking: Keeps a history of your code quality over time
- 🌐 Real Meme Generation: Opens actual memes in your browser using memegen.link API
- Download the script:
curl -o pre-commit https://raw.githubusercontent.com/yourusername/code-meme-hook/main/pre-commit- Make it executable:
chmod +x pre-commit- Place it in your repository's
.git/hooks/directory:
mv pre-commit /path/to/your/repo/.git/hooks/- For team-wide installation, consider using a tool like pre-commit by adding to your
.pre-commit-config.yaml:
repos:
- repo: https://github.com/yourusername/code-meme-hook
rev: v1.0.0
hooks:
- id: code-quality-meme-generatorWhen you make a commit, the hook:
- Gets a list of all staged files in your commit
- Analyzes the code in each file for quality issues
- Calculates an overall quality score (0-100%)
- Determines a quality level ("terrible", "bad", "mediocre", "good", or "excellent")
- Generates a meme matching that quality level
- Displays both ASCII art in the terminal and offers to open a real meme
- Saves the result to a history file (
~/.code_meme_history.json)
The hook classifies your code into one of five quality levels:
- Terrible (< 20%): "CODE SO BRUTAL IT VIOLATES GENEVA CONVENTION"
- Bad (20-40%): "MERGED THIS CODE, BLAMED THE INTERN"
- Mediocre (40-60%): "FIXED ONE BUG, CREATED THREE MORE"
- Good (60-80%): "PR APPROVED WITHOUT A SINGLE COMMENT"
- Excellent (80-100%): "CODE SO ELEGANT COULD MAKE A GROWN DEV CRY"
═══════════════════════════════════════════════════════════════════════════
╔══════════════════════════════════════════════════════════════════════════╗
║ 💥 CODE QUALITY MEME GENERATOR 💥 ║
╚══════════════════════════════════════════════════════════════════════════╝
╔══════════════════════════════════════════╗
║ ║
║ (•̀ᴗ•́)و ̑̑ ✧*。٩(ˊᗜˋ*)و✧*。 ║
║ ║
║ YOUR CODE IS IMPRESSIVE! ║
║ ║
╚══════════════════════════════════════════╝
▓▒░ Quality score: 73.5% ░▒▓
▓▒░ Changes: +45 lines, -12 lines ░▒▓
🔍 TOP ISSUES:
• 📏 src/components/UserProfile.js has 3 lines longer than a CVS receipt
• 📜 src/utils/helpers.js has 1 functions longer than War and Peace
🖼️ Meme text: CODE SO CLEAN - COULD EAT OFF IT
🔗 Meme URL: https://api.memegen.link/images/goodguygrag/CODE_SO_CLEAN/COULD_EAT_OFF_IT.jpg
Want to see this as a real meme? (y/n)
You can customize the script by:
- Adding more meme templates to
MEME_TEMPLATES - Adjusting the scoring algorithm in
analyze_code_quality() - Adding more code quality checks
- Modifying the ASCII art in
ASCII_TEMPLATES
- Makes Code Reviews Fun: Motivates better coding with humor
- Team Building: Share your memes with teammates for laughs
- Learning Tool: Highlights common issues in a memorable way
- Actually Useful: Despite the humor, it provides genuine code quality feedback
- No Blocking: Unlike strict linters, this lets your commit proceed while providing feedback
- Python 3.6+
- Git
- Web browser (optional, for viewing memes)
The hook maintains a history file at ~/.code_meme_history.json that keeps track of your code quality over time. You could build additional tools to visualize trends in your coding quality based on this data.
MIT - Feel free to modify and share!
Contributions welcome! Add more meme templates, improve code analysis, or enhance the ASCII art.
Remember: Good code may be temporary, but dank memes are forever.
