|
| 1 | +# 🤝 Contributing to aiverify |
| 2 | + |
| 3 | +First off, thank you for considering contributing to aiverify! Every star, issue, and pull request helps make AI-generated code safer for everyone. |
| 4 | + |
| 5 | +## ⭐ Support the Project |
| 6 | + |
| 7 | +- **Star the repo** — it helps others discover aiverify |
| 8 | +- **Sponsor** — [GitHub Sponsors](https://github.com/sponsors/FMATheNomad) supports a solo founder |
| 9 | +- **Share** — tell your team about aiverify on [Twitter](https://x.com/intent/tweet?text=Verify%20AI-generated%20code%20before%20you%20commit%E2%80%94aiverify%20catches%20hallucinations%20in%20Claude%2C%20Copilot%2C%20Cursor%2C%20ChatGPT%20code.&url=https://github.com/FMATheNomad/aiverify) |
| 10 | + |
| 11 | +## 🧠 Adding a New Rule |
| 12 | + |
| 13 | +1. **Create the rule class** in `aiverify/rules/` extending `BaseRule`: |
| 14 | + |
| 15 | +```python |
| 16 | +from .base import BaseRule |
| 17 | + |
| 18 | +class MyNewRule(BaseRule): |
| 19 | + name = "my-new-rule" |
| 20 | + code = "PY006" # or JS006, GEN006 |
| 21 | + description = "What this rule detects" |
| 22 | + severity = "warning" # error | warning | info |
| 23 | + language = "python" # python | javascript | generic |
| 24 | + |
| 25 | + def check(self, tree, source: bytes) -> list[Finding]: |
| 26 | + # Use tree-sitter queries here (NOT regex) |
| 27 | + # Return list of Finding objects |
| 28 | + pass |
| 29 | +``` |
| 30 | + |
| 31 | +2. **Register the rule** — add it to the `*_RULES` list in the appropriate module (`python_rules.py`, `js_rules.py`, or `generic.py`) |
| 32 | + |
| 33 | +3. **Add tests** in `tests/test_rules.py`: |
| 34 | + - Test that the rule detects the bad pattern |
| 35 | + - Test that clean code doesn't trigger false positives |
| 36 | + |
| 37 | +4. **Run tests**: |
| 38 | +```bash |
| 39 | +python -m pytest tests/ -v |
| 40 | +``` |
| 41 | + |
| 42 | +### Rule Guidelines |
| 43 | + |
| 44 | +- ✅ **Must use tree-sitter queries** — no regex-based AST analysis |
| 45 | +- ✅ **Must have tests** — both positive (detects pattern) and negative (no false positive) |
| 46 | +- ✅ **Must handle edge cases** — empty files, syntax errors, nested structures |
| 47 | +- ❌ **No false positives** — better to miss a pattern than to flag clean code |
| 48 | +- ❌ **No external dependencies** — keep it self-contained |
| 49 | + |
| 50 | +## 🐛 Reporting Issues |
| 51 | + |
| 52 | +Open an issue at https://github.com/FMATheNomad/aiverify/issues with: |
| 53 | +- The command you ran |
| 54 | +- The output (or error message) |
| 55 | +- A minimal example that reproduces the issue |
| 56 | +- Your Python version and OS |
| 57 | + |
| 58 | +## 📦 Development Setup |
| 59 | + |
| 60 | +```bash |
| 61 | +git clone https://github.com/FMATheNomad/aiverify.git |
| 62 | +cd aiverify |
| 63 | +python -m venv venv |
| 64 | +source venv/bin/activate |
| 65 | +pip install -r requirements.txt |
| 66 | +pip install -e . |
| 67 | +python -m pytest tests/ -v |
| 68 | +``` |
| 69 | + |
| 70 | +## 📜 Code of Conduct |
| 71 | + |
| 72 | +Be respectful. Be constructive. Be excellent to each other. This is a solo founder project running on kindness and coffee. |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | +*Built by a solo founder. Every star & sponsor helps keep this project alive.* 🙏 |
0 commit comments