Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add min_max #97

Open
lauchaves opened this issue Sep 22, 2024 · 2 comments
Open

Add min_max #97

lauchaves opened this issue Sep 22, 2024 · 2 comments

Comments

@lauchaves
Copy link
Contributor

lauchaves commented Sep 22, 2024

What it does


Check cases where the min or max functions are used unnecessarily, particularly when a simple comparison between two values could be clearer and more efficient.

Why is this bad?


Using min or max for two values introduces unnecessary function calls and makes the code less readable. A simple if-else comparison is both clearer and more efficient for such cases.

Example


x.max(100).min(0);

Use instead:

   if x > 100 {
        return 100;
    } else if x < 0 {
        return 0;
    } else {
        return x;
    }
@lauchaves
Copy link
Contributor Author

Hey @0xLucqs 👋 As we talked about, I’ll be taking care of this one. I’ll keep you in the loop!

Copy link

onlydustapp bot commented Sep 22, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant