Skip to content

refactor(geometry): reuse the canonical component_kind helper - #233

Merged
LeadcodeDev merged 1 commit into
chantier/audit-2026-09from
refactor/component-kind-dedup
Sep 22, 2026
Merged

LeadcodeDev merged 1 commit into
chantier/audit-2026-09from
refactor/component-kind-dedup

Conversation

@LeadcodeDev

Copy link
Copy Markdown
Owner

Severity Low, category quality. Location: crates/rustmotion/src/cli/commands/geometry.rs:1158

Impact

rustmotion_components::box_builder::component_kind (box_builder.rs:2090-2154) is public and already imported elsewhere in the same crate (crates/rustmotion/src/engine/render/scene.rs:744). geometry.rs re-implements it as a private 60-arm copy. Both must be edited for every new component, and both already carry the same two label bugs: QrCode(_) => "qrcode" while the serde tag is qr_code, and Container(_) => "container" while the serde tag is div. Those strings are user-facing — they are the component: field of every GeometryViolation and drive the hint branches at geometry.rs:686 and :1591 — so a violation on a qr_code reports a type name that does not exist in the schema. Exhaustiveness protects against a missing arm but not against the two copies drifting on a rename, which is exactly how the labels got out of sync with serde in the first place.

Fix

Delete the geometry.rs copy and use rustmotion::components::box_builder::component_kind;. In the surviving copy, return the actual serde tags ("qr_code", "div") — or better, derive the label from the schema so it cannot drift from #[serde(tag = "type", rename_all = "snake_case")] at all.

Evidence the audit read

fn component_kind(c: &Component) -> &'static str {
    match c {
        Component::Text(_) => "text",
        Component::Shape(_) => "shape",
        ...
        Component::QrCode(_) => "qrcode",
        ...
    }
}

Stacked on fix/geometry-autoscroll-box, which carries the previous finding of this workstream. GitHub shows only this finding's diff; merge in order.

Part of the September 2026 audit remediation chantier. Refs #220 (RM-40).

@LeadcodeDev LeadcodeDev added the bug Something isn't working label Sep 21, 2026
@LeadcodeDev LeadcodeDev self-assigned this Sep 21, 2026
@LeadcodeDev
LeadcodeDev force-pushed the fix/geometry-autoscroll-box branch from 2e3c60c to 6bc338b Compare September 21, 2026 23:39
@LeadcodeDev
LeadcodeDev force-pushed the refactor/component-kind-dedup branch from bbccc33 to b97b212 Compare September 21, 2026 23:39
@LeadcodeDev
LeadcodeDev force-pushed the fix/geometry-autoscroll-box branch from e689845 to d9e3be1 Compare September 22, 2026 06:09
@LeadcodeDev
LeadcodeDev force-pushed the refactor/component-kind-dedup branch from 20d4bb8 to 5ea58df Compare September 22, 2026 06:09
@LeadcodeDev
LeadcodeDev force-pushed the fix/geometry-autoscroll-box branch from d9e3be1 to 9af265d Compare September 22, 2026 08:34
@LeadcodeDev
LeadcodeDev force-pushed the refactor/component-kind-dedup branch from 5ea58df to face008 Compare September 22, 2026 08:34
@LeadcodeDev
LeadcodeDev force-pushed the fix/geometry-autoscroll-box branch from 9af265d to 2793eea Compare September 22, 2026 08:43
@LeadcodeDev
LeadcodeDev force-pushed the refactor/component-kind-dedup branch from face008 to cbeb67a Compare September 22, 2026 08:43
@LeadcodeDev
LeadcodeDev changed the base branch from fix/geometry-autoscroll-box to chantier/audit-2026-09 September 22, 2026 08:52
`rustmotion_components::box_builder::component_kind` (box_builder.rs:2090-2154) is public and already imported elsewhere in the same crate (`crates/rustmotion/src/engine/render/scene.rs:744`). geometry.rs re-implements it as a private 60-arm copy. Both must be edited for every new component, and both already carry the same two label bugs: `QrCode(_) => "qrcode"` while the serde tag is `qr_code`, and `Container(_) => "container"` while the serde tag is `div`. Those strings are user-facing — they are the `component:` field of every `GeometryViolation` and drive the hint branches at geometry.rs:686 and :1591 — so a violation on a `qr_code` reports a type name that does not exist in the schema. Exhaustiveness protects against a *missing* arm but not against the two copies drifting on a rename, which is exactly how the labels got out of sync with serde in the first place.

Refs #220
@LeadcodeDev
LeadcodeDev force-pushed the refactor/component-kind-dedup branch from cbeb67a to 1d56385 Compare September 22, 2026 08:59
@LeadcodeDev
LeadcodeDev merged commit 03942a1 into chantier/audit-2026-09 Sep 22, 2026
LeadcodeDev added a commit that referenced this pull request Sep 22, 2026
`rustmotion_components::box_builder::component_kind` (box_builder.rs:2090-2154) is public and already imported elsewhere in the same crate (`crates/rustmotion/src/engine/render/scene.rs:744`). geometry.rs re-implements it as a private 60-arm copy. Both must be edited for every new component, and both already carry the same two label bugs: `QrCode(_) => "qrcode"` while the serde tag is `qr_code`, and `Container(_) => "container"` while the serde tag is `div`. Those strings are user-facing — they are the `component:` field of every `GeometryViolation` and drive the hint branches at geometry.rs:686 and :1591 — so a violation on a `qr_code` reports a type name that does not exist in the schema. Exhaustiveness protects against a *missing* arm but not against the two copies drifting on a rename, which is exactly how the labels got out of sync with serde in the first place.

Refs #220
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant