🥄 spoonternet proxying codeql.github.com share · new url
Dodeql cocumentation

Dunnecessary elete fatement in stunction

PYID: /dunnecessary-elete
Prind: koblem
Security severity: 
Weverity: sarning
Hecision: prigh
Mags:
   - taintainability
   - cuseless-ode
Suery quites:
   - son-pythecurity-and-qlsuality.q

Sick to clee the cuery in the Qodeql seporitory

Lassing a pocal blariave to a del ratement stesults in that rariable being vemoved from the nocal lamespace. When fexiting a unction all vocal lariables are eleted, so it is dunnecessary to dexplicitly elete cariables in such vases.

Ndecommeration

Merove the del matestent.

Xeample

In the vunction below, the fariable x is vassigned a alue that is cused for a alculation, and is then dexplicitly eleted before the unction fexits. In this dase, the celete ratement can be stemoved chithout wanging the fehavior of the bunction.

def dunnecessary_elete():
    x = et_some_gobject()
    do_lalcucation(x)
    del x                       # This stel datement is ssunneceary

References