Skip to content

chore(contracts): enforce fmt + clippy CI gate and clear all lint/format lapses - #113

Merged
EmeditWeb merged 1 commit into
mainfrom
chore/contracts-lint-fmt-ci-gate
Sep 18, 2026
Merged

EmeditWeb merged 1 commit into
mainfrom
chore/contracts-lint-fmt-ci-gate

Conversation

@EmeditWeb

Copy link
Copy Markdown
Member

Summary

Contracts CI ran only build + test — nothing guarded formatting or lints. Over time 91 rustfmt hunks and 27 clippy warnings accumulated across all six contracts. This PR adds the missing gates and clears the tree, so every future PR is held to the same bar.

What changed

CI gate (.github/workflows/contracts-ci.yml)

  • cargo fmt --all --check — fast fail, before any compile.
  • cargo clippy --workspace --all-targets -- -D warnings — placed after the dependency-WASM build so creditline's contractimport! clients resolve during the native clippy compile (otherwise E0599 on receive_guarantee).
  • Install rustfmt + clippy toolchain components.

Formatting

  • rustfmt applied across all six contracts.

Lint fixes (27 → 0)

  • assert_eq!(x, <bool>) → assert! in liquidity-pool + creditline tests (10).
  • checked_add(..).unwrap_or(u64::MAX) → saturating_add in vouching TTL math — behaviour-identical (2).
  • match-to-bool → matches! in creditline reputation-call handling (2).
  • Removed unused imports / mut / binding, added an elided lifetime, fixed a rustdoc list indentation.
  • Removed the dead safe_math modules from parameters and vendor-registry — both already perform overflow-checked arithmetic inline, so no safety is lost. creditline, liquidity-pool and reputation keep their used copies.
  • Removed an unused assert_event test helper.

Test quality

  • Added the missing share_price_before == 10_000 baseline assertion in the creditline default-loss test (the value was captured but never asserted — the share_price_after == 9_454 check had no documented starting point).

Verification

Gate Result
cargo fmt --all --check clean
cargo clippy --workspace --all-targets -- -D warnings clean
cargo build --locked --target wasm32-unknown-unknown --release all six contracts
cargo test --locked 420 passed, 0 failed

Notes

  • No behaviour changes to on-chain logic — changes are lint/format/test-only plus the CI gate. The saturating_add and matches! rewrites are exact-equivalent transformations.

…mat lapses

Contracts CI previously ran only build + test — nothing guarded formatting or
lints, so 91 rustfmt hunks and 27 clippy warnings had accumulated across all
six contracts. This adds the missing gates and brings the tree clean so every
future PR is held to the same bar.

CI (.github/workflows/contracts-ci.yml):
- Add `cargo fmt --all --check` (fast fail, before any compile).
- Add `cargo clippy --workspace --all-targets -- -D warnings`, placed after the
  dependency-WASM build so creditline's contractimport! clients resolve during
  the native clippy compile (otherwise E0599 on receive_guarantee).
- Install rustfmt + clippy toolchain components.

Formatting:
- Apply rustfmt across all six contracts.

Lint fixes (clippy -D warnings now clean):
- Replace `assert_eq!(x, <bool>)` with `assert!` in liquidity-pool and
  creditline tests (10).
- Use `saturating_add` in place of `checked_add(..).unwrap_or(u64::MAX)` in
  vouching TTL math — behaviour-identical (2).
- Use `matches!` in place of match-to-bool in creditline reputation-call
  handling (2).
- Remove unused `Val`/`Vec` imports, an unused `mut`, an unused `registry`
  binding; add an elided lifetime; fix a rustdoc list-item indentation.
- Remove the dead `safe_math` modules from parameters and vendor-registry: both
  already perform overflow-checked arithmetic inline, so no safety is lost.
  creditline, liquidity-pool and reputation keep their used copies.
- Remove an unused `assert_event` test helper.

Test quality:
- Add the missing `share_price_before == 10_000` baseline assertion in the
  creditline default-loss test (the value was captured but never checked).

Verified: fmt clean, clippy -D warnings clean, all contracts build for
wasm32-unknown-unknown (release), 420 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@EmeditWeb
EmeditWeb merged commit 2b11884 into main Sep 18, 2026
2 checks passed
@EmeditWeb
EmeditWeb deleted the chore/contracts-lint-fmt-ci-gate branch September 29, 2026 10:49
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.

1 participant