github / github/codeql

LGTM.com - false positive: py/unreachable-statement with assert

Đang mở
#2,506 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
false-positive Python
Ngôn ngữ chính
CodeQL
Star
10.1k
Fork
2.1k
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
141

Mô tả

Platform: Python

**Description of the false positive**

`assert` calls will be ignored when using the `-O` option. Therefore some code shouldn't be considered as dead.

This is quite low priority. `-O` related bugs are very common, but no one really uses it. Linters have been fighting forever to know whether this should be taken into account, or simply discarded

**test.py**
```python
def hello():
assert False
return 1

print(hello())
```

**Results:**

- `python test.py` -> `AssertionError`
- `python -O test.py` -> `1`

**[Related doc:](https://docs.python.org/3/using/cmdline.html#cmdoption-o)**

> -O
> Remove assert statements and any code conditional on the value of \_\_debug\_\_. Augment the filename for compiled (bytecode) files by adding .opt-1 before the .pyc extension (see PEP 488). See also PYTHONOPTIMIZE.

**URL to the alert on the project page on LGTM.com**

https://lgtm.com/projects/g/secdev/scapy/snapshot/33177966dbe59a9c7cbed5b086f99b40c4b1ede7/files/scapy/fields.py?sort=name&dir=ASC&mode=heatmap#x551c9066f44c0ec2:1

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.