Repository navigation
chore: enforce clippy and rustfmt in CI - #66
Merged
codemagician1949 merged 1 commit intoAug 25, 2026
Merged
Conversation
CI checked, tested, size-capped and audited the workspace but never looked at
formatting or lints, so both had drifted: 34 rustfmt deviations across five
files and three Clippy warnings that had been accumulating unnoticed.
Adds a `lint` job running:
cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings
It is a separate job from `contracts` rather than two more steps on it. A
formatting deviation and a failing test are different kinds of problem, and
folding them together means whichever runs first hides the other in the checks
list — with `-D warnings` in particular, a lint failure would mask the test
results entirely.
`--all-targets` matters here rather than being boilerplate: of the three
existing warnings, one was in a `#[cfg(test)]` helper that a bare `cargo
clippy` never compiles, so the narrower invocation would have shipped a green
job over a warning that still fails locally for anyone running the full
command.
Warnings resolved:
- invoice-registry/src/multisig.rs — `unnecessary_cast`: `required` is already
`u32`, so `required as u32` was a no-op
- invoice-registry/src/pedersen.rs — `manual_range_contains`: `c >= 0 && c < P`
becomes `(0..P).contains(&c)`
- pool-manager/src/lib.rs — `manual_range_contains`: the reserve-ratio bounds
check becomes `!(0..=BPS_SCALE).contains(&reserve_ratio_bps)`
All three are behaviour-preserving. The pool-manager one also happens to save
22 bytes of Wasm, which is worth having in a contract sitting at 98% of the
64KB CI limit.
The rustfmt pass is mechanical — line wrapping and import layout only, no
logic touched — across invoice-registry (lib, multisig, nft), pool-manager and
repayment-waterfall.
Verified: fmt clean, clippy clean under `-D warnings`, `cargo test --workspace`
passing (139 tests), release Wasm build under the per-contract size limit.
3 tasks done
Contributor
|
Nice job @Alheriii |
3 tasks
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.
Closes #2
Summary
CI checked, tested, size-capped and audited the workspace but never looked at formatting or lints — so both had drifted: 34 rustfmt deviations across five files and three Clippy warnings accumulating unnoticed.
Adds a
lintjob:Two decisions worth calling out
A separate job, not two more steps on
contracts. A formatting deviation and a failing test are different kinds of problem, and folding them together means whichever runs first hides the other in the checks list. With-D warningsspecifically, a lint failure would mask the test results entirely — you'd fix the lint, push, and only then find out what the tests thought.--all-targetsis load-bearing, not boilerplate. One of the three existing warnings lives in a#[cfg(test)]helper, which a barecargo clippynever compiles. Without the flag this job would have gone green over a warning that still fails for anyone running the full command locally — the exact failure mode the issue is trying to close.Warnings resolved
invoice-registry/src/multisig.rsunnecessary_castrequiredis alreadyu32, sorequired as u32was a no-opinvoice-registry/src/pedersen.rsmanual_range_containsc >= 0 && c < P→(0..P).contains(&c)pool-manager/src/lib.rsmanual_range_contains!(0..=BPS_SCALE).contains(&reserve_ratio_bps)All three are behaviour-preserving. The pool-manager one also saves 22 bytes of Wasm, which is worth having in a contract sitting at 98% of the 64KB CI limit (
pool_manager.wasmis 64,262 bytes onmain— that's 1,274 bytes of headroom, and worth knowing before anyone adds to that crate).The rustfmt pass is mechanical — line wrapping and import layout, no logic touched — across
invoice-registry(lib, multisig, nft),pool-managerandrepayment-waterfall.Acceptance criteria
cargo clippy -- -D warningsin CIcargo fmt --checkin CIVerification
fmt clean, clippy clean under
-D warnings,cargo test --workspacepassing (139 tests), release Wasm build under the per-contract size limit.Conflicts
This and the PR for #1 both touch
pool-manager/src/lib.rs,repayment-waterfall/src/lib.rsandinvoice-registry/src/lib.rs— unavoidable, since reformatting touches the same files that gain aversion()change.They were written to not collide: every hunk in this PR is at least 22 lines away from every hunk in the other, and #1's
version()bodies and new tests were deliberately placed in the gaps between this PR's reformatting hunks rather than at the ends of files (where the nearest hunk would have been ~5 lines away).Both merge orders were tested locally against
main. Clean either way, and on the combined result the gates this PR introduces pass against the other PR's code: fmt clean, clippy clean, 141 tests passing, Wasm within limits. Merging one will not conflict or red-CI the other.