Skip to content

Clear the clippy warnings and gate on them in CI - #19

Open
bmesuere wants to merge 1 commit into
fix/translate-unknown-tablefrom
chore/clippy
Open

Clear the clippy warnings and gate on them in CI#19
bmesuere wants to merge 1 commit into
fix/translate-unknown-tablefrom
chore/clippy

Conversation

@bmesuere

Copy link
Copy Markdown
Member

Top of the stack: #14 -> #15 -> #16 -> #17 -> this.

99 warnings down to zero, and CI now runs cargo clippy --all-targets -- -D warnings — which #10 deliberately left out precisely because of these warnings.

The mechanical 98

Applied with cargo clippy --fix, then read through:

  • 63 useless use of vec! in test assertions
  • .get(0) -> .first()
  • io::Error::new(ErrorKind::Other, _) -> io::Error::other(_)
  • redundant .into(), now that Replace error-chain with thiserror #16 made the error types concrete
  • elidable lifetimes, &[b'\n'] -> b"\n", size_of::<usize>() * 8 -> usize::BITS

All semantically neutral. I checked the non-test diffs individually rather than trusting --fix, and confirmed filter, prot2tryp and uniq produce byte-identical output to a pre-clippy build.

The one that wasn't mechanical

Clippy wants Rank::partial_cmp to be Some(self.cmp(other)). Taking that suggestion would change results. The impl deliberately reports NoRank as incomparable, and that is load-bearing in two places:

  • score() is a chain of if self < &Rank::X. For NoRank every comparison is false, so it falls through to None. Canonical ordering would give it Some(12).
  • raise_to_rank climbs while ... target < r, and stops at NoRank for the same reason.

So it is #[allow]ed with a comment explaining why.

Worth a maintainer's eye, though: writing that comment turned up that PartialOrd and Ord on Rank contradict each other.

NoRank.partial_cmp(&Species) = None      // incomparable
NoRank.cmp(&Species)         = Less      // ordered
NoRank < Species             = false
min(NoRank, Species)         = NoRank

Ord is used via min() in agg/rank.rs:65; PartialOrd via < in agg/rank.rs:35 and score(). Both are relied on, so < and min() genuinely disagree about NoRank. That is a real latent bug rather than a lint, and fixing it means deciding what NoRank should mean — too big to do as a drive-by, so it is documented and left.

Verification

All four CI gates pass locally, including against the pinned 1.88 toolchain. 39 tests pass, and the full pipeline runs end to end through FragGeneScanRs to tryptic peptides.

99 warnings down to zero. Nearly all were mechanical and applied with
`cargo clippy --fix`: `vec!` in test assertions, `.get(0)` for `.first()`,
`io::Error::new(ErrorKind::Other, _)` for `io::Error::other(_)`, redundant
`.into()` now that the error types are concrete, elidable lifetimes, and
`size_of::<usize>() * 8` for `usize::BITS`.

The one that was not mechanical is Rank's PartialOrd. Clippy wants
`Some(self.cmp(other))`, but the impl deliberately reports NoRank as
incomparable, which is what makes `score()` fall through every branch for it
and what stops `raise_to_rank` from climbing past it. Taking the suggestion
would give NoRank a score of 12 and change aggregation, so it is allowed with
a comment instead.

While writing that comment: the PartialOrd and Ord impls contradict each
other. For NoRank against Species, partial_cmp says None while cmp says Less,
so `<` and `min()` disagree. Both behaviours are used, so this is left alone
and noted rather than changed as a drive-by.

CI now runs `cargo clippy --all-targets -- -D warnings`, which was left out
when CI was added precisely because of these warnings.

Verified the pipeline still produces identical output to a pre-clippy build.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 18, 2026 13:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@bmesuere bmesuere mentioned this pull request Aug 18, 2026
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.

2 participants