diff --git a/AGENTS.md b/AGENTS.md index aa013ed..db8fcc4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -42,6 +42,18 @@ and this file is for what someone changing worklane's own code needs. - `setup_worklane()` creates temp `.worklane/` with all four status folders pre-created, plus `campaigns/` in `cmd_campaign.rs`, which is also where the on-demand creation is tested from a board without it - `create_ticket()` writes fully-formed markdown files directly (no `--` separator for positional args in test commands) - **`cargo clippy --all-targets` is clean. Keep it clean**, and do not silence a lint that is pointing at something real. The only two `allow`s in the tree sit on the `create_ticket` fixtures in `cmd_mv.rs` and `cmd_show.rs`, each carrying the reason and what would replace it +- **`cargo fmt --check` is clean too, and `rustfmt.toml` is what makes that affordable.** rustfmt is the formatter here, run it. The config is four stable width settings and nothing else: + + | setting | value | why | + |---|---|---| + | `max_width` | 100 | The tree's own habit, and the measured optimum: 90 costs 268 hunks and 120 costs 194, against 161 at 100 | + | `fn_call_width` | 75 | A call stays whole if it fits in three quarters of the line. rustfmt's default of 60 is what expanded 276 of the 305 hunks the default config wanted | + | `chain_width` | 65 | The same for a method chain | + | `struct_lit_width` | 30 | A small struct literal stays whole, so `Size { width: 120, height: 20 }` is not six lines | + + **The numbers were measured, not chosen.** Default rustfmt wanted 305 hunks and would have added 1418 lines of pure layout, because its sub-widths sit far below the 100 columns this tree is written to. `use_small_heuristics = "Max"` went the other way, 308 hunks and 796 lines *removed*, one-lining `if`/`else` and collapsing struct literals that were split on purpose. Coordinate descent over the stable width knobs landed here, at 161 hunks, and 98 of those are rustfmt *joining* calls that fit rather than breaking them. Sweeping any one of these four in either direction makes the diff bigger, so do not adjust one by eye; measure it the same way, with `cargo fmt --check | grep -c '^Diff in'` + - What this does not buy: rustfmt has no rule for "keep parallel arms parallel", so a match whose arms are one line and four lines depending on the length of their contents is what it produces, and that is accepted. Reach for `#[rustfmt::skip]` only where the layout carries meaning a reader needs, not to win an argument about density + - Do not add an unstable option. `cargo fmt` on stable ignores them with a warning, so the tree would format differently for whoever ran nightly ## Coding Guidelines diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..fffd85d --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,22 @@ +# rustfmt is the formatter for this tree, and these four widths are what make it agree +# with how the tree is already written. Measured, not chosen: the default config wanted +# 305 hunks and +1418 lines of layout, `use_small_heuristics = "Max"` wanted 308 the +# other way, and this lands at 161. The reasoning is in AGENTS.md beside the clippy rule. +# +# Sweeping any one of these in either direction makes the diff bigger. Measure before +# changing one: `cargo fmt --check | grep -c '^Diff in'`. + +# The habit the tree is written to, and the measured optimum: 90 costs 268 hunks, 120 +# costs 194. +max_width = 100 + +# A call stays whole if it fits in three quarters of the line. rustfmt's default of 60 +# is what expands 276 of the 305 hunks the default config wants. +fn_call_width = 75 + +# The same for a method chain. +chain_width = 65 + +# A small struct literal stays whole, so `Size { width: 120, height: 20 }` is not six +# lines. Above the default of 18, which is what explodes it. +struct_lit_width = 30