github / github/codeql

LGTM.com - false positive C# nullable types/linq Where then Select

Open
#5,884 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

**Description of the false positive**

An earlier lamda uses `Where` with nullable Type (int?) `HasValue`. Later lamda dereferences `ID.Value`. It is a false positive because the first lamda ensures there are no null values.

```csharp
// the cohorts in the database
var available = ExtractableCohort.GetImportableCohortDefinitions(ect).Where(c=>c.ID.HasValue).ToArray();

[...]

// new ones we don't know about yet
available = available.Where(c => !existing.Contains(c.ID.Value)).ToArray();
```

https://lgtm.com/projects/g/HicServices/RDMP/rev/pr-51dd5b87e2dee7ed707f8a2b4855b01ad10e3ca0

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.