fix(clippy): use sort_by_key with Reverse for descending sorts - #23
Merged
Merged
Conversation
Rust 1.95.0 added the unnecessary_sort_by lint, which fires on `sort_by(|a, b| b.cmp(&a))` patterns since they are equivalent to `sort_by_key(|x| std::cmp::Reverse(x))`. This was caught when meta's CI re-ran for the first time in two weeks (clippy is run with -D warnings against the cloned meta_cli main). No functional change — sort order is preserved.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThree sorting implementations across distinct modules were refactored from Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
mateodelnorte
added a commit
to gitkb/meta_git_lib
that referenced
this pull request
Apr 26, 2026
Caught by Rust 1.95.0's unnecessary_sort_by lint. Same pattern as gitkb/meta_cli#23 — `sort_by(|a, b| b.cmp(&a))` is equivalent to `sort_by_key(|x| std::cmp::Reverse(x))`. DateTime<Utc> is Copy, so no allocation/clone concerns. Unblocks gitkb/meta#78.
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.
Summary
Rust 1.95.0 added the
unnecessary_sort_bylint, which fires onsort_by(|a, b| b.cmp(&a))patterns since they're equivalent tosort_by_key(|x| std::cmp::Reverse(x)). Three call sites were caught when meta's CI re-ran for the first time in two weeks against this repo's cloned main.Changes (mechanical, matches clippy's suggested fix exactly):
src/agent_guard.rs:275— pattern compile-time sort by prioritysrc/agent_score.rs:119— session list sort by mtimesrc/dependency_graph.rs:410— dependent count sortNo functional change — sort order is preserved.
Why this matters now
gitkb/meta#78 (adding Discord release notification) is blocked on clippy. Meta's CI clones this repo's
mainfresh, so this needs to land first to unblock the meta PR.Test plan
Summary by CodeRabbit