Update RSPEC

This commit is contained in:
yassin-kammoun-sonarsource 2025-03-27 11:04:51 +01:00
parent fd57f6b027
commit 9f6baeaede
2 changed files with 15 additions and 32 deletions

View File

@ -1,12 +1,13 @@
{
"title": "FIXME",
"type": "CODE_SMELL",
"title": "Infinite iterators should be finished off with a terminating operation",
"type": "BUG",
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "5min"
},
"tags": [
"clippy"
],
"defaultSeverity": "Major",
"ruleSpecification": "RSPEC-7464",
@ -16,10 +17,8 @@
"quickfix": "unknown",
"code": {
"impacts": {
"MAINTAINABILITY": "HIGH",
"RELIABILITY": "MEDIUM",
"SECURITY": "LOW"
"RELIABILITY": "MEDIUM"
},
"attribute": "CONVENTIONAL"
"attribute": "LOGICAL"
}
}

View File

@ -1,16 +1,6 @@
FIXME: add a description
// If you want to factorize the description uncomment the following line and create the file.
//include::../description.adoc[]
== Why is this an issue?
FIXME: remove the unused optional headers (that are commented out)
//=== What is the potential impact?
== How to fix it
//== How to fix it in FRAMEWORK NAME
Infinite iteration is usually an error in most cases, leading to programs that never terminate. While there are some acceptable use cases such as event streams, developers often unintentionally create infinite loops, causing resource exhaustion or unresponsive behavior.
=== Code examples
@ -18,27 +8,21 @@ FIXME: remove the unused optional headers (that are commented out)
[source,rust,diff-id=1,diff-type=noncompliant]
----
FIXME
use std::iter;
iter::repeat(1_u8).collect::<Vec<_>>(); // Noncompliant: This creates an infinite iterator.
----
==== Compliant solution
[source,rust,diff-id=1,diff-type=compliant]
----
FIXME
use std::iter;
iter::repeat(1_u8).take(5).collect::<Vec<_>>(); // Compliant: This creates a finite iterator by taking only the first 5 items.
----
//=== How does this work?
== Resources
=== Documentation
//=== Pitfalls
//=== Going the extra mile
//== Resources
//=== Documentation
//=== Articles & blog posts
//=== Conference presentations
//=== Standards
//=== External coding guidelines
//=== Benchmarks
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#infinite_iter