Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions apps/nextra/pages/en/build/smart-contracts/linter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ If you find any issues, please submit [bugs and feedback](https://github.com/apt
Checks for patterns that look like overflow checks done in a C style:
```move
// Overflow check
if (x > x + y) {
if (x > x + y) {
abort 1;
};

// Underflow check
if (x < x - y) {
if (x < x - y) {
abort 1;
};
```
This pattern in Move does not make sense, as it either aborts immediately or is always true/false.
This pattern in Move does not make sense, as it either aborts immediately or is always true/false.

### `almost_swapped`
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:
Expand Down Expand Up @@ -65,6 +65,22 @@ Checks for binary operations where both operands are the same, which is likely a

This lint does not catch cases where the operands are vector access.

### `find_unnecessary_casts`

Checks for unnecessary type casts where the source expression already has the same type as the target type. These casts are redundant and can be removed to improve code readability.

For example:
```move
let x: u64 = 42;
let y = x as u64; // unnecessary cast, x is already u64
```

The above can be simplified to:
```move
let x: u64 = 42;
let y = x; // cast removed
```

### `known_to_abort`

Checks for expressions that will always abort at runtime due to known constant values that violate runtime constraints. This lint helps identify code that will deterministically fail before it reaches production.
Expand Down