rust-lang / rust-lang/rust-clippy
How about a `redundant_ok` lint?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
I've noticed a few places in the code with which I work where Ok( and ?) can be removed from the ends of a line without altering system behavior - would it be good to have Clippy flag those?
Advantage
The advantage would be that the code on the page gets to avoid (a small bit of) unnecessary syntactic structural complexity.
Drawbacks
Maybe some folks like seeing the Ok as a visual reminder or cue of "this is an exit point of the current behavior"? Since there's not a return keyword like in other languages? ... but I'm just supposing and speculating about that.
Example
Ok(helper_function_call(4)?)
Could be written as:
helper_function_call(4)
Comparison with existing lints
I had figured that this probably already existed, but it doesn't yet seem to, nor did I find any past issue proposing it.
Additional Context
I'm not aware of any additional context; feel free to inform me about what I am overlooking.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating existing Clippy lints related to redundant expressions and compare their handling of the Ok(helper_function_call(4)?) example. Determine the intended cases and exceptions, then add coverage showing when the lint should flag code and when it should not.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100