LGTM.com - false positive: null-check in LINQ Query Syntax causes inference of possible null value
- Lingua principale
- CodeQL
- Stelle
- 10.1k
- Fork
- 2.1k
- Merge medio
- 2g 15h
- PR unite (30g)
- 141
Descrizione
**Description of the false positive**
Here is my example query. Null checks in LINQ query syntax should infer that the next access of the checked variable is not null, but instead it is the very null check that causes an LGTM warning.
```csharp
var x = from seed in seedsToTrim
let parent = context[seed.Parent]
where parent?.Content.Type == "search_title"
let title = context.GetChildren(seed).FirstOrDefault(s => s.Content.Type == "title")
where title != null // null check here should infer that title is not null in the next line
let r = title.Content.Value // but previous check causes LGTM: 'Variable title may be null here as suggested by this null check.'
let distance = this.Comparator.Distance(r.NormalizeTitle(), parent?.Content.Value.NormalizeTitle())
orderby distance ascending, context.GetChildren(seed).Count() descending
select seed
```
https://lgtm.com/projects/g/SnowflakePowered/snowflake/snapshot/91c41ebda631e445ba26d521696adb2537a720da/files/src/Snowflake.Support.Scraping.Primitives/ResultCuller.cs?sort=name&dir=ASC&mode=heatmap#x47f6f70265861613:1
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.