[Feature Request] List of Additional Aptos Move Lint Checks #15221
Labels
enhancement
New feature or request
move-linter
Issues related to the Move Linter
stale-exempt
Prevents issues from being automatically marked and closed as stale
🚀 Feature Request
Below is a list of additional checks that we would like to add to
aptos move lint
. Please feel free to comment if you would like any of these implemented sooner rather than later, or have ideas for other checks.aptos_std::math64::mul_div
instead ofa * b / c
to prevent intermediate overflow. Same withu8
andu128
for which similar functions exist.x = y; y = x;
,a.b = x.y; x.y = a.b;
x && true
,true && x
=>x
x || false
,false || x
=>x
x && false
=>{x; false}
false && x
=>false
x || true
=>{x; true}
true || x
=>true
(&mut 0) = 3;
&x
;pure_side_effect_free_function();
assert!(true)
orassert!(false)
, and suggest they can either be removed or replaced with an explicit abort.==
,>
,>=
,<
,<=
,!=
,&&
,||
,&
,|
,^
, ``,/
.x.y = x.y
, which can all be removed.&mut
of a const is taken: the mutable reference will refer to the copy, not the originalconst
item (Rust also warns on this).break
,return
, orcontinue
. All they do is obfuscate the code, so rewrite code without loop.a && b || a
can be replaced with justa
.if (a + b < a) { ... }
.x <= 400 && a < 500
, and always false/true comparisons:x <= 400 && x > 500
.let a = a;
This is likely unintentional.10..0
, etc. This might not be intentional, the developer might be erroneously attempting a reverse range.if
branch with no else branch (also, emptyif
with someelse
branch).if
conditions (i.e., nestedif
that can be collapsed with&&
).else { if ... }
=>else if ...
.return
at the end of a function.x as u64
whenx
is alreadyu64
).loop {}
expressions (empty loops that do not terminate).(&mut v).foo()
which can be simplified tov.foo()
, because needed mutable/immutable references are automatically added in receiver-style calls.Foo {foo: foo}
can be replaced by justFoo {foo}
and suggest it.The text was updated successfully, but these errors were encountered: