You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 30, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: apps/nextra/pages/en/build/smart-contracts/linter.mdx
+25-3Lines changed: 25 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,16 +18,16 @@ If you find any issues, please submit [bugs and feedback](https://github.com/apt
18
18
Checks for patterns that look like overflow checks done in a C style:
19
19
```move
20
20
// Overflow check
21
-
if (x > x + y) {
21
+
if (x > x + y) {
22
22
abort 1;
23
23
};
24
24
25
25
// Underflow check
26
-
if (x < x - y) {
26
+
if (x < x - y) {
27
27
abort 1;
28
28
};
29
29
```
30
-
This pattern in Move does not make sense, as it either aborts immediately or is always true/false.
30
+
This pattern in Move does not make sense, as it either aborts immediately or is always true/false.
31
31
32
32
### `almost_swapped`
33
33
Checks for expression patterns that look like a failed swap attempt and notifies the user. These patterns are likely erroneous code. This currently only detects simple access patterns such as assignments to a variable or a field of a struct. Examples include:
@@ -118,6 +118,28 @@ Checks for patterns where there are needless references taken when accessing a f
118
118
-`(&s).f` can be simplified to `s.f`
119
119
-`(&mut s).f = 42;` can be simplified to `s.f = 42;`
120
120
121
+
### `nested_if`
122
+
123
+
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.
124
+
125
+
```move
126
+
if (a) {
127
+
if (b) {
128
+
// some code
129
+
}
130
+
}
131
+
```
132
+
133
+
This pattern can be simplified to:
134
+
135
+
```move
136
+
if (a && b) {
137
+
// some code
138
+
}
139
+
```
140
+
141
+
The simplified version is more readable and avoids unnecessary nesting while maintaining the same logical behavior.
142
+
121
143
### `nonminimal_bool`
122
144
123
145
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