github / github/codeql

LGTM.com - false positive: null-check in LINQ Query Syntax causes inference of possible null value

オープン
#6,512 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
acknowledged C# false-positive not security
主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 15時間
マージ済み PR(30日)
141

説明

**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

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。