S4158 FP: Collection filled in a for loop reported to be empty #6179
Labels
Area: C#
C# rules related issues.
Area: CFG/SE
CFG and SE related issues.
Area: VB.NET
VB.NET rules related issues.
Type: CFG/SE FPs
Rule IS triggered when it shouldn't be for CFG and SE rules.
Milestone
Description
Sonar Analyzer incorrectly reports S4158 for the code below. My original code is actually more complex. However, this simplified example also reports S4158.
Repro steps
Expected behavior
As the collection is not empty, no issue should be reported.
Actual behavior
S4158 is reported.
Known workarounds
Using a foreach loop in the lower part, does not report the issue. However, in my original code this is not possible, as I actually have two collections that I have to access with indices.
Related information
Environment:
- Visual Studio Enterprise 17.3.0
- SonarAnalyzer.CSharp 8.46.0.54807
- .NET Framework 4.8
- Windows 10 x64
The text was updated successfully, but these errors were encountered: