Skip to content

Commit

Permalink
S4158: Add repro for #9444 (#9445)
Browse files Browse the repository at this point in the history
  • Loading branch information
CristianAmbrosini authored Jun 19, 2024
1 parent f563cae commit 444559d
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1218,3 +1218,26 @@ void Test(List<Repro9425> aList)
collectionOfIds.Clear(); // Noncompliant FP
}
}

//https://github.com/SonarSource/sonar-dotnet/issues/9444
class Repro9444
{
List<int> Numbers { get; set; }

void Initialize()
{
Numbers = new List<int>();
InitializeNumbers();
foreach (var number in Numbers) // Noncompliant FP
{
System.Console.WriteLine(number);
}
}

void InitializeNumbers()
{
Numbers.Add(1);
Numbers.Add(2);
Numbers.Add(3);
}
}

0 comments on commit 444559d

Please sign in to comment.