keep-starknet-strange / cairo-lint

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

Add `manual_unwrap_or` #66

Open 0xLucqs opened 1 week ago

0xLucqs commented 1 week ago

What it does

Finds patterns that reimplement Option::unwrap_or or Result::unwrap_or.

Why is this bad?

Concise code helps focusing on behavior instead of boilerplate.

Example

let foo: Option<i32> = None;
match foo {
    Some(v) => v,
    None => 1,
};

Use instead:

let foo: Option<i32> = None;
foo.unwrap_or(1);

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

coxmars commented 1 week ago

Hi @0xLucqs, I would like to work in this one asap 🫡

onlydustapp[bot] commented 1 week ago

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

Benjtalkshow commented 1 week ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello, I can easily work on this task. I will be glad if this task is assigned to me.

lindsaymoralesb commented 1 week ago

Hi @0xLucqs I'd like to hop into this issue if still available. I'd use the clippy and given examples as a reference to see how it should behave/work and also I already have the exp on this project with the collapsible_if_else issue i solved before.

onlydustapp[bot] commented 1 week ago

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

chachaleo commented 1 week ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have contributed to a lot of project in Starknet, I have experience in Rust

How I plan on tackling this issue

Read the code base and merged PR and implement in a similar way

gregemax commented 5 days ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have a strong background in software development, particularly in Rust programming. My experience includes contributing to various projects, where I’ve focused on improving code quality and readability through the use of tools like Clippy. I’m well-versed in identifying code patterns that can lead to inefficiencies and am passionate about promoting best practices within the Rust community. This background enables me to effectively identify and implement lints like manual_unwrap_or, ensuring that developers can write cleaner, more maintainable code.

How I plan on tackling this issue

To tackle the implementation of the manual_unwrap_or lint, I would start by analyzing common patterns in existing Rust codebases where developers manually implement the behavior of Option::unwrap_or and Result::unwrap_or. I’d focus on identifying these patterns by reviewing various projects and gathering examples.

Next, I would define the lint logic by creating a set of rules that can effectively detect these patterns using the Rust Analyzer framework. This would involve pattern matching within the abstract syntax tree (AST) to pinpoint instances of manual matching that could be simplified.

After establishing the detection logic, I would prioritize thorough testing to ensure that the lint accurately identifies the intended patterns without false positives. This would include writing unit tests and integration tests to cover a wide range of scenarios

od-hunter commented 19 hours ago

Hi @0xLucqs , please can I be assigned please? This would be my first time contributing to this repo and I’d love to be given the opportunity.

onlydustapp[bot] commented 19 hours ago

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