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:
github-actions[bot] 2025-03-19 12:12:17 +01:00 committed by GitHub
parent a9fc281e99
commit 3c466262f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,5 @@
{
"tags": [
"clippy"
]
}

View 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[]