keep-starknet-strange / cairo-lint

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

Add `collapsible_if` #37

Open 0xLucqs opened 3 weeks ago

0xLucqs commented 3 weeks ago

What it does

Checks for nested if statements which can be collapsed by &&-combining their conditions.

Why is this bad?

Each if-statement adds one level of nesting, which makes code look more complex than it really is.

Example

if x {
    if y {
        // …
    }
}

Use instead:

if x && y {
    // …
}
jimenezz22 commented 3 weeks ago

gm @0xLucqs I could help with this issue

onlydustapp[bot] commented 3 weeks ago

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