-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lintsL-complexityLint: Belongs in the complexity lint groupLint: Belongs in the complexity lint groupgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
Detect usage of
if a < 0.0 { // or a.is_sign_negative()
-a
} else {
a
}
and
if a > 0.0 { // or a.is_sign_positive()
a
} else {
-a
}and suggest usage of abs instead
a.abs()Using abs is more efficient, handles more cases and is more succinct than using the if/else block so this lint could go under the suboptimal_flops lint. If this seems like an obvious thing and isn't worth the check then I'd be happy to close it.
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsL-complexityLint: Belongs in the complexity lint groupLint: Belongs in the complexity lint groupgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy