Contributing
Bug reports, ideas and pull requests are all welcome. For anything bigger than a small fix, open an issue first so the approach can be discussed.
Building and testing
The project is a Rust workspace. The justfile has the commands CI runs:
just test # run all tests
just clippy # lint, with warnings as errors
just format # format the code
just doc # build the API docs, with warnings as errors
just docs # build the book and check its links
Parts of the docs are generated from the code, like the table of lint rules.
Tests fail when they fall behind, and just update-docs regenerates them.
Most formatter tests are insta snapshot tests. When a change alters the
output, review the new snapshots with cargo insta review before accepting
them. Every bug fix should come with a snapshot that shows the fixed case.
The docs are an mdBook under docs/. Run mdbook serve docs to preview them,
and just docs to build them and check every link with lychee, the same way
CI does.
Where things live
| Crate | Contains |
|---|---|
rafiki | The command line tool |
monkey-c-parser | The lexer, parser and syntax tree |
monkey-c-formatter | The formatter |
monkey-c-linter | The lint rules and their fixes |
monkey-c-lsp | The language server |
monkey-c-config | The rafiki.toml format |
monkey-c-coverage | The source rewriting behind rafiki coverage |
monkey-c-jungle | A parser and printer for jungle files |
Adding a lint rule
- Add a module under
monkey-c-linter/src/ruleswith acheck_exprorcheck_stmtfunction that returns aDiagnostic, and a fix if one is safe. - Call it from the matching
dispatch_*function invisit.rs. - Add it to
rules::ALLwith a one-line summary and whether it has a fix. The command line and the Rules table are built from it. - Add tests next to the rule for what it flags and what it leaves alone.
- Add a page at
docs/src/linter/rules/<name>/README.md, list it indocs/src/SUMMARY.mdand runjust update-docsto add it to the rules table.