Priority: Medium · Area: CI / code quality · Est. effort: 6–9 h
📌 Problem
.github/workflows/ci.yml runs cargo fmt --all -- --check, cargo build and cargo test. grep -c clippy .github/workflows/ci.yml returns 0.
Formatting is enforced; correctness lints are not. On a Soroban contract the lints that matter are not stylistic — clippy flags arithmetic that can wrap, lossy numeric casts, comparison chains that admit an off-by-one at a threshold, and needless clones and allocations that cost real wasm bytes. This contract handles anchors, liquidity and settlements, so threshold and arithmetic errors are correctness bugs with value attached.
The wasm size is currently unmeasured (tracked separately), which makes allocation-related lints doubly worth having.
🎯 Design decision required
State and defend:
- Scope of this PR. Run it first and report the count by category. Clear everything, or enable a defined subset now and file the rest? Either is fine; picking silently is not. If you scope down, list precisely what was deferred.
- Allow policy. Where you keep an
#[allow], is it justified by Soroban's constraints (no-std, determinism, size) or by convenience? Say which per site. A crate-level blanket #![allow] to make the job pass will be rejected.
- Test targets.
--all-targets lints the 305 tests in src/test.rs too, which will likely dominate the count. Decide whether test targets are in scope now and argue it.
🧩 Requirements and context
- Clippy must run with
-D warnings so the job fails. A step that only prints is not worth adding.
- No behavioural changes. If a lint fix would change behaviour, stop and note it in the PR instead.
- Report the wasm byte delta for anything affecting generated code.
rust-toolchain.toml pins the toolchain — lint against it, and note that findings differ across clippy versions.
- The
Makefile has fmt/fmt-check targets; consider adding a clippy target so local and CI invocations cannot diverge.
🛠️ Suggested execution
- Run
cargo clippy --all-targets -- -D warnings; paste the count grouped by category before fixing anything.
- Fix by category, one commit each.
- Add the CI step (and a Makefile target if you argued for it).
- Show it green and prove it fails on a deliberate violation.
- Report the wasm byte delta.
✅ Acceptance criteria
🚫 Out of scope
- Behavioural changes.
- The wasm build and size guard — separate issue.
- Splitting
test.rs — separate issue.
🧪 Verification
cargo clippy --all-targets -- -D warnings
cargo test
cargo fmt --all -- --check
cargo build --target wasm32-unknown-unknown --release
📤 What your PR must include
- The pre-fix lint inventory by category.
- Your scope and test-target decisions.
- Justification per surviving
#[allow].
- Link to a failing run, plus the wasm delta.
Closes #<n>.
🔒 Security notes
Several default clippy lints map directly onto contract-safety concerns: wrapping arithmetic, lossy casts, and boundary comparisons that admit an off-by-one. On liquidity and settlement paths that arithmetic decides how much value moves, and nothing currently flags it.
📋 Guidelines
- Minimum 95% test coverage on changed lines
- Clear documentation
- Timeframe: 96 hours from assignment
- One logical change per commit; no merge commits
💬 Join our community
Working on this, or want to sanity-check your approach before you start? Come and ask — the maintainers are there and happy to help.
Telegram: https://t.me/Grainlify
Priority: Medium · Area: CI / code quality · Est. effort: 6–9 h
📌 Problem
.github/workflows/ci.ymlrunscargo fmt --all -- --check,cargo buildandcargo test.grep -c clippy .github/workflows/ci.ymlreturns 0.Formatting is enforced; correctness lints are not. On a Soroban contract the lints that matter are not stylistic — clippy flags arithmetic that can wrap, lossy numeric casts, comparison chains that admit an off-by-one at a threshold, and needless clones and allocations that cost real wasm bytes. This contract handles anchors, liquidity and settlements, so threshold and arithmetic errors are correctness bugs with value attached.
The wasm size is currently unmeasured (tracked separately), which makes allocation-related lints doubly worth having.
🎯 Design decision required
State and defend:
#[allow], is it justified by Soroban's constraints (no-std, determinism, size) or by convenience? Say which per site. A crate-level blanket#![allow]to make the job pass will be rejected.--all-targetslints the 305 tests insrc/test.rstoo, which will likely dominate the count. Decide whether test targets are in scope now and argue it.🧩 Requirements and context
-D warningsso the job fails. A step that only prints is not worth adding.rust-toolchain.tomlpins the toolchain — lint against it, and note that findings differ across clippy versions.Makefilehasfmt/fmt-checktargets; consider adding aclippytarget so local and CI invocations cannot diverge.🛠️ Suggested execution
cargo clippy --all-targets -- -D warnings; paste the count grouped by category before fixing anything.✅ Acceptance criteria
cargo clippy -- -D warningsexits 0 for your stated scope.#[allow]is narrowly scoped with a justification comment.#![allow]was added.cargo teststill passes (305 tests).🚫 Out of scope
test.rs— separate issue.🧪 Verification
cargo clippy --all-targets -- -D warnings cargo test cargo fmt --all -- --check cargo build --target wasm32-unknown-unknown --release📤 What your PR must include
#[allow].Closes #<n>.🔒 Security notes
Several default clippy lints map directly onto contract-safety concerns: wrapping arithmetic, lossy casts, and boundary comparisons that admit an off-by-one. On liquidity and settlement paths that arithmetic decides how much value moves, and nothing currently flags it.
📋 Guidelines
💬 Join our community
Working on this, or want to sanity-check your approach before you start? Come and ask — the maintainers are there and happy to help.
Telegram: https://t.me/Grainlify