Create rule S1656: Variables should not be self-assigned (#4679)
* Add rust to rule S1656 * 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>
This commit is contained in:
parent
a9fc281e99
commit
3c466262f6
5
rules/S1656/rust/metadata.json
Normal file
5
rules/S1656/rust/metadata.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"tags": [
|
||||
"clippy"
|
||||
]
|
||||
}
|
40
rules/S1656/rust/rule.adoc
Normal file
40
rules/S1656/rust/rule.adoc
Normal file
@ -0,0 +1,40 @@
|
||||
== Why is this an issue?
|
||||
|
||||
include::../description.adoc[]
|
||||
|
||||
=== Noncompliant code example
|
||||
|
||||
[source,rust,diff-id=1,diff-type=noncompliant]
|
||||
----
|
||||
let mut x = 5;
|
||||
x = x; // Self-assignment - does nothing
|
||||
----
|
||||
|
||||
==== Compliant solution
|
||||
|
||||
[source,rust,diff-id=1,diff-type=compliant]
|
||||
----
|
||||
let mut x = 5;
|
||||
// Removed the self-assignment
|
||||
----
|
||||
|
||||
== Resources
|
||||
=== Documentation
|
||||
|
||||
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#self_assignment
|
||||
|
||||
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[]
|
Loading…
x
Reference in New Issue
Block a user