19 lines
820 B
Plaintext
19 lines
820 B
Plaintext
![]() |
== Why is this an issue?
|
||
|
|
||
|
An expression like `min <= x` may misleadingly imply that it is possible for `x` to be less than the minimum. Expressions like `max < x` are likely mistakes, as they can never be true. These comparisons involving minimum or maximum values for their type with integer and boolean types are often unintentional and can lead to confusion and potentially incorrect program logic.
|
||
|
|
||
|
=== Noncompliant code example
|
||
|
|
||
|
[source,rust]
|
||
|
----
|
||
|
let vec: Vec<isize> = Vec::new();
|
||
|
if vec.len() <= 0 {} // Noncompliant: 0 is the minimum value for usize, this is always true.
|
||
|
|
||
|
if 100 > i32::MAX {} // Noncompliant: i32::MAX is the maximum value for i32, this is always false.
|
||
|
----
|
||
|
|
||
|
== Resources
|
||
|
=== Documentation
|
||
|
|
||
|
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons
|