![github-actions[bot]](/assets/img/avatar_default.png)
* Add rust to rule S126 * 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>
34 lines
558 B
Plaintext
34 lines
558 B
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,rust,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
if x == 0 {
|
|
do_something();
|
|
} else if x == 1 {
|
|
do_something_else();
|
|
}
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,rust,diff-id=1,diff-type=compliant]
|
|
----
|
|
if x == 0 {
|
|
do_something();
|
|
} else if x == 1 {
|
|
do_something_else();
|
|
} else {
|
|
panic!("Unexpected value for x");
|
|
}
|
|
----
|
|
|
|
== Resources
|
|
|
|
=== Documentation
|
|
|
|
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#else_if_without_else
|