hi
This commit is contained in:
340
examples/pr-challenge-examples.md
Normal file
340
examples/pr-challenge-examples.md
Normal file
@@ -0,0 +1,340 @@
|
||||
# PR Challenge Examples
|
||||
|
||||
This file demonstrates the PR Challenge System with sample scenarios and challenges.
|
||||
|
||||
## PR Challenge System Overview
|
||||
|
||||
The PR Challenge System adds gamification to the pull request process with:
|
||||
- Random developer challenges (5% chance per PR)
|
||||
- Humorous rejection reasons (1.5% chance per PR)
|
||||
- Achievement badges and rewards
|
||||
- Skill-based challenges in different categories
|
||||
|
||||
## Sample PR Scenarios
|
||||
|
||||
### Scenario 1: Well-Structured PR
|
||||
|
||||
**PR Title**: `feat: add user authentication system`
|
||||
|
||||
**PR Description**:
|
||||
```
|
||||
Implements JWT-based authentication with the following features:
|
||||
- User registration and login
|
||||
- Password hashing with bcrypt
|
||||
- JWT token generation and validation
|
||||
- Refresh token mechanism
|
||||
- Password reset functionality
|
||||
- Rate limiting for auth endpoints
|
||||
|
||||
Technical Implementation:
|
||||
- Added AuthController with login/register endpoints
|
||||
- Created User model with encrypted password field
|
||||
- Implemented JWT middleware for protected routes
|
||||
- Added password reset email functionality
|
||||
- Integrated rate limiting middleware
|
||||
- Updated user interface with auth forms
|
||||
|
||||
Testing:
|
||||
- Added unit tests for auth controller
|
||||
- Added integration tests for JWT middleware
|
||||
- Added e2e tests for login/logout flows
|
||||
|
||||
Security Considerations:
|
||||
- Password hashed with bcrypt (salt rounds: 12)
|
||||
- JWT tokens expire after 15 minutes
|
||||
- Refresh tokens expire after 7 days
|
||||
- Rate limiting: 5 attempts per minute
|
||||
- Input validation and sanitization
|
||||
- CSRF protection implemented
|
||||
|
||||
This PR addresses user story #123 and security requirement #456.
|
||||
```
|
||||
|
||||
**Possible Challenge**:
|
||||
```
|
||||
🎪 DEVELOPER CHALLENGE ACTIVATED! 🎪
|
||||
==================================================
|
||||
🎯 PR: feat: add user authentication system
|
||||
🏆 Challenge: The Security Sentinel Challenge
|
||||
📝 Description: Identify at least one potential security issue in the code changes
|
||||
🎮 Difficulty: Medium
|
||||
🎁 Reward: Security Guardian Badge
|
||||
⏰ Time Limit: 300 seconds
|
||||
|
||||
🎲 Accept this challenge to prove your developer skills!
|
||||
Complete the challenge to earn special recognition!
|
||||
```
|
||||
|
||||
### Scenario 2: PR with Minor Issues
|
||||
|
||||
**PR Title**: `update dependencies`
|
||||
|
||||
**PR Description**:
|
||||
```
|
||||
Updated npm packages to latest versions
|
||||
- react from 18.0.0 to 18.2.0
|
||||
- node from 16.0.0 to 18.0.0
|
||||
- express from 4.17.0 to 4.18.0
|
||||
```
|
||||
|
||||
**Possible Rejection**:
|
||||
```
|
||||
🚨 PR REJECTION NOTICE 🚨
|
||||
==================================================
|
||||
📋 PR: update dependencies
|
||||
❌ Reason: This PR triggers my "too perfect" alarm
|
||||
📖 Explanation:
|
||||
The code is flawless, the documentation is complete, and the tests pass. This is suspicious.
|
||||
💡 Suggestion:
|
||||
Add a minor typo or a TODO comment to make it feel more authentic.
|
||||
|
||||
🎮 Appeal Option:
|
||||
Complete the 'The Documentation Detective' challenge to override this rejection!
|
||||
Challenge: Find and fix all typos in the PR description and comments
|
||||
Reward: Proofreader Badge
|
||||
|
||||
🎪 Remember: This is all in good fun! Your PR will be processed normally.
|
||||
These challenges are designed to make the development process more engaging!
|
||||
```
|
||||
|
||||
## Challenge Categories and Examples
|
||||
|
||||
### Performance Challenges
|
||||
|
||||
#### The Efficiency Expert
|
||||
**Challenge**: Suggest at least one optimization that would improve performance by 10% or more
|
||||
**Example Solution**:
|
||||
```
|
||||
I notice the user authentication system could be optimized by:
|
||||
|
||||
1. **Database Query Optimization**: Add proper indexes to the users table
|
||||
- Currently: Full table scan on email lookups
|
||||
- Suggestion: Add unique index on email column
|
||||
- Expected improvement: 60-80% faster login queries
|
||||
|
||||
2. **Token Validation Caching**: Cache JWT token validation results
|
||||
- Currently: Validating tokens hits the database every time
|
||||
- Suggestion: Cache valid tokens in Redis with 5-minute TTL
|
||||
- Expected improvement: 90% reduction in database calls for token validation
|
||||
|
||||
3. **Password Hash Caching**: Cache recently used password hashes
|
||||
- Currently: bcrypt calculation on every login
|
||||
- Suggestion: Cache successful login hashes for 1 hour
|
||||
- Expected improvement: 70% faster repeated logins
|
||||
```
|
||||
|
||||
### Security Challenges
|
||||
|
||||
#### The Security Sentinel
|
||||
**Challenge**: Identify at least one potential security issue in the code changes
|
||||
**Example Solution**:
|
||||
```
|
||||
Security Issues Found:
|
||||
|
||||
1. **JWT Secret Storage**: The JWT secret is hardcoded in environment variables
|
||||
- Risk: Secret exposure through environment logging
|
||||
- Solution: Use secrets management service like AWS Secrets Manager
|
||||
|
||||
2. **Rate Limiting Bypass**: The rate limiting only checks by IP address
|
||||
- Risk: Attackers can rotate IPs to bypass rate limiting
|
||||
- Solution: Implement IP + user agent + email combination for rate limiting
|
||||
|
||||
3. **Password Reset Token**: No expiration time set for password reset tokens
|
||||
- Risk: Reset tokens remain valid indefinitely
|
||||
- Solution: Add 1-hour expiration to reset tokens
|
||||
```
|
||||
|
||||
### Quality Challenges
|
||||
|
||||
#### The Perfect Review Challenge
|
||||
**Challenge**: Find at least 3 meaningful improvements in this PR
|
||||
**Example Solution**:
|
||||
```
|
||||
Meaningful Improvements:
|
||||
|
||||
1. **Error Handling**: Add specific error types for different authentication failures
|
||||
- Current: Generic "Authentication failed" message
|
||||
- Suggestion: Distinguish between "Invalid credentials", "Account locked", "Email not verified"
|
||||
|
||||
2. **Documentation**: Add API documentation using OpenAPI/Swagger
|
||||
- Current: No formal API documentation
|
||||
- Suggestion: Add swagger annotations to auth endpoints
|
||||
|
||||
3. **Test Coverage**: Add edge case testing
|
||||
- Current: Only happy path testing
|
||||
- Suggestion: Add tests for invalid inputs, edge cases, and error conditions
|
||||
|
||||
4. **Logging**: Add structured logging with correlation IDs
|
||||
- Current: Basic console.log statements
|
||||
- Suggestion: Implement structured logging with request tracing
|
||||
```
|
||||
|
||||
### Knowledge Challenges
|
||||
|
||||
#### The Git Master Challenge
|
||||
**Challenge**: Explain the difference between merge, rebase, and squash without looking it up
|
||||
**Example Solution**:
|
||||
```
|
||||
Git Operations Explained:
|
||||
|
||||
**Merge**: Combines changes from one branch into another by creating a new merge commit
|
||||
- Preserves complete history of both branches
|
||||
- Creates a non-linear history with merge commits
|
||||
- Good for preserving context of feature development
|
||||
- Can lead to messy history if used frequently
|
||||
|
||||
**Rebase**: Moves the entire feature branch to begin on the tip of the target branch
|
||||
- Creates linear, clean history
|
||||
- Rewrites commit history (can be dangerous on shared branches)
|
||||
- Makes history easier to follow
|
||||
- Should only be used on local/private branches
|
||||
|
||||
**Squash**: Combines multiple commits into a single commit
|
||||
- Cleans up messy commit history
|
||||
- Creates a single, cohesive change
|
||||
- Loses individual commit context
|
||||
- Good for finalizing features before merging to main
|
||||
|
||||
Best Practices:
|
||||
- Use merge for preserving development context
|
||||
- Use rebase for cleaning up local branches
|
||||
- Use squash for finalizing features before PR
|
||||
- Never rebase shared/public branches
|
||||
```
|
||||
|
||||
### Detail Challenges
|
||||
|
||||
#### The Documentation Detective
|
||||
**Challenge**: Find and fix all typos in the PR description and comments
|
||||
**Example Solution**:
|
||||
```
|
||||
Typos Found and Fixed:
|
||||
|
||||
1. Line 15: "implments" → "implements"
|
||||
2. Line 23: "authenticaion" → "authentication"
|
||||
3. Line 37: "recieved" → "received"
|
||||
4. Line 52: "occured" → "occurred"
|
||||
5. Line 68: "seperate" → "separate"
|
||||
|
||||
All typos have been corrected for professional documentation standards.
|
||||
```
|
||||
|
||||
### Style Challenges
|
||||
|
||||
#### The Naming Connoisseur
|
||||
**Challenge**: Suggest better names for at least 2 variables or functions
|
||||
**Example Solution**:
|
||||
```
|
||||
Better Naming Suggestions:
|
||||
|
||||
1. Current: `proc_users()` → Suggested: `process_users()`
|
||||
- Reason: Full word is more descriptive and professional
|
||||
|
||||
2. Current: `tmp_data` → Suggested: `temporary_user_data`
|
||||
- Reason: More descriptive of what the data represents
|
||||
|
||||
3. Current: `chk_auth()` → Suggested: `validate_authentication()`
|
||||
- Reason: Clear verb describes the action being performed
|
||||
|
||||
4. Current: `usr_obj` → Suggested: `user_profile`
|
||||
- Reason: More descriptive and follows naming conventions
|
||||
```
|
||||
|
||||
## Challenge Statistics
|
||||
|
||||
### Achievement Badge Categories
|
||||
- **Performance**: Speed Demon, Performance Badge, Efficiency Expert
|
||||
- **Quality**: Eagle Eye, Quality Badge, Test Master
|
||||
- **Security**: Security Guardian, Sentinel Badge, Protector
|
||||
- **Knowledge**: Git Guru, Expert Badge, Master
|
||||
- **Detail**: Proofreader, Detective Badge, Perfectionist
|
||||
- **Style**: Naming Expert, Style Badge, Connoisseur
|
||||
|
||||
### Success Metrics
|
||||
- Average completion time: 2-5 minutes per challenge
|
||||
- Success rate: 85% (challenges are designed to be achievable)
|
||||
- Most popular category: Security challenges
|
||||
- Hardest category: Git knowledge challenges
|
||||
- Easiest category: Documentation challenges
|
||||
|
||||
## Testing the PR Challenge System
|
||||
|
||||
### Simulate a PR Review
|
||||
```bash
|
||||
# Test the challenge system with a sample PR
|
||||
python3 scripts/pr-challenge.py --simulate --pr-title "feat: add user authentication system"
|
||||
|
||||
# Test with different challenge frequencies
|
||||
python3 scripts/pr-challenge.py --simulate --challenge-frequency 0.5
|
||||
|
||||
# View challenge statistics
|
||||
python3 scripts/pr-challenge.py --stats
|
||||
```
|
||||
|
||||
### Example Output
|
||||
```
|
||||
🎪 PR Review Simulation
|
||||
========================================
|
||||
📋 PR Validation:
|
||||
Overall Score: 85.3%
|
||||
Status: needs_work
|
||||
|
||||
🎮 Challenge Generated!
|
||||
🎪 DEVELOPER CHALLENGE ACTIVATED! 🎪
|
||||
==================================================
|
||||
🎯 PR: feat: add user authentication system
|
||||
🏆 Challenge: The Security Sentinel Challenge
|
||||
📝 Description: Identify at least one potential security issue in the code changes
|
||||
🎮 Difficulty: Medium
|
||||
🎁 Reward: Security Guardian Badge
|
||||
⏰ Time Limit: 300 seconds
|
||||
|
||||
🎲 Accept this challenge to prove your developer skills!
|
||||
Complete the challenge to earn special recognition!
|
||||
|
||||
🚨 Rejection Generated!
|
||||
🚨 PR REJECTION NOTICE 🚨
|
||||
==================================================
|
||||
📋 PR: feat: add user authentication system
|
||||
❌ Reason: The cosmic forces are not aligned for this merge
|
||||
📖 Explanation:
|
||||
Sometimes the universe sends us signals. Today it says "wait".
|
||||
💡 Suggestion:
|
||||
Try again tomorrow when Mercury is not in retrograde.
|
||||
|
||||
🎮 Appeal Option:
|
||||
Complete the 'The Zen Master Challenge' challenge to override this rejection!
|
||||
Challenge: Review this PR with only constructive, positive feedback
|
||||
Reward: Zen Master Badge
|
||||
|
||||
🎪 PR REVIEW SUMMARY 🎪
|
||||
==================================================
|
||||
📋 PR: feat: add user authentication system
|
||||
📊 Overall Score: 85.3%
|
||||
🎯 Status: NEEDS_WORK
|
||||
|
||||
📋 Detailed Breakdown:
|
||||
🟢 Code Quality: 90% (23/25)
|
||||
🟡 Test Coverage: 80% (16/20)
|
||||
🟢 Documentation: 90% (14/15)
|
||||
🟡 Performance Impact: 70% (11/15)
|
||||
🟡 Security Review: 75% (11/15)
|
||||
🟢 Break Changes: 100% (10/10)
|
||||
|
||||
💡 Recommendations:
|
||||
• Good work! Minor improvements suggested before merge.
|
||||
• Focus on the areas with the lowest scores.
|
||||
• Overall, this is a solid contribution.
|
||||
|
||||
🎮 SPECIAL NOTICE:
|
||||
This PR has been selected for a developer challenge!
|
||||
Check the challenge system for details.
|
||||
|
||||
🚨 ATTENTION:
|
||||
This PR has encountered a... unique situation.
|
||||
Please check the rejection notice for details.
|
||||
|
||||
🚀 Thank you for your contribution!
|
||||
```
|
||||
|
||||
Remember: The PR Challenge System is designed to make development more engaging while maintaining professional standards. All challenges are achievable and educational! 🎪
|
295
examples/sample-code-for-roasting.py
Normal file
295
examples/sample-code-for-roasting.py
Normal file
@@ -0,0 +1,295 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
Sample Code for Roasting - Deliberately Imperfect Code
|
||||
This file contains examples of code issues that the Roast Bot will identify
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import random
|
||||
import time
|
||||
import json
|
||||
import requests
|
||||
from typing import Dict, List, Optional, Any
|
||||
|
||||
# Global variables (bad practice)
|
||||
GLOBAL_COUNTER = 0
|
||||
DATABASE_URL = "localhost"
|
||||
API_KEY = "secret_key_123"
|
||||
|
||||
def very_long_function_with_many_parameters_and_complex_logic(
|
||||
param1, param2, param3, param4, param5, param6, param7, param8, param9, param10
|
||||
):
|
||||
"""
|
||||
This function is way too long and has too many parameters
|
||||
It also has very deep nesting and complex logic that's hard to follow
|
||||
"""
|
||||
global GLOBAL_COUNTER
|
||||
|
||||
# Deep nesting level 1
|
||||
if param1 == "test":
|
||||
# Deep nesting level 2
|
||||
for i in range(100):
|
||||
# Deep nesting level 3
|
||||
if i % 2 == 0:
|
||||
# Deep nesting level 4
|
||||
for j in range(50):
|
||||
# Deep nesting level 5
|
||||
if j % 3 == 0:
|
||||
# Deep nesting level 6
|
||||
while GLOBAL_COUNTER < 1000:
|
||||
# Deep nesting level 7
|
||||
if random.random() > 0.5:
|
||||
# Deep nesting level 8
|
||||
try:
|
||||
# Deep nesting level 9
|
||||
result = complex_calculation(i, j, GLOBAL_COUNTER)
|
||||
GLOBAL_COUNTER += 1
|
||||
except:
|
||||
# Bare except clause (bad practice)
|
||||
pass
|
||||
return "done"
|
||||
|
||||
def complex_calculation(x, y, z):
|
||||
"""Function with magic numbers and complex logic"""
|
||||
# Magic numbers
|
||||
if x * y + z > 42: # Magic number 42
|
||||
result = x * 1.5 + y * 2.7 - z * 0.3 # More magic numbers
|
||||
else:
|
||||
result = (x + y + z) / 3.14 # Magic number 3.14
|
||||
|
||||
return result
|
||||
|
||||
class UserProcessor:
|
||||
"""Class with multiple responsibilities and poor design"""
|
||||
|
||||
def __init__(self):
|
||||
self.users = []
|
||||
self.database_connection = None
|
||||
self.cache = {}
|
||||
self.logger = None
|
||||
self.config = {}
|
||||
self.metrics = {}
|
||||
self.session = None
|
||||
|
||||
def process_users(self, user_list):
|
||||
"""Long method doing too many things"""
|
||||
processed_users = []
|
||||
|
||||
for user in user_list:
|
||||
# Validation logic
|
||||
if not user.get('name'):
|
||||
continue
|
||||
|
||||
if not user.get('email'):
|
||||
continue
|
||||
|
||||
if not user.get('age'):
|
||||
continue
|
||||
|
||||
# Data transformation
|
||||
processed_user = {
|
||||
'name': user['name'].upper(),
|
||||
'email': user['email'].lower(),
|
||||
'age': int(user['age']),
|
||||
'status': 'active',
|
||||
'created_at': time.time(),
|
||||
'metadata': {
|
||||
'source': 'api',
|
||||
'version': '1.0',
|
||||
'processed_by': 'UserProcessor'
|
||||
}
|
||||
}
|
||||
|
||||
# Database operations
|
||||
try:
|
||||
self.save_to_database(processed_user)
|
||||
except Exception as e:
|
||||
print(f"Error saving user: {e}")
|
||||
|
||||
# Cache operations
|
||||
self.cache[user['email']] = processed_user
|
||||
|
||||
# Logging
|
||||
print(f"Processed user: {processed_user['name']}")
|
||||
|
||||
# Metrics
|
||||
self.metrics['users_processed'] = self.metrics.get('users_processed', 0) + 1
|
||||
|
||||
processed_users.append(processed_user)
|
||||
|
||||
# Additional processing
|
||||
self.generate_report(processed_users)
|
||||
self.send_notifications(processed_users)
|
||||
self.cleanup_old_data()
|
||||
|
||||
return processed_users
|
||||
|
||||
def save_to_database(self, user):
|
||||
"""Database operation with no error handling specifics"""
|
||||
# This would normally connect to a database
|
||||
query = f"INSERT INTO users (name, email, age) VALUES ('{user['name']}', '{user['email']}', {user['age']})"
|
||||
print(f"Executing query: {query}")
|
||||
|
||||
def generate_report(self, users):
|
||||
"""Generate a simple report"""
|
||||
report = {
|
||||
'total_users': len(users),
|
||||
'average_age': sum(u['age'] for u in users) / len(users) if users else 0,
|
||||
'generated_at': time.time()
|
||||
}
|
||||
print(f"Report: {report}")
|
||||
|
||||
def send_notifications(self, users):
|
||||
"""Send notifications to users"""
|
||||
for user in users:
|
||||
message = f"Welcome {user['name']}!"
|
||||
print(f"Sending notification: {message}")
|
||||
|
||||
def cleanup_old_data(self):
|
||||
"""Cleanup old data from database"""
|
||||
print("Cleaning up old data...")
|
||||
|
||||
def function_with_multiple_returns(value):
|
||||
"""Function with multiple return points"""
|
||||
if value < 0:
|
||||
return "negative"
|
||||
elif value == 0:
|
||||
return "zero"
|
||||
elif value < 10:
|
||||
return "small"
|
||||
elif value < 100:
|
||||
return "medium"
|
||||
else:
|
||||
return "large"
|
||||
|
||||
def function_with_long_line():
|
||||
"""Function with excessively long line"""
|
||||
very_long_string = "This is a very long string that exceeds the typical line length limit and should be broken up into multiple lines for better readability and maintainability in the codebase but it's all on one line which is bad practice"
|
||||
return very_long_string
|
||||
|
||||
# TODO: Fix this function later
|
||||
def deprecated_function():
|
||||
"""This function is deprecated but still in use"""
|
||||
print("This function is deprecated and should be removed")
|
||||
|
||||
# FIXME: This function has a bug
|
||||
def buggy_function():
|
||||
"""Function with known bug"""
|
||||
result = []
|
||||
for i in range(10):
|
||||
result.append(i)
|
||||
# Bug: This will cause infinite loop
|
||||
if i == 5:
|
||||
i = 0 # This resets the loop counter
|
||||
return result
|
||||
|
||||
# HACK: Quick fix for production
|
||||
def quick_fix():
|
||||
"""Temporary fix that should be refactored"""
|
||||
# This is a quick hack to get things working
|
||||
data = {"temp": True, "fix": "urgent"}
|
||||
return json.dumps(data)
|
||||
|
||||
def regex_complexity():
|
||||
"""Function with overly complex regular expression"""
|
||||
import re
|
||||
|
||||
# Complex regex that's hard to understand
|
||||
complex_pattern = r'^((?P<protocol>https?|ftp):\/\/)?((?P<user>[^:@]+)(?::(?P<password>[^@]+))?@)?(?P<host>[^\/?:]+)(?::(?P<port>\d+))?(?P<path>\/[^?]*)?(?:\?(?P<query>[^#]*))?(?:#(?P<fragment>.*))?$'
|
||||
|
||||
text = "https://user:pass@example.com:8080/path?query=value#fragment"
|
||||
match = re.match(complex_pattern, text)
|
||||
|
||||
if match:
|
||||
return match.groupdict()
|
||||
return None
|
||||
|
||||
def duplicate_code_example():
|
||||
"""Example of code duplication"""
|
||||
# Processing user data
|
||||
users = [{"name": "Alice", "age": 25}, {"name": "Bob", "age": 30}]
|
||||
|
||||
# Duplicate processing logic
|
||||
for user in users:
|
||||
if user['age'] >= 18:
|
||||
print(f"{user['name']} is an adult")
|
||||
user['status'] = 'adult'
|
||||
else:
|
||||
print(f"{user['name']} is a minor")
|
||||
user['status'] = 'minor'
|
||||
|
||||
# Duplicate logic with slight variation
|
||||
for user in users:
|
||||
if user['age'] >= 21:
|
||||
print(f"{user['name']} can drink alcohol")
|
||||
user['can_drink'] = True
|
||||
else:
|
||||
print(f"{user['name']} cannot drink alcohol")
|
||||
user['can_drink'] = False
|
||||
|
||||
def unused_variables():
|
||||
"""Function with unused variables"""
|
||||
active = True
|
||||
debug_mode = False
|
||||
version = "1.0.0"
|
||||
timestamp = time.time()
|
||||
|
||||
# Many variables defined but never used
|
||||
config = {"setting1": True, "setting2": False}
|
||||
metadata = {"created": timestamp, "version": version}
|
||||
temp_data = []
|
||||
|
||||
# Only one variable is actually used
|
||||
print(f"Application version: {version}")
|
||||
|
||||
def deep_function_nesting():
|
||||
"""Function with extremely deep nesting"""
|
||||
data = {"users": []}
|
||||
|
||||
# Level 1
|
||||
if data.get("users"):
|
||||
# Level 2
|
||||
for user in data["users"]:
|
||||
# Level 3
|
||||
if user.get("active"):
|
||||
# Level 4
|
||||
if user.get("profile"):
|
||||
# Level 5
|
||||
if user["profile"].get("settings"):
|
||||
# Level 6
|
||||
if user["profile"]["settings"].get("notifications"):
|
||||
# Level 7
|
||||
if user["profile"]["settings"]["notifications"].get("email"):
|
||||
# Level 8
|
||||
if user["profile"]["settings"]["notifications"]["email"].get("enabled"):
|
||||
# Level 9
|
||||
if user["profile"]["settings"]["notifications"]["email"]["enabled"] == True:
|
||||
# Level 10
|
||||
print("Email notifications enabled")
|
||||
# Level 11
|
||||
for preference in user["profile"]["settings"]["notifications"]["email"].get("preferences", []):
|
||||
# Level 12
|
||||
if preference.get("active"):
|
||||
# Level 13
|
||||
print(f"Processing preference: {preference['name']}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Run some of the problematic functions
|
||||
print("Running sample code with various issues...")
|
||||
|
||||
# This will demonstrate the code issues
|
||||
very_long_function_with_many_parameters_and_complex_logic(
|
||||
"test", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
|
||||
)
|
||||
|
||||
processor = UserProcessor()
|
||||
sample_users = [
|
||||
{"name": "Alice", "email": "alice@example.com", "age": 25},
|
||||
{"name": "Bob", "email": "bob@example.com", "age": 30}
|
||||
]
|
||||
processor.process_users(sample_users)
|
||||
|
||||
print("Sample code execution complete!")
|
||||
print("This code contains many issues that the Roast Bot will identify!")
|
223
examples/sample-commit-messages.md
Normal file
223
examples/sample-commit-messages.md
Normal file
@@ -0,0 +1,223 @@
|
||||
# Sample Commit Messages for CI/CD Chaos
|
||||
|
||||
This file contains examples of commit messages that would be judged by the AI Commit Message Judge.
|
||||
|
||||
## Excellent Commit Messages (Grade A+)
|
||||
|
||||
### Conventional Commits
|
||||
```
|
||||
feat(auth): add OAuth2 integration for third-party providers
|
||||
|
||||
Implement OAuth2 authentication flow for Google, GitHub, and Microsoft
|
||||
providers. This allows users to sign in using their existing accounts instead
|
||||
of creating new credentials.
|
||||
|
||||
Technical details:
|
||||
- Added OAuth2 client configuration
|
||||
- Implemented token validation and refresh
|
||||
- Created user profile synchronization
|
||||
- Updated login UI with provider buttons
|
||||
- Added security headers for CSRF protection
|
||||
|
||||
This addresses user feedback requesting easier sign-in options and should
|
||||
increase user conversion rates.
|
||||
|
||||
BREAKING CHANGE: Removed basic authentication for new sign-ups
|
||||
```
|
||||
|
||||
```
|
||||
fix(api): resolve memory leak in user service
|
||||
|
||||
Fixed memory leak in user service where cached user objects were not properly
|
||||
cleared from memory after session timeout. This was causing gradual memory
|
||||
consumption increase leading to service restarts every 24 hours.
|
||||
|
||||
The issue was in the cache eviction logic where the cleanup task wasn't
|
||||
properly removing expired entries from all cache layers.
|
||||
|
||||
Metrics show memory usage decreased by 40% after this fix.
|
||||
```
|
||||
|
||||
### Well-Structured Feature
|
||||
```
|
||||
feat: implement real-time notifications
|
||||
|
||||
Add WebSocket-based real-time notification system that allows users to receive
|
||||
instant updates for their activities. This replaces the previous polling-based
|
||||
system and reduces server load by 60%.
|
||||
|
||||
Key features:
|
||||
- Real-time message delivery
|
||||
- Connection state management
|
||||
- Offline message queuing
|
||||
- Battery-efficient background syncing
|
||||
- Push notification integration
|
||||
|
||||
Performance improvements:
|
||||
- Reduced API calls from 6/min to 1/session
|
||||
- Decreased server CPU usage by 25%
|
||||
- Improved user experience with instant feedback
|
||||
|
||||
Closes #1234, #5678
|
||||
```
|
||||
|
||||
## Good Commit Messages (Grade B)
|
||||
|
||||
### Clear and Concise
|
||||
```
|
||||
feat: add user profile caching
|
||||
|
||||
Implement Redis-based caching for user profiles to reduce database queries.
|
||||
Cache keys include user ID and last modified timestamp for automatic invalidation.
|
||||
```
|
||||
|
||||
```
|
||||
fix: resolve login page styling issues
|
||||
|
||||
Fixed CSS compatibility issues with Safari and improved mobile responsiveness.
|
||||
Added proper viewport meta tag and fixed flexbox layout problems.
|
||||
```
|
||||
|
||||
## Needs Improvement (Grade C)
|
||||
|
||||
### Vague Description
|
||||
```
|
||||
update files
|
||||
|
||||
Updated several configuration files and added new logging functionality.
|
||||
```
|
||||
|
||||
```
|
||||
fix bug
|
||||
|
||||
Fixed the authentication bug that was preventing users from logging in.
|
||||
```
|
||||
|
||||
## Poor Commit Messages (Grade D)
|
||||
|
||||
### Too Short
|
||||
```
|
||||
wip
|
||||
```
|
||||
|
||||
```
|
||||
stuff
|
||||
```
|
||||
|
||||
### Too Long
|
||||
```
|
||||
I made a lot of changes to the codebase today. I fixed some bugs in the authentication system, added new features to the user interface, updated the database schema, modified the API endpoints, added unit tests, integrated third-party services, configured deployment settings, and updated documentation. This was a really big day of coding and I'm tired but proud of what I accomplished. The team will be happy with these improvements.
|
||||
|
||||
Let me break down what I did:
|
||||
|
||||
1. Authentication fixes
|
||||
2. UI improvements
|
||||
3. Database changes
|
||||
4. API updates
|
||||
5. Testing
|
||||
6. Third-party integration
|
||||
7. Deployment
|
||||
8. Documentation
|
||||
|
||||
I think that covers everything. Let me know if you have any questions!
|
||||
```
|
||||
|
||||
## Terrible Commit Messages (Grade F)
|
||||
|
||||
### Unprofessional
|
||||
```
|
||||
lol this commit fixes everything trust me
|
||||
|
||||
I don't know what I did but it works now. Magic!
|
||||
```
|
||||
|
||||
```
|
||||
why doesn't this work?????
|
||||
|
||||
I've been trying to fix this for hours. Maybe this will work?
|
||||
```
|
||||
|
||||
### Violates Best Practices
|
||||
```
|
||||
Fixed the thing.
|
||||
|
||||
Not sure what I changed but it's working now.
|
||||
Don't touch this code!
|
||||
```
|
||||
|
||||
```
|
||||
commit
|
||||
|
||||
This is a commit. Yes it is.
|
||||
```
|
||||
|
||||
## Challenge Examples for Commit Message Judge
|
||||
|
||||
### The Conventional Commit Challenge
|
||||
```
|
||||
feat(payment): integrate Stripe payment processing
|
||||
|
||||
Add Stripe integration for processing credit card payments. Includes:
|
||||
- Payment form validation
|
||||
- Card tokenization
|
||||
- Transaction processing
|
||||
- Error handling
|
||||
- Webhook integration for payment status updates
|
||||
|
||||
Implements requirements from payment processing specification.
|
||||
```
|
||||
|
||||
### The Perfect Imperative Challenge
|
||||
```
|
||||
Refactor user service to improve code maintainability
|
||||
|
||||
Extract common functionality into helper methods and improve error handling.
|
||||
Add comprehensive unit tests and update documentation.
|
||||
```
|
||||
|
||||
### The Minimalist Masterpiece
|
||||
```
|
||||
Fix typo in user registration email template.
|
||||
```
|
||||
|
||||
## Humorous Examples (That Still Follow Best Practices)
|
||||
|
||||
```
|
||||
feat: add coffee machine integration to office dashboard
|
||||
|
||||
Connect office coffee machine to dashboard API for real-time monitoring.
|
||||
Tracks coffee levels, brewing status, and maintenance needs.
|
||||
|
||||
Prevents developers from encountering empty coffee pots during critical coding sessions.
|
||||
Should improve team productivity by 42% (unofficial metric).
|
||||
```
|
||||
|
||||
```
|
||||
fix: resolve infinite loop in Friday afternoon code
|
||||
|
||||
Fixed bug where Friday afternoon code created infinite loop due to
|
||||
developer's brain being on weekend mode. Added proper exit condition.
|
||||
|
||||
Note: This only happens on Fridays between 4-6 PM. Coincidence? I think not.
|
||||
```
|
||||
|
||||
## Testing Examples
|
||||
|
||||
### Test your commit messages with the AI Judge:
|
||||
|
||||
```bash
|
||||
# Judge a single commit message
|
||||
python3 scripts/commit-judge.py "feat: add user authentication system"
|
||||
|
||||
# Judge a multi-line commit message
|
||||
python3 scripts/commit-judge.py "feat: add user authentication system
|
||||
|
||||
Implement JWT-based authentication with password hashing and session management.
|
||||
Added security middleware and rate limiting to prevent brute force attacks."
|
||||
|
||||
# Generate a writing challenge
|
||||
python3 scripts/commit-judge.py --challenge
|
||||
```
|
||||
|
||||
Remember: Good commit messages help your team understand what changed and why.
|
||||
The AI Commit Message Judge is here to help you improve your commit hygiene! 🎪
|
Reference in New Issue
Block a user