Thank you for considering contributing to Hyp, a Rust code quality and analysis toolkit. This project is designed to be extensible (custom checkers, custom CLIs) and educational (problem examples that compile but are problematic), so contributions in both code and docs are very welcome.
Before large changes, please scan:
README.mdfor the overall vision and conceptual modelcrates/hyp-checks-generic/README.mdfor checker architecture and macroscrates/hyp/BUILD_YOUR_OWN_HYP_CLI.mdfor custom CLI patterns
If you plan a substantial redesign, new category family, or major API change, please open an issue first so we can align on direction.
-
Fork and clone
- Fork the repository on your Git hosting service
- Clone your fork locally and add the original repo as
upstreamif you like
-
Set up Rust toolchain
- Install a recent stable Rust (via
rustup) - Recommended components:
rustfmt(for formatting)clippy(for lints, where applicable)
- Install a recent stable Rust (via
-
Build and test
-
From the repo root:
make build # ensure compilation make test # run all unit tests and ensure problem examples are compilable and executable
-
Run the analyzer CLI against the bundled problem examples:
cargo run --bin hyp -- -s crates/hyp-examples/src -v cargo run --bin hyp -- --list
-
-
crates/hyp-examples/Compilable but problematic Rust snippets, grouped by categoriesE10–E18. -
crates/hyp-checks-generic/Core analysis library with:define_checker!andregister_checker!macros- Checker trait and registry
- Analyzer configuration and violation reporting
-
crates/hyp/Reference CLI that wires the analyzer into a usablehypbinary. Also containsBUILD_YOUR_OWN_HYP_CLI.mdshowing how to build your owncargo hyp-myproject.
The top-level README.md explains the conceptual model, built-in categories, and how Hyp differs
from tools like Clippy, Kani, Miri, Prusti, and MIRAI.
These live in crates/hyp-examples/src/ and are grouped by category, e.g.:
e10_unsafe_code/e11_code_surface_complexity/e14_type_safety/
Goal: Realistic Rust code that compiles but illustrates a specific problematic pattern.
-
Do:
- Keep examples as small as possible while still realistic.
- Include comments/docstrings explaining the problem and mitigation.
- Reference the relevant checker code (e.g.
E1002,E1401) in the file name and docs.
-
Checklist when adding an example:
- Add a new
.rsfile in the appropriateeXX_...folder. - Make sure it compiles with
cargo test -p hyp-examples(or fullcargo test). - Update any listing/registry in the hyp-examples crate if needed.
- Add a new
Checkers live in crates/hyp-checks-generic/src/checkers/ under:
e10/,e11/,e12/, …,e18/
Each checker is implemented with the define_checker! macro and usually follows the
patterns in:
e10/e1001_direct_panic.rse11/e1106_long_function.rse14/e1401_integer_overflow.rs
Basic steps to add a checker:
-
Pick a code and category
- Use the roadmap table in
crates/hyp-checks-generic/README.mdto find the next free code (or extend with a new checker not yet listed).
- Use the roadmap table in
-
Create the checker file
- Place it in the appropriate module, e.g.
crates/hyp-checks-generic/src/checkers/e10/e1004_unsafe_without_comment.rs
- Use
define_checker!to declare:code(e.g."E1004")namesuggestionstarget_items(e.g.[Function])config_entry_name(TOML key, e.g."e1004_unsafe_without_comment")configstruct fields and defaultscheck_itembody that walks thesynAST and returnsVec<Violation>
- Place it in the appropriate module, e.g.
-
Register the checker
- Export checker + config in the group
mod.rs, e.g.checkers/e10/mod.rs - Add it to the group registry with
register_checker!, e.g.checkers/e10/registry.rs - Ensure
crates/hyp-checks-generic/src/registry.rsincludes the group (for new groups)
- Export checker + config in the group
-
Add tests
- Add unit tests in the same file:
- Positive cases (violations are reported).
- Negative cases (no violations).
- Use
syn::parse_fileand callchecker.check_item(&item, "test.rs").
- Add unit tests in the same file:
-
Update docs
- Mark the checker as supported in the roadmap table in
crates/hyp-checks-generic/README.md. - Optionally add or cross-link problem examples that showcase the pattern.
- Mark the checker as supported in the roadmap table in
-
Run tests
cargo test -p hyp-checks-genericcargo testat the workspace root.
The reference CLI lives in crates/hyp/.
You can:
- Improve UX (flags, output formats, listing checkers).
- Add examples or documentation for building project-specific CLIs.
For a full, opinionated guide on custom CLIs (like cargo hyp-myproject), see:
crates/hyp/BUILD_YOUR_OWN_HYP_CLI.md
If you add new CLI functionality, please:
- Add or update integration tests if applicable.
- Extend
crates/hyp/README.mdand/or the top-levelREADME.md.
High‑quality documentation is a core goal of Hyp.
Good contributions include:
- Clarifying existing docs or READMEs.
- Adding small, focused examples that make new features easy to understand.
- Improving cross‑links between:
README.mdcrates/hyp-checks-generic/README.mdcrates/hyp/BUILD_YOUR_OWN_HYP_CLI.md
When updating docs, keep headings and style consistent:
- Use
##/###headings. - Use bullet lists with short, focused sentences.
- Refer to files and modules with backticks, e.g.
crates/hyp-checks-generic/src/checkers/e10/.
-
Rust style
- Run
cargo fmtbefore committing. - Try to keep functions short and focused; new checkers should be readable examples.
- Run
-
Testing
- Prefer adding tests alongside the code you change.
- For checkers, aim for:
- 1–3 positive tests (violations).
- 1–3 negative tests (no violations).
-
Error handling
- Use
ResultandAnalyzerError(where applicable in the analyzer). - Prefer explicit error messages that help users understand misconfigurations.
- Use
- Open an issue (recommended for non-trivial changes)
- Describe what you want to add/change and why.
- Link to any relevant problem examples or external references.
Use a short prefix in your commit messages to make history easy to scan:
- feat: New feature (e.g., new checker, new CLI capability)
- fix: Bug fix (including incorrect checker behavior)
- docs: Documentation changes only (README, guides, comments)
- refactor: Internal code changes that don’t alter behavior
- test: Add or update tests without behavior changes
- chore: Tooling, dependency bumps, CI, formatting, trivial plumbing
Examples:
feat: add E1305 non-exhaustive match checkerfix: correct line number reporting in E1106LongFunctiondocs: clarify custom hyp-myproject CLI setuptest: add regression test for E1015 unwrap detection
-
Create a branch and implement the change
- Follow the guidelines above for checkers, examples, or CLI changes.
-
Run the full test suite
make test
-
Open a Pull Request
- Keep the PR focused on one logical change (one checker, one CLI feature, or one doc theme).
- In the PR description:
- Explain what you changed and why.
- Reference related issues or roadmap items (e.g. specific
E1xxxcodes).
-
Review and iterate
- Be prepared to discuss architectural trade‑offs (especially for new macros, registries, or configuration behavior).
- Small follow‑up commits to address review feedback are encouraged.
If you are unsure where to start:
- Browse the roadmap in
crates/hyp-checks-generic/README.mdand pick an unimplemented checker. - Look at existing checkers (
E1001,E1002,E1003,E1106,E1401,E1402,E1403) to understand the standard patterns. - Explore
crates/hyp-examples/and think about additional problematic patterns that deserve detection.
Thank you for helping make Hyp a better tool for Rust teams and for AI‑assisted development. 🙌