Skip to content

S0006 crate-folder-size

Rule: A folder holds no more crate folders than its limit.

Code S0006 (stable, never reused)
Id crate-folder-size
Category size
Source spirit_level
Fix by hand

Level per tier

Tier Level Reason
small off
small-workspace off
medium warn a flat crates/ past a few dozen crates groups by layer; a layer of about 100 crates by discipline
big deny a flat crates/ past a few dozen crates groups by layer; a layer of about 100 crates by discipline
ai off
embedded off
ui off
egui off
units-strict off
units-paranoid off

Parameters

Name Type Default Meaning
max-flat integer 80 crate folders side by side in a folder that is not a layer folder (a flat crates/) above which it is reported
max-crates integer 100 crate folders in one layer or discipline folder above which it is reported

Why

A flat crates/ folder reads well up to a few dozen crates: prefixes group them, and the listing fits a screen. Past that the listing stops telling what the parts are, and finding a crate means knowing its name. A large workspace puts its crates in layer folders (crates/<layer>/<crate>), and a layer of about a hundred crates or more splits once more by discipline (crates/engines/rf/<crate>), never deeper (crate-folder-layer).

The lint counts the crate folders directly inside each folder that holds crates. A folder named after a layer of the crate map, or inside one, is held to max-crates; any other folder, such as a flat crates/, to max-flat.

How to fix

A flat folder past max-flat: give every crate its layer folder, as the map's layers say, and update the members globs. A layer folder past max-crates: give its crates a discipline in the map and move each into crates/<layer>/<discipline>/<crate>.

Configure

[lints.crate-folder-size]
level = "deny"
max-flat = 80
max-crates = 100
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(crate-folder-size) <reason> (waivers); the code works there too, as in [lints.S0006].