![github-actions[bot]](/assets/img/avatar_default.png)
* Add rust to rule S905 * Update RSPEC * Remove tag --------- Co-authored-by: yassin-kammoun-sonarsource <yassin-kammoun-sonarsource@users.noreply.github.com> Co-authored-by: yassin-kammoun-sonarsource <yassin.kammoun@sonarsource.com>
66 lines
1.1 KiB
Plaintext
66 lines
1.1 KiB
Plaintext
include::../summary.adoc[]
|
|
|
|
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
=== Exceptions
|
|
|
|
The rule does not raise an issue on statements containing only a semicolon (``++;++``).
|
|
|
|
== How to fix it
|
|
|
|
include::../how-to-fix.adoc[]
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,rust,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
fn get_result() -> i32 {
|
|
let mut result = 42;
|
|
if should_be_zero() {
|
|
result == 0; // Noncompliant: no side effect, was an assignment intended?
|
|
}
|
|
result
|
|
}
|
|
----
|
|
|
|
|
|
==== Compliant solution
|
|
|
|
[source,rust,diff-id=1,diff-type=compliant]
|
|
----
|
|
fn get_result() -> i32 {
|
|
let mut result = 42;
|
|
if should_be_zero() {
|
|
result = 0; // Compliant
|
|
}
|
|
result
|
|
}
|
|
----
|
|
|
|
|
|
include::../see.adoc[]
|
|
|
|
=== Documentation
|
|
|
|
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#no_effect
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|