Skip to content

chore(clippy): clear all warnings and gate clippy in CI - #739

Merged
kirillDevPro merged 5 commits into
mainfrom
chore/clippy-zero
Sep 26, 2026
Merged

kirillDevPro merged 5 commits into
mainfrom
chore/clippy-zero

Conversation

@kirillDevPro

Copy link
Copy Markdown
Collaborator

What & why

CI never ran clippy, so warnings grew with every PR: cargo clippy --workspace --all-targets
reported 464 unique warnings (moon-ui-gpui 347, moon-core 105, moon-chart 12), and with
-D warnings it stopped at moon-core, so moon-ui-gpui was never checked at all.

This makes it zero and keeps it there:

  • [workspace.lints.clippy] allows too_many_arguments, type_complexity and
    neg_cmp_op_on_partial_ord. The !(a < b) forms are deliberate NaN handling and stay as they are.
  • cargo clippy --fix for everything machine-applicable, including collapsible_if rewritten as
    let-chains.
  • The rest is fixed by hand where the rewrite is local and behaviour-neutral. Otherwise it gets a
    targeted #[allow] with a reason: large_enum_variant on feed / command / match-heavy enums
    (boxing would allocate on hot paths), and result_large_err where boxing would change a public
    Result.
  • A blocking CI job runs cargo clippy --workspace --all-targets --locked -- -D warnings, and
    ci_gate_contract.rs pins it so the gate cannot be demoted silently. CONTRIBUTING lists the rule.

No behaviour change is intended: no dependency, lock, edition or public API change. The branch is
rebased on the tuner (#738), which added no new warnings.

Commits are split so each part reviews on its own: lint table, --fix output, hand fixes and
allows, CI gate, and a fix for two allow reasons.

How to verify

  • cargo clippy --workspace --all-targets --locked -- -D warnings exits 0
  • cargo test --workspace --locked and cargo test -p moon-ui-gpui --test theme_contract green
  • cargo fmt --all -- --check green
  • Checked on a debug build: the app starts, all cores connect, and the Report, Orders and trade
    window render normally, including wheel zoom.

Clippy is about to become a merge gate. too_many_arguments and
type_complexity describe API shape, not defects, and `!(a < b)` is
deliberate NaN handling that must not be rewritten to `>=`. Each
crate inherits the table with `[lints] workspace = true`.
cargo clippy --fix rewrote the suggestions it marks as safe:
needless borrows, unit lets, map_or forms, and nested ifs as
let chains. Comparisons and NaN handling are untouched. One
collapsible_match suggestion does not compile and stays for
a targeted allow.
The machine-applicable pass left local rewrites and a few
suggestions that would change a signature, drop a wire-format
comment, or collapse a match that does not compile. Those last
ones are allowed on the item, with the reason beside the attribute.
Pull requests were not linted, so warnings accumulated until
-D warnings failed on the first crate. The new Windows job runs
the same clippy command developers must pass, and the CI contract
test reddens if that command is weakened or the job is demoted.
CoreTrack::averaged checked the divisor by hand and claimed
checked_div would report zero. checked_div returns None for a
zero sample count, which is the unknown state, and the same
quotient otherwise. The hotkeys allow stays; its comment now
says the suggested collapse does not compile.
@kirillDevPro
kirillDevPro merged commit 30e09b1 into main Sep 26, 2026
9 checks passed
@kirillDevPro
kirillDevPro deleted the chore/clippy-zero branch September 26, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant