G0011 crate-folder-layer¶
Rule: A crate's folder is its layer in the map, then its discipline where the map gives one.
| Code | G0011 (stable, never reused) |
| Id | crate-folder-layer |
| Category | graph |
| Source | spirit_level |
| Fix | by hand |
| Needs | the crate map ([map] or map-file) |
Level per tier¶
| Tier | Level | Reason |
|---|---|---|
| small | off | |
| small-workspace | off | |
| medium | off | |
| big | deny |
the map decides the path: crates/ |
| ai | off | |
| embedded | off | |
| ui | off | |
| egui | off | |
| units-strict | off | |
| units-paranoid | off |
Parameters¶
| Name | Type | Default | Meaning |
|---|---|---|---|
root |
string | "crates" |
the folder that holds the crates, flat or in layer folders |
Why¶
A workspace past about a hundred crates is hard to browse as one flat crates/ folder: the listing stops telling what the parts are. Folders by layer make the map visible in the tree, and a layer of about a hundred crates or more splits once more by discipline. The map decides the path, so the tree and the map never disagree:
| Workspace | Path |
|---|---|
| small | crates/<crate> |
| large | crates/<layer>/<crate> |
| a large layer | crates/<layer>/<discipline>/<crate> |
Never deeper: a third folder level is a sign the layers are cut wrong.
A flat workspace passes. Once any crate sits in a layer folder, or the map gives any crate a discipline, every mapped crate under the root sits in its layer folder.
[map.crates]
it_fem = { layer = "kernel" } # crates/kernel/it_fem
it_antenna = { layer = "engines", discipline = "rf" } # crates/engines/rf/it_antenna
How to fix¶
Move the crate to the folder its map entry names, and update the members globs (crates/*/*, crates/*/*/*). When the folder is right and the map is wrong, fix the map. crate-folder-size says when a folder has grown too big.
Configure¶
[lints.crate-folder-layer]
level = "deny"
root = "crates"
reason = "why this project wants it at this level"
Allow one finding in the code with // spirit-level: allow(crate-folder-layer) <reason> (waivers); the code works there too, as in [lints.G0011].