github / github/codeql

LGTM.com - false positive (captured variable)

Open
#6,457 1 comment 0 reactions 0 assignees View on GitHub
acknowledged false-positive not security Python
Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 15h
Merged PRs (30d)
141

Description

**Description of the false positive**

A variable is defined inside a function, and later used/access from a nested function as follows:

```
def manage_dvs(request) -> str:
...
curr_fake_platform = None
...
def update_dvs(log_path, new_fake_platform=None):
...
nonlocal curr_fake_platform
if new_fake_platform != curr_fake_platform:
...
```

The `curr_fake_platform` incorrectly triggers an unused variable alert

**URL to the alert on the project page on LGTM.com**
https://lgtm.com/projects/g/Azure/sonic-swss/snapshot/b5ac9505d8ac0a7830488d825aae7e616480cc86/files/tests/conftest.py?sort=name&dir=ASC&mode=heatmap#xd660241c258f5ae6:1

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.