| name | code-quality |
| description | Use when checking code style, running pre-commit hooks, or before committing changes to ensure compliance with Google style guide |
Code Quality
Code Style
- Standard: Google C++ Style Guide
- Line limit: 120 characters
- Indent: 4 spaces
- Config: See
.clang-format in repo root
Pre-commit Hooks
Setup
pip3 install pre-commit
pre-commit install --hook-type pre-commit --hook-type pre-push
Usage
pre-commit run
pre-commit run --files src/index/hnsw/hnsw.cc include/knowhere/index/index.h
pre-commit run --all-files
Commit Workflow
pre-commit run --files <changed-files>
git add .
git commit -m "message"
Common Issues
| Issue | Solution |
|---|
| Formatting errors | Run clang-format -i <file> or let pre-commit fix it |
| Line too long | Break line at logical points, max 120 chars |
| Include order | Follow Google style: related header, C system, C++ standard, other libs, project headers |
Pre-commit hooks run automatically on commit. Fix any failures before pushing.