Skip to content

feat(lint): add require-revert-in-loop detector#15236

Merged
mablr merged 6 commits into
foundry-rs:masterfrom
Berektassuly:require-revert-in-loop-lint
Jun 26, 2026
Merged

feat(lint): add require-revert-in-loop detector#15236
mablr merged 6 commits into
foundry-rs:masterfrom
Berektassuly:require-revert-in-loop-lint

Conversation

@Berektassuly

@Berektassuly Berektassuly commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Motivation

Refs #14381.

Adds the require-revert-in-loop detector from the lint parity checklist. A single failing require or revert inside a loop can revert the entire batch, so surfacing these cases helps users review whether validation should happen before the loop, skip invalid entries, or split work into separate calls.

Solution

Adds a low-severity Solidity lint for require calls and revert statements executed in loop context. The detector covers direct loop bodies, internal helper calls reached from loops, modifier placeholder execution inside loops, and inline assembly revert.

The shared loop-context visitor now exposes both statements and expressions so this lint can reuse the same internal-call and modifier traversal already used by loop-related lints, while avoiding duplicate reports for helpers that introduce their own loops and are called from outside a loop.

Validation

Tests pass: cargo test -p forge --test ui -- RequireRevertInLoop

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@mablr mablr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed clippy warning + Added coverage.

Seems good, thank you @Berektassuly!

@figtracer figtracer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mablr mablr enabled auto-merge (squash) June 26, 2026 09:24
@Berektassuly

Copy link
Copy Markdown
Contributor Author

Opened the matching Foundry Book docs PR here: foundry-rs/book#1911

This should address the ensure_lint_rule_docs failure once the Book PR is merged and deployed

@mablr mablr merged commit 4f1513a into foundry-rs:master Jun 26, 2026
19 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Foundry Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants