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 manual_unwrap_or #66

Open
0xLucqs opened this issue Sep 17, 2024 · 11 comments
Open

Add manual_unwrap_or #66

0xLucqs opened this issue Sep 17, 2024 · 11 comments
Labels
good first issue Good for newcomers lint

Comments

@0xLucqs
Copy link
Contributor

0xLucqs commented Sep 17, 2024

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

@0xLucqs 0xLucqs added good first issue Good for newcomers lint labels Sep 17, 2024
@coxmars
Copy link
Contributor

coxmars commented Sep 17, 2024

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

Copy link

onlydustapp bot commented Sep 17, 2024

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
Copy link

Benjtalkshow commented Sep 17, 2024

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
Copy link
Contributor

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.

Copy link

onlydustapp bot commented Sep 17, 2024

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
Copy link
Contributor

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
Copy link

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
Copy link

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.

Copy link

onlydustapp bot commented Sep 24, 2024

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!

@adpthegreat
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a rust developer of close to a year that is interested in open source and tackling problems I recently made contributions to the rust and typescript technical content of solana-developers and I aim looking to make more meaningful contributions to other rust based projects in the web3 ecosystem

How I plan on tackling this issue

I would do research by studying the logic of the manual_unwrap_or lint rule for the rust_analyzer program , then write the relevant logic for the lint rule based on this implementation to find similar patterns that use pattern matching that is those that reimplement Option::unwrap_or or Result::unwrap_or as the PR says , then I would run the tests (and write relevant tests if there are no tests ) for the lint rule to make sure it works as intended

@SumitGoulikar
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm an undergraduate in Computer Science and am well experienced in coding across different programming languages. Along the way, I have enjoyed building efficient algorithms, practicing data structures, and tackling problems in clean, optimized code. So far, I've had fun using best practices to enhance performance and readability in projects.

I'm excited about this project because it will take my coding abilities, problem-solving skills, and passion for learning to the benefit of improving and maintaining code quality. With my strong foundation in computer science and eagerness to collaborate on impactful projects, you can expect to receive valuable contributions from me.

@mkaput mkaput added this to cairo-lint Dec 9, 2024
@github-project-automation github-project-automation bot moved this to Triage in cairo-lint Dec 9, 2024
@mkaput mkaput moved this from Triage to Backlog in cairo-lint Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers lint
Projects
Status: Backlog
Development

No branches or pull requests

9 participants