Skip to content

Add rule G025 to flag post-decrement loop indexing patterns - #761

Merged
mijinummi merged 2 commits into
MDTechLabs:mainfrom
Mkalbani:feat/g025-loop-decrement-750
Aug 25, 2026
Merged

Add rule G025 to flag post-decrement loop indexing patterns#761
mijinummi merged 2 commits into
MDTechLabs:mainfrom
Mkalbani:feat/g025-loop-decrement-750

Conversation

@Mkalbani

Copy link
Copy Markdown
Contributor

Summary

  • Implemented Rule G025 to detect post-decrement loop counters such as i--
  • Recommends replacing post-decrement with pre-decrement (--i)
  • Added coverage for post-decrement, pre-decrement, and unrelated decrement patterns
  • Added Solidity fixture samples

Testing

  • git diff --check
  • Rust tests could not run because cargo and rustc are unavailable in the environment

Closes #750

- Implemented RuleG025LoopDecrement to analyze for loops and identify post-decrement patterns.
- Added tests to ensure correct flagging of post-decrement usage in loop counters.
- Created sample Solidity contract to demonstrate post-decrement and pre-decrement loop structures.
@mijinummi
mijinummi merged commit 7f74332 into MDTechLabs:main Aug 25, 2026
6 of 7 checks passed
@mijinummi

Copy link
Copy Markdown
Collaborator

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RULE] Rule G025: Flag Post-Decrement Loop Indexing Patterns

2 participants