A Python tool for enforcing code quality standards through ratchet tests. CodeRatchet helps teams maintain and improve code quality by preventing the introduction of specific patterns or practices that have been identified as problematic. It's particularly useful for gradually improving legacy codebases by enforcing stricter standards over time.
- Regex-based Pattern Matching: Define code patterns to detect and prevent
- Two-Pass Analysis: Complex pattern matching with context awareness
- Git Integration: Track violations across commits and branches
- CI/CD Support: Easy integration with continuous integration pipelines
- Customizable Rules: Create and share custom ratchet tests
- Performance Optimized: Fast analysis even on large codebases
pip install coderatchet- Create a configuration file (
coderatchet.yaml):
ratchets:
basic:
enabled: true
config: {}
custom:
enabled: true
config:
function_length:
max_lines: 50- Use CodeRatchet in your Python code:
from coderatchet.core.config import RatchetConfigManager
from coderatchet.core.ratchet import run_ratchets_on_file
# Initialize configuration
config = RatchetConfigManager("coderatchet.yaml")
# Get configured ratchets
ratchets = config.get_ratchets()
# Run checks on a file
results = run_ratchets_on_file("your_file.py", ratchets)Check out the examples directory for:
- Basic usage examples
- Custom ratchet tests
- Advanced configurations
- Real-world scenarios
We welcome contributions! Please see our Contributing Guide for details.
This project is licensed under the MIT License - see the LICENSE file for details.