keep-starknet-strange / cairo-lint

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

Add `manual_assert` #62

Open 0xLucqs opened 5 days ago

0xLucqs commented 5 days ago

What it does

Detects if-then-panic! that can be replaced with assert!.

Why is this bad?

assert! is simpler than if-then-panic!.

Example

let sad_people: Array<&str> = arrray![];
if !sad_people.is_empty() {
    panic!("there are sad people: {:?}", sad_people);
}

Use instead:

let sad_people: Array<&str> = array![];
assert!(sad_people.is_empty(), "there are sad people: {:?}", sad_people);

https://rust-lang.github.io/rust-clippy/master/index.html#/manual_assert

stevencartavia commented 5 days ago

Hi, I would like to work on this!

onlydustapp[bot] commented 5 days ago

Hey @stevencartavia! Thanks for showing interest. We've created an application for you to contribute to Cairo lint. Go check it out on OnlyDust!

0xLucqs commented 5 days ago

let's go!