mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-06-10 02:09:49 +00:00
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:
parent
49d7f91ee5
commit
6fd87766c2
13
.github/workflows/ci.yml
vendored
13
.github/workflows/ci.yml
vendored
@ -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
|
||||
|
||||
@ -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**.
|
||||
|
||||
14
Cargo.toml
14
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.
|
||||
|
||||
17
Makefile
Normal file
17
Makefile
Normal 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
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user