From 33e233dee5538a986dfc8ef7a4b8964cb931bb3d Mon Sep 17 00:00:00 2001 From: r4bbit <445106+0x-r4bbit@users.noreply.github.com> Date: Thu, 21 May 2026 10:23:59 +0200 Subject: [PATCH] chore: adjust linting rules and introduce Makefile This relaxes some of the rules introduced in the previous commit. To simplify testing, building and formatting locally and on CI, we also introduce a dedicated makefile --- .github/workflows/ci.yml | 13 +++------ CLAUDE.md | 2 +- Cargo.toml | 14 ++++++---- Makefile | 17 ++++++++++++ amm/methods/guest/Cargo.toml | 48 ++++++++++++++++++++++------------ ata/methods/guest/Cargo.toml | 48 ++++++++++++++++++++++------------ token/methods/guest/Cargo.toml | 48 ++++++++++++++++++++++------------ 7 files changed, 126 insertions(+), 64 deletions(-) create mode 100644 Makefile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 570ca37..6b6ff6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,21 +60,14 @@ jobs: - name: Clippy run: | - if rg -n -U --multiline '#\[(allow|expect)\([\s\S]*?reason\s*=\s*"(TODO|FIXME|fix later|later|temporary|hack)' token amm ata integration_tests tools -g '*.rs'; then + if rg -n -U --multiline '#\[(allow|expect)\([\s\S]*?reason\s*=\s*"(TODO|FIXME|fix later|temporary|hack)' . -g '*.rs' -g '!*/target/*'; then echo "Found non-actionable lint suppression reason" exit 1 fi - RISC0_SKIP_BUILD=1 cargo clippy --workspace --all-targets -- -D warnings + make clippy - name: Guest Clippy - run: | - for manifest in \ - token/methods/guest/Cargo.toml \ - amm/methods/guest/Cargo.toml \ - ata/methods/guest/Cargo.toml - do - cargo clippy --manifest-path "$manifest" --all-targets -- -D warnings - done + run: make clippy-guest unit-tests: name: Unit Tests diff --git a/CLAUDE.md b/CLAUDE.md index 992296f..3b7d7c6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -103,4 +103,4 @@ Each program follows a layered pattern: **Chained calls**: The AMM's swap and liquidity operations compose with the token program via `ChainedCall` — the AMM instructs the token program to execute transfers as part of the same atomic operation. -**Testing**: Tests call program functions directly (no zkVM overhead). Set `RISC0_DEV_MODE=1` to skip ZK proof generation when running integration tests that go through the zkVM. The Rust toolchain pinned version is **1.91.1**. +**Testing**: Tests call program functions directly (no zkVM overhead). Set `RISC0_DEV_MODE=1` to skip ZK proof generation when running integration tests that go through the zkVM. The Rust toolchain pinned version is **1.94.0**. diff --git a/Cargo.toml b/Cargo.toml index 3f8b654..f439e9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,10 +42,17 @@ tokio = { version = "1.28.2", features = ["net", "rt-multi-thread", "sync", "mac [workspace.lints.rust] rust_2018_idioms = { level = "deny", priority = -1 } -unsafe_code = "forbid" +# deny (not forbid) so a targeted per-item #[allow] remains possible if ever needed +unsafe_code = "deny" [workspace.lints.clippy] -all = { level = "deny", priority = -1 } +# Deny only the groups where a new lint should always be a hard error. +# style/pedantic lints default to warn so toolchain upgrades don't break the +# build unexpectedly — they can be evaluated and addressed at our own pace. +correctness = { level = "deny", priority = -1 } +suspicious = { level = "deny", priority = -1 } +perf = { level = "deny", priority = -1 } +style = { level = "warn", priority = -1 } # Generated-code / placeholder blockers. dbg_macro = "deny" @@ -60,18 +67,15 @@ allow_attributes_without_reason = "deny" # Determinism, panic-safety, and arithmetic correctness. arithmetic_side_effects = "deny" indexing_slicing = "deny" -integer_division = "warn" # Cast discipline. as_conversions = "deny" cast_possible_truncation = "deny" cast_possible_wrap = "deny" -cast_precision_loss = "warn" cast_sign_loss = "deny" # API and enum evolution. large_enum_variant = "deny" -match_wildcard_for_single_variants = "warn" wildcard_enum_match_arm = "deny" # Too noisy for this codebase unless enforced selectively. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5dbb110 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +.PHONY: clippy clippy-guest clippy-all test fmt + +clippy: + RISC0_SKIP_BUILD=1 cargo clippy --workspace --all-targets -- -D warnings + +clippy-guest: + for manifest in token/methods/guest/Cargo.toml amm/methods/guest/Cargo.toml ata/methods/guest/Cargo.toml; do \ + cargo clippy --manifest-path "$$manifest" --all-targets -- -D warnings || exit 1; \ + done + +clippy-all: clippy clippy-guest + +test: + RISC0_DEV_MODE=1 cargo test --workspace + +fmt: + cargo +nightly fmt --all diff --git a/amm/methods/guest/Cargo.toml b/amm/methods/guest/Cargo.toml index 7050286..a18d38e 100644 --- a/amm/methods/guest/Cargo.toml +++ b/amm/methods/guest/Cargo.toml @@ -7,30 +7,46 @@ edition = "2021" [lints.rust] rust_2018_idioms = { level = "deny", priority = -1 } -unsafe_code = "forbid" +# deny (not forbid) so a targeted per-item #[allow] remains possible if ever needed +unsafe_code = "deny" [lints.clippy] -all = { level = "deny", priority = -1 } -allow_attributes = "warn" -allow_attributes_without_reason = "deny" -arithmetic_side_effects = "deny" -as_conversions = "deny" -cast_possible_truncation = "deny" -cast_possible_wrap = "deny" -cast_precision_loss = "warn" -cast_sign_loss = "deny" +# Deny only the groups where a new lint should always be a hard error. +# style/pedantic lints default to warn so toolchain upgrades don't break the +# build unexpectedly — they can be evaluated and addressed at our own pace. +correctness = { level = "deny", priority = -1 } +suspicious = { level = "deny", priority = -1 } +perf = { level = "deny", priority = -1 } +style = { level = "warn", priority = -1 } + +# Generated-code / placeholder blockers. dbg_macro = "deny" -indexing_slicing = "deny" -integer_division = "warn" -large_enum_variant = "deny" -match_wildcard_for_single_variants = "warn" -module_name_repetitions = "allow" -similar_names = "allow" todo = "deny" unimplemented = "deny" unwrap_used = "deny" + +# Lint suppression hygiene. +allow_attributes = "warn" +allow_attributes_without_reason = "deny" + +# Determinism, panic-safety, and arithmetic correctness. +arithmetic_side_effects = "deny" +indexing_slicing = "deny" + +# Cast discipline. +as_conversions = "deny" +cast_possible_truncation = "deny" +cast_possible_wrap = "deny" +cast_sign_loss = "deny" + +# API and enum evolution. +large_enum_variant = "deny" wildcard_enum_match_arm = "deny" +# Too noisy for this codebase unless enforced selectively. +module_name_repetitions = "allow" +similar_names = "allow" + [[bin]] name = "amm" path = "src/bin/amm.rs" diff --git a/ata/methods/guest/Cargo.toml b/ata/methods/guest/Cargo.toml index 25a7c07..3ba0eb7 100644 --- a/ata/methods/guest/Cargo.toml +++ b/ata/methods/guest/Cargo.toml @@ -7,30 +7,46 @@ edition = "2021" [lints.rust] rust_2018_idioms = { level = "deny", priority = -1 } -unsafe_code = "forbid" +# deny (not forbid) so a targeted per-item #[allow] remains possible if ever needed +unsafe_code = "deny" [lints.clippy] -all = { level = "deny", priority = -1 } -allow_attributes = "warn" -allow_attributes_without_reason = "deny" -arithmetic_side_effects = "deny" -as_conversions = "deny" -cast_possible_truncation = "deny" -cast_possible_wrap = "deny" -cast_precision_loss = "warn" -cast_sign_loss = "deny" +# Deny only the groups where a new lint should always be a hard error. +# style/pedantic lints default to warn so toolchain upgrades don't break the +# build unexpectedly — they can be evaluated and addressed at our own pace. +correctness = { level = "deny", priority = -1 } +suspicious = { level = "deny", priority = -1 } +perf = { level = "deny", priority = -1 } +style = { level = "warn", priority = -1 } + +# Generated-code / placeholder blockers. dbg_macro = "deny" -indexing_slicing = "deny" -integer_division = "warn" -large_enum_variant = "deny" -match_wildcard_for_single_variants = "warn" -module_name_repetitions = "allow" -similar_names = "allow" todo = "deny" unimplemented = "deny" unwrap_used = "deny" + +# Lint suppression hygiene. +allow_attributes = "warn" +allow_attributes_without_reason = "deny" + +# Determinism, panic-safety, and arithmetic correctness. +arithmetic_side_effects = "deny" +indexing_slicing = "deny" + +# Cast discipline. +as_conversions = "deny" +cast_possible_truncation = "deny" +cast_possible_wrap = "deny" +cast_sign_loss = "deny" + +# API and enum evolution. +large_enum_variant = "deny" wildcard_enum_match_arm = "deny" +# Too noisy for this codebase unless enforced selectively. +module_name_repetitions = "allow" +similar_names = "allow" + [[bin]] name = "ata" path = "src/bin/ata.rs" diff --git a/token/methods/guest/Cargo.toml b/token/methods/guest/Cargo.toml index 6187f2a..7cd8567 100644 --- a/token/methods/guest/Cargo.toml +++ b/token/methods/guest/Cargo.toml @@ -7,30 +7,46 @@ edition = "2021" [lints.rust] rust_2018_idioms = { level = "deny", priority = -1 } -unsafe_code = "forbid" +# deny (not forbid) so a targeted per-item #[allow] remains possible if ever needed +unsafe_code = "deny" [lints.clippy] -all = { level = "deny", priority = -1 } -allow_attributes = "warn" -allow_attributes_without_reason = "deny" -arithmetic_side_effects = "deny" -as_conversions = "deny" -cast_possible_truncation = "deny" -cast_possible_wrap = "deny" -cast_precision_loss = "warn" -cast_sign_loss = "deny" +# Deny only the groups where a new lint should always be a hard error. +# style/pedantic lints default to warn so toolchain upgrades don't break the +# build unexpectedly — they can be evaluated and addressed at our own pace. +correctness = { level = "deny", priority = -1 } +suspicious = { level = "deny", priority = -1 } +perf = { level = "deny", priority = -1 } +style = { level = "warn", priority = -1 } + +# Generated-code / placeholder blockers. dbg_macro = "deny" -indexing_slicing = "deny" -integer_division = "warn" -large_enum_variant = "deny" -match_wildcard_for_single_variants = "warn" -module_name_repetitions = "allow" -similar_names = "allow" todo = "deny" unimplemented = "deny" unwrap_used = "deny" + +# Lint suppression hygiene. +allow_attributes = "warn" +allow_attributes_without_reason = "deny" + +# Determinism, panic-safety, and arithmetic correctness. +arithmetic_side_effects = "deny" +indexing_slicing = "deny" + +# Cast discipline. +as_conversions = "deny" +cast_possible_truncation = "deny" +cast_possible_wrap = "deny" +cast_sign_loss = "deny" + +# API and enum evolution. +large_enum_variant = "deny" wildcard_enum_match_arm = "deny" +# Too noisy for this codebase unless enforced selectively. +module_name_repetitions = "allow" +similar_names = "allow" + [[bin]] name = "token" path = "src/bin/token.rs"