-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
I-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveS-needs-discussionStatus: Needs further discussion before merging or work can be startedStatus: Needs further discussion before merging or work can be startedgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
if condition1() {
1
} else if condition2() {
1
} else if condition3() {
2
} else {
3
}There are many cases where code like this shouldn't be warned on. While you could do condition1() || condition2() often times it is more clear of the intent if they are separate. Especially if the conditions are non-trivial compared to the value being returned.
I think the right time for this warning to warn is if the last if has the same condition as the else. For example the following two cases would warn.
if condition1() {
1
} else {
1
}if condition1() {
1
} else if condition2() {
2
} else {
2
}jdahlstrom, g2p, maxgawason and wlinna
Metadata
Metadata
Assignees
Labels
I-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveS-needs-discussionStatus: Needs further discussion before merging or work can be startedStatus: Needs further discussion before merging or work can be startedgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy