![github-actions[bot]](/assets/img/avatar_default.png)
* 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>
50 lines
857 B
Plaintext
50 lines
857 B
Plaintext
== 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
|