github / github/codeql

False positive py/uninitialized-local-variable

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

描述

**Description of the false positive**

**Code samples or links to source code**

```python
class Foo:
def foo(self, a, b, c=0):
start = 0
visible = not (a == b and c)
end = start if visible else None
return end

```

CodeQL Version: 2.18.3

Alert : Local variable 'visible' may be used before it is initialized.

I suspect that the issue is caused by EssaVariable being unable to locate the assignment statement for the variable visible, but I'm not sure how to modify the ql statement.

贡献指南

打开贡献指南

调研方向

根据提供的 Python 示例,检查 py/uninitialized-local-variable 查询及其对 EssaVariable 的处理。确认对于此代码,关于 visible 的错误警报不再出现,同时预期的未初始化局部变量检测仍保持完整。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
security
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

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