Skip to content

Commit

Permalink
Update RSPEC
Browse files Browse the repository at this point in the history
  • Loading branch information
yassin-kammoun-sonarsource committed Feb 21, 2025
1 parent ea9ecf0 commit 65680c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
6 changes: 5 additions & 1 deletion rules/S6466/rust/metadata.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
{
}
"tags": [
"clippy",
"out_of_bounds_indexing"
]
}
39 changes: 16 additions & 23 deletions rules/S6466/rust/rule.adoc
Original file line number Diff line number Diff line change
@@ -1,44 +1,37 @@
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)
An array index out-of-bounds panic is a bug class that occurs in Rust when a
program tries to access an array element that does not exist.
This bug can cause your program to crash or behave unexpectedly.

//=== What is the potential impact?
include::../impact.adoc[]

== How to fix it
//== How to fix it in FRAMEWORK NAME

To fix an array index out of bounds panic in Rust, you should always ensure
that you are accessing array elements within the bounds of the array.

=== Code examples

==== Noncompliant code example

[source,rust,diff-id=1,diff-type=noncompliant]
----
FIXME
let x = [1, 2, 3, 4];
x[9]; // Out of bounds indexing
----

==== Compliant solution

[source,rust,diff-id=1,diff-type=compliant]
----
FIXME
----

//=== How does this work?
let x = [1, 2, 3, 4];
//=== Pitfalls

//=== Going the extra mile
x[0];
----

== Resources
=== Documentation

//== Resources
//=== Documentation
//=== Articles & blog posts
//=== Conference presentations
//=== Standards
//=== External coding guidelines
//=== Benchmarks
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#out_of_bounds_indexing

0 comments on commit 65680c0

Please sign in to comment.