From 9f6baeaede0665b79f0d53f8d9fc9b5b52c85c6e Mon Sep 17 00:00:00 2001 From: yassin-kammoun-sonarsource Date: Thu, 27 Mar 2025 11:04:51 +0100 Subject: [PATCH] Update RSPEC --- rules/S7464/rust/metadata.json | 11 +++++------ rules/S7464/rust/rule.adoc | 36 ++++++++++------------------------ 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/rules/S7464/rust/metadata.json b/rules/S7464/rust/metadata.json index 2e37bb6fed..7f0ec7c19d 100644 --- a/rules/S7464/rust/metadata.json +++ b/rules/S7464/rust/metadata.json @@ -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" } } diff --git a/rules/S7464/rust/rule.adoc b/rules/S7464/rust/rule.adoc index 368fb2954e..eba6561db9 100644 --- a/rules/S7464/rust/rule.adoc +++ b/rules/S7464/rust/rule.adoc @@ -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::>(); // 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::>(); // 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