Undo conversion for queries that import LegacyPointsTo

This commit is contained in:
Owen Mansel-Chan
2026-06-19 11:18:19 +01:00
parent 5497f2c5fe
commit 451fc2e4e7
143 changed files with 287 additions and 358 deletions

View File

@@ -1,2 +1 @@
query: Variables/ShadowGlobal.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Variables/ShadowGlobal.ql

View File

@@ -11,7 +11,7 @@ def sh1(x):
#Shadow Global
def sh2(x):
sh1 = x + 1 # $ Alert[py/local-shadows-global] #Shadows
sh1 = x + 1 #Shadows
sh1 = x + 0 # no shadowing warning for 2nd def
return sh1

View File

@@ -1,2 +1 @@
query: Variables/UndefinedExport.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Variables/UndefinedExport.ql

View File

@@ -19,12 +19,12 @@ def f(parameter):
helper # Explicitly as import
a # Imlicitly from ud_helper
defined
ug2 # $ Alert[py/undefined-global-variable] # ERROR
e # $ Alert[py/undefined-global-variable] # ERROR Defined in ud_helper, but not in __all__
ug2 # ERROR
e # ERROR Defined in ud_helper, but not in __all__
int
float
__file__ #OK all files have __file__ defined
__path__ # $ Alert[py/undefined-global-variable] #ERROR only modules have __path__ defined
__path__ #ERROR only modules have __path__ defined
len #Ok defined in builtins
monkey1 #Ok monkey-patched builtins
@@ -120,7 +120,7 @@ class Cls(object):
pfp3 += 1
def only_report_once():
ug3 # $ Alert[py/undefined-global-variable]
ug3
ug3
ug3
ug3

View File

@@ -1,2 +1 @@
query: Variables/UndefinedGlobal.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Variables/UndefinedGlobal.ql

View File

@@ -2,7 +2,7 @@
class C:
def m1(self):
y = ug1 # $ Alert[py/undefined-global-variable]
y = ug1
x = 1
return y
@@ -10,16 +10,16 @@ class C:
return p
def m3(self, x1):
return u2 # $ Alert[py/uninitialized-local-variable]
return u2
u2 = x1
def m4(self, x2):
if x2:
u3 = 1
return u3 # $ Alert[py/uninitialized-local-variable]
return u3
def f():
y = ug1 # $ Alert[py/undefined-global-variable]
y = ug1
x = 1
return y
@@ -34,7 +34,7 @@ def q(x4):
def j(u4):
del u4
return u4 # $ Alert[py/uninitialized-local-variable]
return u4
def k(x5):
x5 + 1
@@ -43,7 +43,7 @@ def k(x5):
def m(x6):
if x6:
u6 = 1
u6 # $ Alert[py/uninitialized-local-variable]
u6
#The following are not uninitialized, but unreachable.
u6
u6
@@ -66,13 +66,13 @@ def check_del(cond):
del u8
else:
pass
u8 # $ Alert[py/uninitialized-local-variable]
u8
if cond:
u9 = 1
del u9
else:
u9 = 2
u9 # $ Alert[py/uninitialized-local-variable]
u9
if cond:
x10 = 1
del x10
@@ -82,10 +82,10 @@ def check_del(cond):
x10
u11 = 1
del u11
u11 # $ Alert[py/uninitialized-local-variable]
u11
u12 = "hi"
del u12
del u12 # $ Alert[py/uninitialized-local-variable]
del u12
#x will always be defined.
def const_range():
@@ -116,7 +116,7 @@ def use_def_conditional(cond4, cond5):
u14 = 1
x16 = 2
if cond5:
return u14 # $ Alert[py/uninitialized-local-variable]
return u14
def init_and_set_flag_in_try(f):
@@ -148,7 +148,7 @@ def split_not_OK():
except:
cond = not False
if not not cond:
return u19 # $ Alert[py/uninitialized-local-variable]
return u19
def double_is_none(x):
if x is not None:
@@ -160,7 +160,7 @@ def double_is_none(x):
#ODASA-4241
def def_in_post_loop(seq):
j(x) # $ Alert[py/uninitialized-local-variable]
j(x)
x = []
for p in seq:
x = p
@@ -173,9 +173,9 @@ def f(cond1, cond2):
else:
y = 1
if cond2:
return x # $ Alert[py/uninitialized-local-variable]
return x
else:
return y # $ Alert[py/uninitialized-local-variable]
return y
def needs_splitting(var):
if var:

View File

@@ -1,2 +1 @@
query: Variables/UninitializedLocal.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Variables/UninitializedLocal.ql

View File

@@ -1,16 +1,16 @@
import dotted
__all__ = ["foo", "bar", "baz", "not_defined"] # $ Alert[py/undefined-export]
__all__ = ["foo", "bar", "baz", "not_defined"]
@dotted.decorator
def foo():
pass
@undotted_decorator # $ Alert[py/undefined-global-variable]
@undotted_decorator
def bar():
pass
@not_imported.but_dotted # $ Alert[py/undefined-global-variable]
@not_imported.but_dotted
def baz():
pass

View File

@@ -1,4 +1,4 @@
__all__ = ["foo", "bar", "baz", "quux", "blat", "frob", "nosuch", "i_got_it_elsewhere"] # $ Alert[py/undefined-export]
__all__ = ["foo", "bar", "baz", "quux", "blat", "frob", "nosuch", "i_got_it_elsewhere"]
with open("foo.txt") as f:
foo = f.read()

View File

@@ -8,7 +8,7 @@ def f(cond1, cond2):
except Exception:
if cond2:
var = 7
if var == 1: # $ Alert[py/uninitialized-local-variable]
if var == 1:
var = var + 1
elif var == 2:
var +- 3

View File

@@ -1,2 +1 @@
query: Variables/UnusedModuleVariable.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Variables/UnusedModuleVariable.ql

View File

@@ -1,2 +1 @@
query: Variables/UnusedParameter.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Variables/UnusedParameter.ql

View File

@@ -22,7 +22,7 @@ __hidden_marker = False
#Unused parameter, local and global
def u1(x): # $ Alert[py/unused-parameter]
def u1(x):
return 0
def u2():
@@ -45,8 +45,8 @@ class D(C):
pass
#Unused module variable
not_used_var1 = 17 # $ Alert[py/unused-global-variable]
not_used_var2 = 18 # $ Alert[py/unused-global-variable]
not_used_var1 = 17
not_used_var2 = 18
is_used_var1 = 19
is_used_var2 = 20
@@ -83,7 +83,7 @@ def f(t):
# Entirely unused tuple
a,b,c = t # $ Alert[py/unused-global-variable]
a,b,c = t
def f(t):
a,b,c = t # $ Alert[py/unused-local-variable]
@@ -97,7 +97,7 @@ def second_def_undefined():
#And gloablly
glob_var = 0
use(glob_var)
glob_var = 1 # $ Alert[py/unused-global-variable] # unused
glob_var = 1 # unused