-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
A-lintArea: New lintsArea: New lintsL-complexityLint: Belongs in the complexity lint groupLint: Belongs in the complexity lint groupL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions
Description
Lint idea:
let x = if [let]? _ {
{true,false}
} else {
{false,true}
}
// ... maybe some code not using x
if [!]?x {
do_something();
}Can be rewritten as
match _ {
Some_::Thing(..) => do_something();
_ => {}
}or
if _ {
do_something();
}What to keep in mind when implementing this:
- Differ between
ifandif let: Suggest rewriting it as oneifin the first case and as amatchin the second*. - Between the binding and the usage of the binding is no other use of the binding.
- Get the conditions right. -> Write many test cases with all combinations of conditions and returns.
- Maybe this lint should only trigger on
if/elseblocks returningtrue/false, without doing anything else inside? - I couldn't come up with a lint name, so be creative :)
cc #4308
- Could conflict with the
single_match_elselint, but this is a pedantic lint, so we can ignore this
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsL-complexityLint: Belongs in the complexity lint groupLint: Belongs in the complexity lint groupL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions