Make main pass the new forge lint and pre-commit static gates - #235
Conversation
`-D` denies solc's own diagnostics too, so the two "state mutability can be restricted to pure" warnings failed the compile before forge-lint ran at all, and the four lint findings behind them had never been printed by CI. Both helpers call only pure cheatcodes, so `pure` is what they are. The `missing-zero-check` pair is a mock that answers back the addresses it was handed and authorises nothing, built by fuzz tests that reach `address(0)`; the `block-timestamp` comparison is the assertion itself. Both take a scoped disable. `x != y ? x < y : false` is `x < y`, so the `boolean-cst` constant goes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V8ViHcKLVk2YoS2joH4HdN
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughChangesTest maintenance
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Refactor Merge Risk: ⚪ Minimal · up to The PR contains localized test cleanup and lint documentation changes with no established functional or operational risk, so it is mergeable. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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. Comment |
rainix-sol-static.yamlgainedforge lint -D warningsandpre-commit run --all-files, and this repo consumes that workflow at@main.Main's last CI run predates both, so main is green over code that fails one of
them. Six open PRs sit behind it.
forge lint -D warnings-Dis a compiler flag, so it denies solc's own diagnostics as well asforge-lint's. Two
Function state mutability can be restricted to purewarnings therefore failed the compile, and the step aborted before
forge-lint ran at all — which is why the four findings behind them had never
been printed by any CI run.
view→pure×2LibRainDeploySnapshot.t.solsnapshotBytesConstant/snapshotAddressConstantboolean-cstLibRainDeploySnapshot.t.soltestTagPrecedesMatchesComponentOrdermissing-zero-check×2MockChainDependentOwnerconstructorblock-timestampMigrationRegistryApplyMigration.t.solFixed —
view→pure. Both helpers read a snapshot out of a string withvm.contains/vm.split/vm.parseBytes/vm.parseAddressand assert. Nothingthey call touches state, so
pureis what they are.Fixed —
boolean-cst. The tail of the tag-ordering oracle readaPatch != bPatch ? aPatch < bPatch : false. WhenaPatch == bPatch,aPatch < bPatchis alreadyfalse, so the conditional is exactlyaPatch < bPatchand the constant is dead weight. The oracle is unchanged asan expression; the fuzz test that consumes it is untouched.
Disabled —
missing-zero-check.MockChainDependentOwnerstores the twoaddresses in immutables and answers one of them back from
iOwner(). Theyauthorise nothing, and the fuzz tests that build it
(
testCheckResolvedAddressesReadsEachCallSeparately,testCheckResolvedAddressesDirtyWordNamesTheFailingRead) assume onlyfirst != second, so the fuzzer reachesaddress(0)— a zero check wouldrevert runs the mock exists to serve. The hazard the rule names does not exist
here.
Disabled —
block-timestamp. The flagged line isassertTrue(sRegistry.applied(...) != block.timestamp), asserting thatapplyMigrationHistoryrecords the moment the CALLER supplied rather than theblock it landed in. The comparison against
block.timestampIS the assertion,which is the case rainix's own comment on the step says takes a scoped disable.
pre-commit run --all-filesRun twice in the pinned
sol-shell: every hook passes, no hook writesanything, and
git statusis empty after both. The gate needs no change here,so this PR carries no pre-commit commit — there was nothing for the hooks to
write. Covered surface is the 1
.nix, 8.yaml, 3.toml, 2.mdand 2.rstracked files;shellcheckskips (no shell scripts tracked) and JSON isnot gated in this shell.
QA
forge lint -D warningsexits 1 onmainand 0 on this branch, both run innix develop github:rainlanguage/rainix/8657b83b68f41957ab85da91132c3f652c1f32c0#sol-shell, the SHA the static workflow pins.snapshotBytesConstantpure→view→Warning (2018)at:667, compile fails;snapshotAddressConstantpure→view→Warning (2018)at:679, compile fails; disable line deleted fromMockChainDependentOwner→missing-zero-check×2 at:27:17/:27:39; disable line deleted fromMigrationRegistryApplyMigration.t.sol→block-timestampat:925:20;: falserestored →boolean-cstat:1599:138. Branch with all five in place, and the branch restored after each revert, print nothing.flake.lock— the findings are forge's and solc's output, not a judgement of mine.forge lint -D warningsandpre-commit run --all-files; both covered, lint by six findings resolved (2 solc + 4 forge-lint) and pre-commit by two clean runs over a stable tree.forge fmt --checkre-run and green, since collapsing the ternary shortened the line and fmt then wanted it on one.Every one of PRs #219, #226, #228, #229, #232 and #234 merges this cleanly, and
each is lint-clean and pre-commit-clean with it applied — none carries a
finding of its own.
🤖 Generated with Claude Code
https://claude.ai/code/session_01V8ViHcKLVk2YoS2joH4HdN
Summary by CodeRabbit
Tests
Chores