SonarSource / sonar-dotnet

Code analyzer for C# and VB.NET projects
https://redirect.sonarsource.com/plugins/csharp.html
GNU Lesser General Public License v3.0
788 stars 227 forks source link

Fix S4275 FP: Support &= assignment #9688

Open keith-softsure opened 1 week ago

keith-softsure commented 1 week ago

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

CristianAmbrosini commented 1 week ago

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

keith-softsure commented 1 day ago

Thanks Cristian,

We really appreciate the feedback. And your good work. Cheers Keith From: Cristian @.> Sent: Wed, 30 October 2024 12:17 To: SonarSource/sonar-dotnet @.> Cc: Keith Shearer @.>; Mention @.> Subject: Re: [SonarSource/sonar-dotnet] Fix S4275 FP: Support &= assignment (Issue #9688)

This message originates from outside the Badger Holdings Organization, please exercise caution


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

- Reply to this email directly, view it on GitHubhttps://github.com/SonarSource/sonar-dotnet/issues/9688#issuecomment-2446457258, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BH7ROGMIQASE7EHXYKNUP4LZ6CW23AVCNFSM6AAAAABQQJHYU2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBWGQ2TOMRVHA. You are receiving this because you were mentioned.Message ID: @.**@.>>