keep-starknet-strange / cairo-lint

A collection of lints to catch common mistakes and improve your Cairo code.
21 stars 35 forks source link

feat: manual_expect lint #109

Closed chachaleo closed 2 months ago

chachaleo commented 2 months ago

Resolves: #108

Addition of lint : manual_expect

note :

One of the case fixed introduces an unused import if panic_with_felt252 is not used somewhere else in the file :

use core::panic_with_felt252;
fn main() {
    let foo: Option::<i32> = Option::None;
    let _foo = match foo {
        Option::Some(x) => x,
        Option::None => panic_with_felt252('err'),
    };
}

is fixed to

use core::panic_with_felt252; //unused import
fn main() {
    let foo: Option::<i32> = Option::None;
    let _foo = foo.expect('err');
}

Let me know if I should deal with this in this PR or open a new one