Compare commits

...

2 Commits

Author SHA1 Message Date
yassin-kammoun-sonarsource
35b20f35fd Update RSPEC 2025-03-25 14:23:54 +01:00
yassin-kammoun-sonarsource
05a2bd0cdf Add rust to rule S2437 2025-03-25 12:58:45 +00:00
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,6 @@
{
"tags": [
"suspicious",
"clippy"
]
}

View File

@ -0,0 +1,28 @@
== Why is this an issue?
Using redundant bit masks in comparisons can be misleading because the bit mask does not alter the result of the comparison. This makes the code harder to read and understand. It may also suggest incorrect logic or purpose, increasing the risk of errors.
=== Code examples
==== Noncompliant code example
[source,rust,diff-id=1,diff-type=noncompliant]
----
let x = 1;
if (x | 2 > 3) { // Noncompliant: Bitwise OR with 1 is redundant in this context
}
----
==== Compliant solution
[source,rust,diff-id=1,diff-type=compliant]
----
let x = 1;
if (x > 3) { // Compliant: Simplifies the comparison by removing redundant bit operation
}
----
== Resources
=== Documentation
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#ineffective_bit_mask