Create rule S7439 Comparisons with overlapping ranges that are always false should not be made (#4782)
* Create rule S7439 * Update rule.adoc * Update metadata.json * Update rule.adoc * Update metadata.json --------- Co-authored-by: sallaigy <sallaigy@users.noreply.github.com> Co-authored-by: Gyula Sallai <gyula.sallai@sonarsource.com>
This commit is contained in:
parent
1de188a9e5
commit
bd332080f2
2
rules/S7439/metadata.json
Normal file
2
rules/S7439/metadata.json
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
{
|
||||||
|
}
|
24
rules/S7439/rust/metadata.json
Normal file
24
rules/S7439/rust/metadata.json
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"title": "Comparisons with overlapping ranges that are always false should not be made",
|
||||||
|
"type": "BUG",
|
||||||
|
"status": "ready",
|
||||||
|
"remediation": {
|
||||||
|
"func": "Constant\/Issue",
|
||||||
|
"constantCost": "5min"
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"clippy"
|
||||||
|
],
|
||||||
|
"defaultSeverity": "Critical",
|
||||||
|
"ruleSpecification": "RSPEC-7439",
|
||||||
|
"sqKey": "S7439",
|
||||||
|
"scope": "All",
|
||||||
|
"defaultQualityProfiles": ["Sonar way"],
|
||||||
|
"quickfix": "unknown",
|
||||||
|
"code": {
|
||||||
|
"impacts": {
|
||||||
|
"RELIABILITY": "HIGH"
|
||||||
|
},
|
||||||
|
"attribute": "LOGICAL"
|
||||||
|
}
|
||||||
|
}
|
20
rules/S7439/rust/rule.adoc
Normal file
20
rules/S7439/rust/rule.adoc
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
== Why is this an issue?
|
||||||
|
|
||||||
|
Comparisons involving overlapping ranges that can never be true are likely a programming mistake and can result in unreachable code.
|
||||||
|
|
||||||
|
|
||||||
|
=== Code examples
|
||||||
|
|
||||||
|
==== Noncompliant code example
|
||||||
|
[source,rust]
|
||||||
|
----
|
||||||
|
if status_code <= 400 && status_code > 500 { // Noncompliant: The condition can never be true.
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
----
|
||||||
|
|
||||||
|
== Resources
|
||||||
|
=== Documentation
|
||||||
|
|
||||||
|
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#impossible_comparisons
|
Loading…
x
Reference in New Issue
Block a user