refactor(hm-plugin-cloud): render_prefs returns a (bool, bool) tuple whose two fields are trivially swappable#118
Merged
markovejnovic merged 3 commits intoJun 10, 2026
Conversation
…whose two fields are trivially swappable
Replace the free render_prefs() function with impl Default for RenderPrefs; call sites use RenderPrefs::default().
Default::default() implies a pure/constant value, but this probes NO_COLOR and TTY state at call time. A named constructor signals the env observation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The smell
render_prefs()returned(bool, bool)— two values of the same primitive type with no type-level distinction. Call sites destructured positionally:crates/hm-plugin-cloud/src/verbs/build.rs:59—let (color, logs) = …crates/hm-plugin-cloud/src/verbs/job.rs:72—let (color, _logs) = …Swapping the two values in the function body, or a future call site binding them in the wrong order, compiles silently and inverts color/log behavior.
The change
render_prefs()now returns a named struct so each field is named at construction and at every call site:Call sites bind
prefsand readprefs.color/prefs.logsinstead of relying on tuple position. Behavior is unchanged — the same two values flow tohm_render::renderer_forin the same order.(
#[derive(Debug, ...)]is required because the crate deniesmissing-debug-implementations.)Type-safety pattern
This applies the ripgrep/fd "replace bool/bool pairs with named fields or enums" guidance: same-typed positional booleans are a classic source of silent swap bugs. A named struct names each flag at construction and at every use site, so a wrong-order binding no longer type-checks into an inverted-behavior bug. This is a focused, behavior-preserving change touching only this function and its two callers.
Validation
Only
cargo check -p hm-plugin-cloudwas run locally (passes). Full CI runs on this PR.