← back to index

S1656 — Variables should not be self-assigned

Language: VB.NET  |  Type: BUG  |  Severity: Major

Why is this an issue?

There is no reason to re-assign a variable to itself. Either this statement is redundant and should be removed, or the re-assignment is a mistake and some other value or variable was intended for the assignment instead.

Code examples

Noncompliant code example

Public Sub SetName(name As String)
  name = name ' Noncompliant
End Sub

Compliant solution

Public Sub SetName(name As String)
  Me.name = name ' Compliant
End Sub