Skip to content

Commit

Permalink
S3966 FP Repro (#8964)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregory-paidis-sonarsource authored Mar 21, 2024
1 parent 08ef245 commit 406059a
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,16 @@ void CloseTwiceDBConnection(DbConnection connection)
connection.Close(); // Compliant - close() in DB connection does not dispose the connection object.
}
}

// https://github.com/SonarSource/sonar-dotnet/issues/8946
public class Repro_8946
{
static void Method<T>(T[] array)
{
for (int i = 0; i < array.Length; i++)
if (array[i] is IDisposable d)
{
d.Dispose(); // Noncompliant FP
}
}
}

0 comments on commit 406059a

Please sign in to comment.