github / github/codeql

cs/unused-collection false positive?

Open
#14,073 1 comment 0 reactions 0 assignees View on GitHub
C# false-positive
Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 15h
Merged PRs (30d)
141

Description

Hope this is the right place to file analyzer issues as well, didn't really see any info on recommendations for reporting issues anywhere.

We saw a "Container contents are never accessed" error on our report `cs/unused-collection`: https://github.com/CommunityToolkit/Windows/security/code-scanning/9

Flagging this code in our file:

```cs
private List _overflow = new List();
```

But it was used here in our ArrangeOverride method:

```cs
///
protected override Size ArrangeOverride(Size finalSize)
{
// Have grid to the bulk of our heavy lifting.
var size = base.ArrangeOverride(finalSize);

// Make sure all overflown elements have no size.
foreach (var child in _overflow)
{
child.Arrange(default);
}
```

Is this due to the `foreach` usage or because this is in a framework/platform method that is uncalled by our codebase directly but will be called by the XAML/UWP/WindowsAppSDK platform?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.