Skip to content

chore: enforce clippy and rustfmt in CI - #66

Merged
codemagician1949 merged 1 commit into
IntensifierLab:mainfrom
Alheriii:chore/ci-clippy-rustfmt-2
Aug 25, 2026
Merged

codemagician1949 merged 1 commit into
IntensifierLab:mainfrom
Alheriii:chore/ci-clippy-rustfmt-2

Conversation

@Alheriii

Copy link
Copy Markdown

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 lint job:

- name: Check formatting
  run: cargo fmt --all -- --check
- name: Clippy
  run: cargo clippy --workspace --all-targets -- -D warnings

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 warnings specifically, 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-targets is load-bearing, not boilerplate. One of the three existing warnings lives in a #[cfg(test)] helper, which a bare cargo clippy never 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

File Lint Change
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 → (0..P).contains(&c)
pool-manager/src/lib.rs manual_range_contains reserve-ratio bounds → !(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.wasm is 64,262 bytes on main — 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-manager and repayment-waterfall.

Acceptance criteria

  • cargo clippy -- -D warnings in CI
  • cargo fmt --check in CI
  • All existing warnings resolved

Verification

fmt clean, clippy clean under -D warnings, cargo test --workspace passing (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.rs and invoice-registry/src/lib.rs — unavoidable, since reformatting touches the same files that gain a version() 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.

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.
@codemagician1949

Copy link
Copy Markdown
Contributor

Nice job @Alheriii

@codemagician1949
codemagician1949 merged commit ecea215 into IntensifierLab:main Aug 25, 2026
4 checks passed
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.

chore: add clippy and rustfmt CI enforcement

2 participants