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:
parent
77af1ab66a
commit
99086a587d
6
rules/S1116/rust/metadata.json
Normal file
6
rules/S1116/rust/metadata.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"tags": [
|
||||
"unused",
|
||||
"clippy"
|
||||
]
|
||||
}
|
49
rules/S1116/rust/rule.adoc
Normal file
49
rules/S1116/rust/rule.adoc
Normal 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
|
Loading…
x
Reference in New Issue
Block a user