github / github/codeql

False Positive - Mismatch in multiple assignment

Offen
#8,991 8 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
false-positive
Vorherrschende Sprache
CodeQL
Sterne
10.1k
Forks
2.1k
Ø Merge
2 T. 15 Std.
Gemergte PRs (30 T.)
141

Beschreibung

False positive for "Mismatch in multiple assignment" in Python.

A mismatch in multiple assignment can occur when the number of values assigned does not match the number of variables to which they are assigned. For example a,b=1,2,3 would cause this error in Python.

The false positive occurs when the number of variables is not directly assigned, but instead assigned to a function such as:
out1,out2 = myfunction(in1,in2,in3)
This is not direct assignment of variables but LGTM triggers a false positive on _some_ occasions when this syntax is used.

**URL to the alert on the project page on LGTM.com** is available from [here](https://lgtm.com/projects/g/MatthewReid854/reliability/snapshot/41df1552a5508981636e52e77d1819ac13783658/files/reliability/Distributions.py?sort=name&dir=ASC&mode=heatmap#x462033e751fe50a7:1)
In this file, there are 18 alerts and they are all for the same style of false positive.

Another issue is that to suppress an alert the **# lgtm [py/mismatched-multiple-assignment]** comment must be on the same line as the offending code. If the offending code runs across multiple lines (as is common when using an auto formatter like Black) the suppression comment does not work.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.