Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit f6ef722

Browse files
authored
Add nested_if documentation (#1021)
1 parent 08f6046 commit f6ef722

File tree

1 file changed

+22
-0
lines changed
  • apps/nextra/pages/en/build/smart-contracts

1 file changed

+22
-0
lines changed

apps/nextra/pages/en/build/smart-contracts/linter.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,28 @@ Checks for patterns where there are needless references taken when accessing a f
134134
- `(&s).f` can be simplified to `s.f`
135135
- `(&mut s).f = 42;` can be simplified to `s.f = 42;`
136136

137+
### `nested_if`
138+
139+
Checks for nested if statements that can be simplified using the `&&` operator. This lint identifies patterns where an inner if statement with no else branch is contained within an outer if statement that also has no else branch.
140+
141+
```move
142+
if (a) {
143+
if (b) {
144+
// some code
145+
}
146+
}
147+
```
148+
149+
This pattern can be simplified to:
150+
151+
```move
152+
if (a && b) {
153+
// some code
154+
}
155+
```
156+
157+
The simplified version is more readable and avoids unnecessary nesting while maintaining the same logical behavior.
158+
137159
### `nonminimal_bool`
138160

139161
Check for boolean expressions that can be simplified when a boolean literal (either `true` or `false`) is part of a binary or unary boolean operator. Examples:

0 commit comments

Comments
 (0)