Skip to content

Commit

Permalink
S3063: Add FP repro for #7324 (#7331)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-mikula-sonarsource authored Jun 6, 2023
1 parent aa09804 commit a720d7f
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,40 @@ public static class StringBuilderExtensions
{
public static string ToStringAndFree(this StringBuilder sb) => string.Empty;
}

// https://github.com/SonarSource/sonar-dotnet/issues/7324
public class Repro_7324
{
public string Concat_Prefix()
{
var sb = new StringBuilder(); // Noncompliant FP
sb.Append("Lorem ipsum");
var ret = "Prefix: " + sb;
return ret;
}

public string Concat_Infix()
{
var sb = new StringBuilder(); // Noncompliant FP
sb.Append("Lorem ipsum");
var ret = "Prefix: " + sb + " suffix";
return ret;
}

public string Concat_Suffix()
{
var sb = new StringBuilder(); // Noncompliant FP
sb.Append("Lorem ipsum");
var ret = sb + " suffix";
return ret;
}

public string Concat_OutsideDeclaration()
{
var sb = new StringBuilder(); // Noncompliant FP
sb.Append("Lorem ipsum");
string ret;
ret = "Prefix: " + sb;
return ret;
}
}

0 comments on commit a720d7f

Please sign in to comment.