Fix clippy warnings and a stale test assertion surfaced by check.yml
All checks were successful
check / check (push) Successful in 1m17s

check.yml runs clippy -D warnings and cargo test for the first time in
this repo's history, surfacing pre-existing lint debt across all four
workspace crates plus one stale test assertion (breadpad-shared's
Palette default-background test still expected bread-theme's old
#1e1e2e; the upstream design system moved to #0c0c0c a while back and
nothing caught the drift since tests never ran in CI).

All fixes are mechanical: needless returns/closures/borrows, manual
Default impls replaceable by #[derive], map_or -> is_some_and, manual
range checks -> RangeInclusive::contains, a non-idiomatic sort_by ->
sort_by_key, an overly complex inline type given an alias, and moving
a function that ended up defined after its own test module. The one
exception is NoteType::from_str, which clippy flags for shadowing
std::str::FromStr's name — left as `#[allow(...)]` with a comment
rather than renamed, since it has 30+ call sites across every crate
in the workspace and returns Self directly rather than Result.
This commit is contained in:
Breadway 2026-08-04 17:52:45 +08:00
parent 3225f49a93
commit fe2724220a
12 changed files with 99 additions and 99 deletions

View file

@ -108,13 +108,15 @@ mod args {
// ── AppState ──────────────────────────────────────────────────────────────────
type ErrorLog = Rc<RefCell<Vec<(chrono::DateTime<Local>, String)>>>;
/// Shared UI state, cheap to clone (all fields are Rc/Arc).
#[derive(Clone)]
struct AppState {
store: Arc<Store>,
notes: Rc<RefCell<Vec<Note>>>,
cfg: Rc<RefCell<Config>>,
errors: Rc<RefCell<Vec<(chrono::DateTime<Local>, String)>>>,
errors: ErrorLog,
active_view: Rc<RefCell<String>>,
stack: gtk4::Stack,
window: gtk4::ApplicationWindow,
@ -579,7 +581,7 @@ fn build_note_list(
.build();
let mut sorted: Vec<Note> = notes.iter().filter(|n| !n.done).cloned().collect();
sorted.sort_by(|a, b| b.created.cmp(&a.created));
sorted.sort_by_key(|n| std::cmp::Reverse(n.created));
if sorted.is_empty() {
let action = empty_new_type.map(|nt| views::row::new_note_action(nt, state.window.clone(), state.clone()));

View file

@ -35,7 +35,7 @@ pub fn build(entries: &[(DateTime<chrono::Local>, String)]) -> gtk4::ScrolledWin
.build();
let time_label = gtk4::Label::builder()
.label(&ts.format("%H:%M:%S").to_string())
.label(ts.format("%H:%M:%S").to_string())
.width_chars(10)
.xalign(0.0)
.css_classes(["dim-label"])