github / github/codeql

LGTM.com - false positive - unnecessary null check C#

未关闭
#6,554 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
acknowledged C# false-positive not security
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

Found it in a **.NET 5.0 C#** project of mine, an access to a **List\** object in a loop had a warning saying it may be null because of some checks.

This shouldn't be the case because the loop is already limited by a variable **n** which gets **0** in the case of the object being null, or the length of the object. When the **n** variable is **0** loop is skipped, therefore the null check inside it is unnecessary.

[**>>Alert link here<<**](https://lgtm.com/projects/g/semihM/exmat/snapshot/094b2dcf4a99b7e555bdb418d990a04b9344df98/files/exmatstdlib/ExStdString.cs?sort=name&dir=ASC&mode=heatmap#xf95a12ccdeb2d93c:1)

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。