Create rule S1116: Empty statements should be removed (#4728)

* Add rust to rule S1116

* Update RSPEC

---------

Co-authored-by: yassin-kammoun-sonarsource <yassin-kammoun-sonarsource@users.noreply.github.com>
Co-authored-by: yassin-kammoun-sonarsource <yassin.kammoun@sonarsource.com>
This commit is contained in:
github-actions[bot] 2025-03-19 13:38:13 +00:00 committed by GitHub
parent 77af1ab66a
commit 99086a587d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 55 additions and 0 deletions

View File

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

View File

@ -0,0 +1,49 @@
== Why is this an issue?
include::../description.adoc[]
=== Code examples
==== Noncompliant code example
[source,rust,diff-id=1,diff-type=noncompliant]
----
fn main() {
let x = 5;
if x > 0 {
println!("x is positive");
}; // Noncompliant
match x {
1 => println!("x is one"),
2 => println!("x is two"),
_ => println!("x is something else"),
}; // Noncompliant
}
----
==== Compliant solution
[source,rust,diff-id=1,diff-type=compliant]
----
fn main() {
let x = 5;
if x > 0 {
println!("x is positive");
}
match x {
1 => println!("x is one"),
2 => println!("x is two"),
_ => println!("x is something else"),
}
}
----
== Resources
=== Documentation
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_semicolon