Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix S1656 FN: Self-assignment to Me.Field is not detected #9667

Open
PavlinII opened this issue Sep 22, 2024 · 1 comment
Open

Fix S1656 FN: Self-assignment to Me.Field is not detected #9667

PavlinII opened this issue Sep 22, 2024 · 1 comment
Labels
Area: VB.NET VB.NET rules related issues. Type: False Negative Rule is NOT triggered when it should be.

Comments

@PavlinII
Copy link
Contributor

S1656 detects useless self-assignment to field, but does not raise when a field is self-assigned using Me. (like this. in C#).

This can help finding bugs in constructors.

Public Class Sample

    Public First, Second As String

    Public Sub New(First As String)
        Me.First = First    'Compliant
        Second = Second     'Noncompliant, as expected
        Me.Second = Second  'False Negative
        Second = Me.Second  'False Negative
    End Sub

End Class
@mary-georgiou-sonarsource
Copy link
Contributor

mary-georgiou-sonarsource commented Sep 24, 2024

Dear @PavlinII thanks a lot for reporting this.
I confirm it's a False Negative. We'll add it to our backlog and fix it sometime in the future.

@pavel-mikula-sonarsource, our VB.NET expert will be thrilled to fix this.

@CristianAmbrosini CristianAmbrosini added Area: VB.NET VB.NET rules related issues. Type: False Negative Rule is NOT triggered when it should be. labels Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: VB.NET VB.NET rules related issues. Type: False Negative Rule is NOT triggered when it should be.
Projects
None yet
Development

No branches or pull requests

3 participants