Skip to content

← Firmware Downloads

Post-install setup · Reborn (Y2Linux) · Y2

Coding standard: Y2Linux platform and Y2Reborn

Debian-based Linux with a fast clickwheel interface for the Innioasis Y2.

Instructions published by the project, shown here word for word.

Coding standard: Y2Linux platform and Y2Reborn

Production code only. This is how the platform (platform/crates) and Reborn (../Y2Reborn) are written since Beta 9.1; every rule below is already true of the code, and the gate keeps it so. New code meets it from its first commit; old code that does not is listed in the ratchet's baseline and only ever gets better.

1. What the gate enforces

tools/development/platform-gate.sh must print GATE OK before any commit (Reborn work included: the gate builds Reborn's contract test and measures Reborn's code). It runs:

CheckRule
cargo fmtformatted; and rustfmt must be able to format it (see long lines below)
cargo clippy --all-targetsno warning
cargo check --target armv7-unknown-linux-gnueabihfbuilds for the player
tools/development/code-quality.pythe ratchet (section 2)
cargo test and the golden suitesno failure; every recorded answer of every command unchanged unless re-recorded on purpose
tools/development/record-compat.pyan older build can still read every /data record this one writes
Reborn contract testReborn reads every recorded platform answer as before

Reborn on its own: cargo fmt --all, cargo clippy --workspace --all-targets (no warning), `cargo test --workspace` (no failure), then the gate.

2. The ratchet (code-quality.py)

Measured on production code (tests excluded) against tools/development/code-quality-baseline.json. Nothing may get worse; an improvement is recorded with --update and its baseline diff is part of the commit.

The length limits are ceilings, not targets (owner, 2026-10-31): a function or file between the aim and the ceiling passes, so a small fix never has to start with a refactor. Split code when it reads better, not to win a line back.

MeasureLimit for new codeExisting exceptions
Function lengthaim for ≤ 100 lines; the gate stops at 150over 150: listed; may only shrink
File lengthaim for ≤ 1000 lines; the gate stops at 1500over 1500: listed; may only shrink
unsafeonly in the crates that have it today, never moreper crate
.unwrap() / .expect(none in production paths (an invariant gets expect("why it holds"))per crate
panic! / todo! / unimplemented! / unreachable!noneper crate
#[allow(…)]none without a comment whyper crate
Raw JSON field lookups ["field"]none: read records in their typesper file
Code lines over 100 columnsnone (rustfmt gives up on a function containing one)per file
TODO / FIXME / XXX / HACKnone, ever—

3. Shape of the code

Functions do one thing and are named for it. A long sequence becomes named steps, not comments:

Modules are named for what they do (playback/decode.rs, runtime/sleep.rs), tests live next to them in *_tests.rs or a tests/ module, and a file's first line (//!) says what it is for.

4. Records and the platform contract

5. Errors, unsafe, panics

6. Comments and documentation

7. Changing code

Published by the schulzcode/y2linux project [1] [3]