chore: fix clippy warnings across workspace#748
Conversation
Resolves all clippy warnings under `cargo clippy --all-targets --all-features` (modulo an external `chumsky` future-incompat note), covering the lib invocation CI runs (`cargo clippy -- -D warnings`) and test targets. Notable changes: - alonzo phase1 collateral check refactored to share the lovelace comparison across `Coin` and `Multiasset` - script_data tests: `const LazyLock` → `static LazyLock` to satisfy the interior-mutability lint - exposed existing tuple type aliases in tests/common.rs as `pub` and used them in babbage.rs / conway.rs in place of inline tuples - replaced `assert!(false, msg)` with `panic!(msg)` in validate tests and pallas-math Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR applies targeted refactoring and cleanup across multiple crates: core validation logic is simplified via pattern-matching consolidation and ChangesCore Validation Logic Refactoring
Test Infrastructure, Type Exports & Test Migrations
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pallas-validate/tests/conway.rs (1)
879-890:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winWire the mutated collateral params into
env.
conway_prot_paramsis updated here, butenv.prot_paramsstill comes from a freshmk_mainnet_params_epoch_380()value. As written, this test never exercises the reduced-collateral scenario it describes.Suggested fix
- let env: Environment = Environment { - prot_params: MultiEraProtocolParameters::Conway(mk_mainnet_params_epoch_380()), - prot_magic: 764824073, - block_slot: 149807950, - network_id: 1, - acnt: Some(acnt), - }; let mut conway_prot_params: ConwayProtParams = mk_mainnet_params_epoch_380(); conway_prot_params.collateral_percentage = 10; + let env: Environment = Environment { + prot_params: MultiEraProtocolParameters::Conway(conway_prot_params), + prot_magic: 764824073, + block_slot: 149807950, + network_id: 1, + acnt: Some(acnt), + };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pallas-validate/tests/conway.rs` around lines 879 - 890, The test mutates conway_prot_params.collateral_percentage but never wires that into env.prot_params, so the reduced-collateral scenario is not exercised; after updating conway_prot_params, assign it into env.prot_params (e.g. set env.prot_params = MultiEraProtocolParameters::Conway(conway_prot_params) or construct Environment using conway_prot_params) before calling validate_txs so the validate_txs call uses the mutated ConwayProtParams.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@pallas-validate/tests/conway.rs`:
- Around line 879-890: The test mutates conway_prot_params.collateral_percentage
but never wires that into env.prot_params, so the reduced-collateral scenario is
not exercised; after updating conway_prot_params, assign it into env.prot_params
(e.g. set env.prot_params =
MultiEraProtocolParameters::Conway(conway_prot_params) or construct Environment
using conway_prot_params) before calling validate_txs so the validate_txs call
uses the mutated ConwayProtParams.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a213e8ac-b5c4-459b-a6b2-2566928bed35
📒 Files selected for processing (11)
pallas-codec/src/lib.rspallas-math/src/math.rspallas-network/src/miniprotocols/handshake/server.rspallas-network/src/miniprotocols/localstate/queries_v16/codec.rspallas-primitives/src/conway/script_data.rspallas-validate/src/phase1/alonzo.rspallas-validate/src/phase2/script_context.rspallas-validate/src/phase2/tx.rspallas-validate/tests/babbage.rspallas-validate/tests/common.rspallas-validate/tests/conway.rs
💤 Files with no reviewable changes (1)
- pallas-validate/src/phase2/script_context.rs
Summary
cargo clippy --all-targets --all-features(only an externalchumsky v1.0.0-alpha.7future-incompat note remains, untouchable from this repo).cargo clippy -- -D warnings) is green.pallas-validate/src/phase1/alonzo.rs: collateral check now extracts the shared lovelace comparison acrossCoinandMultiassetarms (eliminatescollapsible_match).pallas-primitives/src/conway/script_data.rs:const LazyLock<…>→static LazyLock<…>(interior mutability lint).pallas-validate/tests/common.rs: existing tuple type aliases (BabbageTxOutInfo,ConwayCollateralInfoMut, …) exposed aspub;babbage.rs/conway.rsnow use them instead of duplicating 4–5-field tuple types inline.assert!(false, msg)→panic!(msg)inpallas-mathand validate tests.sort_by→sort_by_keyw/Reverse, removed needlessreturns, removed redundant.cloned(), uselessError::fromconversion, redundant&-then-deref, collapsed nested matches intomatches!, dropped a-> ()return.Test plan
cargo clippy --all-targets --all-features— clean (modulo external chumsky note)cargo clippy -- -D warnings(CI invocation) — passescargo fmt --all -- --check— cleancargo test -p pallas-math --lib— 19 passedcargo test -p pallas-network --lib— 240 passedcargo test -p pallas-validate --test babbage --test conway— all passcargo check --all-targets --all-features— builds🤖 Generated with Claude Code
Summary by CodeRabbit
Refactor
Tests