new lint: functions that return unneeded options/results #5969
Labels
A-lint
Area: New lints
E-medium
Call for participation: Medium difficulty level problem and requires some initial experience.
L-complexity
Lint: Belongs in the complexity lint group
What it does
I wonder if it makes sense to have a lint that checks for functions that wrap their return types in
Option
orResult
unnecessarily i.e. functions that always returnOk()
orSome()
.This could indicate there once was some refactoring which removed the
Err()
orNone
case and the function can be simplified to directly return the wrapped type instead of the Option/Result.Categories (optional)
This could be
complexity
orpedantic
lint.What is the advantage of the recommended code over the original code
could would be warned about and could be refactored to
Drawbacks
This would probably "push" option-wrapping into other functions which might be annoying, i.e.
could become
if
foo
requires anOption
The lint should not probably not apply to
pub
fns as it suggests changing function signatures.The text was updated successfully, but these errors were encountered: