github / github/codeql

False Positive - Mismatch in multiple assignment

Ouverte
#8,991 8 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
false-positive
Langage dominant
CodeQL
Étoiles
10.1k
Forks
2.1k
Merge moyen
2 j 15 h
PR mergées (30 j)
141

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.