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 S4275 FP: Support &= assignment #9688

Open
keith-softsure opened this issue Oct 24, 2024 · 2 comments
Open

Fix S4275 FP: Support &= assignment #9688

keith-softsure opened this issue Oct 24, 2024 · 2 comments
Labels
Area: VB.NET VB.NET rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.

Comments

@keith-softsure
Copy link

keith-softsure commented Oct 24, 2024

SonarLint does not recognise &= operator as assignment

S4275 fails the SET statement and suggests that _feedback parameter is not assigned a value in this line:
_feedback &= value

Repro steps

Friend Property Feedback As String
    Get
        Return _feedback
    End Get
    Private Set(value As String)
        value = Trim(value).Trim()
        Debug.Print(value)
        If _feedback <> Nothing Then _feedback &= vbCrLf
        _feedback &= value ' original Code
        ' _feedback = _feedback & value ' SonarLint compliant code
    End Set
End Property
Private _feedback As String

Expected behavior

_feedback &= value ' original Code
should be acceptable

Actual behavior

_feedback &= value ' original Code
generates S4275 error

Known workarounds

   _feedback = _feedback & value ' SonarLint compliant code

Related information

  • C#/VB.NET Plugins version ... 8.5.0.10497
  • Visual Studio version ... 17.11.5
  • MSBuild / dotnet version ... 4.8.09037
  • Using SonarLint & Sonar Cloud
  • Operating System ... Windows 10
@CristianAmbrosini CristianAmbrosini changed the title Fix S4275 FP/FN: SonarLint does not recognise &= as assignment Fix S4275 FP: Support &= assignment Oct 30, 2024
@CristianAmbrosini CristianAmbrosini added Type: False Positive Rule IS triggered when it shouldn't be. Area: VB.NET VB.NET rules related issues. labels Oct 30, 2024
@CristianAmbrosini CristianAmbrosini self-assigned this Oct 30, 2024
@CristianAmbrosini
Copy link
Contributor

Hi @keith-softsure! I confirm this as a false positive. I'll add a reproducer to our repository shortly. Thanks for the feedback!

@CristianAmbrosini CristianAmbrosini removed their assignment Oct 31, 2024
@keith-softsure
Copy link
Author

keith-softsure commented Nov 4, 2024 via email

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 Positive Rule IS triggered when it shouldn't be.
Projects
None yet
Development

No branches or pull requests

2 participants