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
This commit is contained in:
r4bbit 2026-05-21 10:23:59 +02:00
parent a3163dbe58
commit 33e233dee5
No known key found for this signature in database
GPG Key ID: E95F1E9447DC91A9
7 changed files with 126 additions and 64 deletions

View File

@ -60,21 +60,14 @@ jobs:
- name: Clippy - name: Clippy
run: | 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" echo "Found non-actionable lint suppression reason"
exit 1 exit 1
fi fi
RISC0_SKIP_BUILD=1 cargo clippy --workspace --all-targets -- -D warnings make clippy
- name: Guest Clippy - name: Guest Clippy
run: | run: make 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
done
unit-tests: unit-tests:
name: Unit Tests name: Unit Tests

View File

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

View File

@ -42,10 +42,17 @@ tokio = { version = "1.28.2", features = ["net", "rt-multi-thread", "sync", "mac
[workspace.lints.rust] [workspace.lints.rust]
rust_2018_idioms = { level = "deny", priority = -1 } 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] [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. # Generated-code / placeholder blockers.
dbg_macro = "deny" dbg_macro = "deny"
@ -60,18 +67,15 @@ allow_attributes_without_reason = "deny"
# Determinism, panic-safety, and arithmetic correctness. # Determinism, panic-safety, and arithmetic correctness.
arithmetic_side_effects = "deny" arithmetic_side_effects = "deny"
indexing_slicing = "deny" indexing_slicing = "deny"
integer_division = "warn"
# Cast discipline. # Cast discipline.
as_conversions = "deny" as_conversions = "deny"
cast_possible_truncation = "deny" cast_possible_truncation = "deny"
cast_possible_wrap = "deny" cast_possible_wrap = "deny"
cast_precision_loss = "warn"
cast_sign_loss = "deny" cast_sign_loss = "deny"
# API and enum evolution. # API and enum evolution.
large_enum_variant = "deny" large_enum_variant = "deny"
match_wildcard_for_single_variants = "warn"
wildcard_enum_match_arm = "deny" wildcard_enum_match_arm = "deny"
# Too noisy for this codebase unless enforced selectively. # Too noisy for this codebase unless enforced selectively.

17
Makefile Normal file
View File

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

View File

@ -7,30 +7,46 @@ edition = "2021"
[lints.rust] [lints.rust]
rust_2018_idioms = { level = "deny", priority = -1 } 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] [lints.clippy]
all = { level = "deny", priority = -1 } # Deny only the groups where a new lint should always be a hard error.
allow_attributes = "warn" # style/pedantic lints default to warn so toolchain upgrades don't break the
allow_attributes_without_reason = "deny" # build unexpectedly — they can be evaluated and addressed at our own pace.
arithmetic_side_effects = "deny" correctness = { level = "deny", priority = -1 }
as_conversions = "deny" suspicious = { level = "deny", priority = -1 }
cast_possible_truncation = "deny" perf = { level = "deny", priority = -1 }
cast_possible_wrap = "deny" style = { level = "warn", priority = -1 }
cast_precision_loss = "warn"
cast_sign_loss = "deny" # Generated-code / placeholder blockers.
dbg_macro = "deny" 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" todo = "deny"
unimplemented = "deny" unimplemented = "deny"
unwrap_used = "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" wildcard_enum_match_arm = "deny"
# Too noisy for this codebase unless enforced selectively.
module_name_repetitions = "allow"
similar_names = "allow"
[[bin]] [[bin]]
name = "amm" name = "amm"
path = "src/bin/amm.rs" path = "src/bin/amm.rs"

View File

@ -7,30 +7,46 @@ edition = "2021"
[lints.rust] [lints.rust]
rust_2018_idioms = { level = "deny", priority = -1 } 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] [lints.clippy]
all = { level = "deny", priority = -1 } # Deny only the groups where a new lint should always be a hard error.
allow_attributes = "warn" # style/pedantic lints default to warn so toolchain upgrades don't break the
allow_attributes_without_reason = "deny" # build unexpectedly — they can be evaluated and addressed at our own pace.
arithmetic_side_effects = "deny" correctness = { level = "deny", priority = -1 }
as_conversions = "deny" suspicious = { level = "deny", priority = -1 }
cast_possible_truncation = "deny" perf = { level = "deny", priority = -1 }
cast_possible_wrap = "deny" style = { level = "warn", priority = -1 }
cast_precision_loss = "warn"
cast_sign_loss = "deny" # Generated-code / placeholder blockers.
dbg_macro = "deny" 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" todo = "deny"
unimplemented = "deny" unimplemented = "deny"
unwrap_used = "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" wildcard_enum_match_arm = "deny"
# Too noisy for this codebase unless enforced selectively.
module_name_repetitions = "allow"
similar_names = "allow"
[[bin]] [[bin]]
name = "ata" name = "ata"
path = "src/bin/ata.rs" path = "src/bin/ata.rs"

View File

@ -7,30 +7,46 @@ edition = "2021"
[lints.rust] [lints.rust]
rust_2018_idioms = { level = "deny", priority = -1 } 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] [lints.clippy]
all = { level = "deny", priority = -1 } # Deny only the groups where a new lint should always be a hard error.
allow_attributes = "warn" # style/pedantic lints default to warn so toolchain upgrades don't break the
allow_attributes_without_reason = "deny" # build unexpectedly — they can be evaluated and addressed at our own pace.
arithmetic_side_effects = "deny" correctness = { level = "deny", priority = -1 }
as_conversions = "deny" suspicious = { level = "deny", priority = -1 }
cast_possible_truncation = "deny" perf = { level = "deny", priority = -1 }
cast_possible_wrap = "deny" style = { level = "warn", priority = -1 }
cast_precision_loss = "warn"
cast_sign_loss = "deny" # Generated-code / placeholder blockers.
dbg_macro = "deny" 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" todo = "deny"
unimplemented = "deny" unimplemented = "deny"
unwrap_used = "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" wildcard_enum_match_arm = "deny"
# Too noisy for this codebase unless enforced selectively.
module_name_repetitions = "allow"
similar_names = "allow"
[[bin]] [[bin]]
name = "token" name = "token"
path = "src/bin/token.rs" path = "src/bin/token.rs"