feat: constructor custom errors, enum iteration rule, event topic constants, and redundant cast rule - #716
Merged
mijinummi merged 1 commit intoJul 29, 2026
Conversation
…stants, and redundant cast rule Implement assigned issues for abdulrcrtw: - Refactor constructor error handling to use custom errors (MDTechLabs#708) - Add static Rule G017 for enum iteration detection (MDTechLabs#707) - Inlining pre-computed constant event topic selectors (MDTechLabs#706) - Add static Rule G016 for redundant cast operations (MDTechLabs#705) Closes MDTechLabs#708 Closes MDTechLabs#707 Closes MDTechLabs#706 Closes MDTechLabs#705
|
@abdulrcrtw Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
2 tasks
mijinummi
pushed a commit
that referenced
this pull request
Jul 31, 2026
…mbly-log event topics PR #716 previously landed the initial implementations for issues #731, #730, #729, and #728, but each still had real gaps against its original acceptance criteria: - G016 (redundant address casts): the check only did a flat substring search, so it missed deeper chains like address(uint160(uint256(x))) and address(payable(uint160(x))), and had no safeguard against matching inside comments. Added detection for those chains, comment stripping, and unit tests covering both the new positive cases and the "does not flag necessary bytes32 -> address conversions" negative case called out in the issue. - G017 (enum iteration): the check only looked for "any loop" plus "any enum keyword anywhere in the file", which fails the issue's own acceptance criterion of "passes cleanly on standard integer index loops" (it flagged unrelated loops whenever an enum was declared anywhere in the contract). Rewrote it to isolate each loop body and only flag loops that actually cast their index into a known enum type, added nested-loop and while-loop coverage, and added unit tests for both positive and negative cases. - Event topics (#730): EventRegistry.sol's test file was a placeholder that asserted `true == true` and never verified the topic constants. Added ApprovalForAll/OwnershipTransferred constants, an emitViaAssembly() function demonstrating a low-level log call consuming a compile-time constant topic directly (per the issue's second requirement, which wasn't previously demonstrated), and a real test suite that checks each constant against ethers.id(...) of its canonical signature. - Heatmap reporter (#728): reporter::heatmap was never declared in gasguard-cli's lib.rs, so it was dead code not compiled into the crate at all. Wired it up, added a legend describing the tiers and colors, added visual severity bars (the "summary visual bars" requirement wasn't previously implemented), and made functions with no gas estimate render as an explicit N/A tier instead of silently falling into the LOW bucket. Closes #731 Closes #730 Closes #729 Closes #728
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
GasGuardFactory.solto use custom error definitions (InvalidOwner(),ZeroInit()) instead of string revert messages.G017inrules/g017_enum_iteration.rsto detect unbounded loops casting integers to enum types.EventRegistry.solusing compile-timebytes32 constantevent topic selectors to eliminate runtimekeccak256hashing.G016inrules/g016_redundant_casts.rsto flag redundantaddress(uint160(x))type conversion operations.Closes #708
Closes #707
Closes #706
Closes #705