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
772 stars 226 forks source link

Fix S2629 FP: Constant interpolated string concatenation #9653

Closed Jake-Derrick closed 3 weeks ago

Jake-Derrick commented 3 weeks ago

Description

Please provide a succinct description of your issue. Also please provide the rule ID (e.g. S1234)

Repro steps

const string localConstant = "local";

logger.Log(LogLevel.Warning, $"Constant: {localConstant}" + $"Constant2: {localConstant}"); // Non-Compliant FP

logger.Log(LogLevel.Warning, $"Constant: {localConstant} Constant2: {localConstant}"); // Compliant

Expected behavior

Rule S2629 not raised

Actual behavior

Rule S2629 raised

Known workarounds

Use a single interpolated string

Related information

sebastien-marichal commented 3 weeks ago

Hello @Jake-Derrick,

Thank you for reporting this issue.

I confirm this is a false positive.