ci: make clippy a hard gate
The advisory step existed because the tree carried a warning backlog. Measured on 1.97.1 — the pinned toolchain CI actually uses — that backlog is three warnings, not the ~51 the comment claimed: two unnecessary_sort_by in smart_cache and one redundant into_iter in offline. Fixed, so clippy now runs with -D warnings and a warning means new breakage. Worth recording why this took a toolchain pin to do safely: the same tree measured 0 warnings on 1.92.0 and 3 on 1.97.1. Flipping the flag on a local measurement, without the pin, would have reddened CI on the next push. TRACES: | DR-206
This commit is contained in:
@@ -84,21 +84,18 @@ jobs:
|
|||||||
cd src-tauri
|
cd src-tauri
|
||||||
cargo fmt --all -- --check
|
cargo fmt --all -- --check
|
||||||
|
|
||||||
# ⚠️ Advisory for now — clippy warnings do NOT fail this job yet.
|
# Clippy is a hard gate. It was advisory while the tree carried a warning
|
||||||
|
# backlog; that backlog is gone (0 warnings on 1.97.1, the pinned
|
||||||
|
# toolchain), so a warning here is now new breakage rather than old noise.
|
||||||
#
|
#
|
||||||
# The tree carries ~51 pre-existing warnings; adding `-D warnings` today
|
# This only means anything because src-tauri/rust-toolchain.toml pins the
|
||||||
# would paint CI red on unrelated work. A compile *error* still fails the
|
# compiler: clippy's lint set moves between releases, so an unpinned gate
|
||||||
# step, so this is not a no-op: it stops new breakage and surfaces the
|
# would fail on whatever the runner happened to install. The pin and this
|
||||||
# backlog in every run.
|
# flag stand or fall together — if you unpin, drop this back to advisory.
|
||||||
#
|
- name: Run clippy
|
||||||
# TODO: once the existing warnings are cleared, tighten this to
|
|
||||||
# cargo clippy --all-targets -- -D warnings
|
|
||||||
# Flip that flag — do not delete the step. Track progress with
|
|
||||||
# `cd src-tauri && cargo clippy --all-targets 2>&1 | grep -c '^warning'`.
|
|
||||||
- name: Run clippy (advisory)
|
|
||||||
run: |
|
run: |
|
||||||
cd src-tauri
|
cd src-tauri
|
||||||
cargo clippy --all-targets
|
cargo clippy --all-targets -- -D warnings
|
||||||
|
|
||||||
- name: Run Rust tests
|
- name: Run Rust tests
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ pub async fn get_album_recommendations(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sort by tracks played (descending)
|
// Sort by tracks played (descending)
|
||||||
recommendations.sort_by(|a, b| b.tracks_played.cmp(&a.tracks_played));
|
recommendations.sort_by_key(|r| std::cmp::Reverse(r.tracks_played));
|
||||||
|
|
||||||
Ok(recommendations)
|
Ok(recommendations)
|
||||||
}
|
}
|
||||||
@@ -224,7 +224,7 @@ pub fn get_album_affinity_status(
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// Sort by play count (descending)
|
// Sort by play count (descending)
|
||||||
statuses.sort_by(|a, b| b.unique_tracks_played.cmp(&a.unique_tracks_played));
|
statuses.sort_by_key(|s| std::cmp::Reverse(s.unique_tracks_played));
|
||||||
|
|
||||||
Ok(statuses)
|
Ok(statuses)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1128,7 +1128,7 @@ impl OfflineRepository {
|
|||||||
let device_total_bytes: i64 = leaves.iter().map(|(_, b)| *b).sum();
|
let device_total_bytes: i64 = leaves.iter().map(|(_, b)| *b).sum();
|
||||||
|
|
||||||
let mut sizes = std::collections::HashMap::new();
|
let mut sizes = std::collections::HashMap::new();
|
||||||
for (id, bytes) in leaves.into_iter().chain(containers.into_iter()) {
|
for (id, bytes) in leaves.into_iter().chain(containers) {
|
||||||
// A container id can never collide with a leaf id, so a plain insert
|
// A container id can never collide with a leaf id, so a plain insert
|
||||||
// is fine; use entry to be defensive against duplicate rows.
|
// is fine; use entry to be defensive against duplicate rows.
|
||||||
*sizes.entry(id).or_insert(0) += bytes;
|
*sizes.entry(id).or_insert(0) += bytes;
|
||||||
|
|||||||
Reference in New Issue
Block a user