mirror of
https://github.com/github/codeql.git
synced 2026-06-18 03:11:07 +02:00
Convert Python qlref tests to inline expectations
This commit is contained in:
@@ -1 +1,2 @@
|
||||
Variables/SuspiciousUnusedLoopIterationVariable.ql
|
||||
query: Variables/SuspiciousUnusedLoopIterationVariable.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
Variables/UnusedLocalVariable.ql
|
||||
query: Variables/UnusedLocalVariable.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
Variables/UnusedModuleVariable.ql
|
||||
query: Variables/UnusedModuleVariable.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
Variables/UnusedParameter.ql
|
||||
query: Variables/UnusedParameter.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
#Unused
|
||||
def fail():
|
||||
for t in [TypeA, TypeB]:
|
||||
for t in [TypeA, TypeB]: # $ Alert[py/unused-loop-variable]
|
||||
x = TypeA()
|
||||
run_test(x)
|
||||
|
||||
@@ -63,19 +63,19 @@ def OK8(seq, output):
|
||||
#Not OK -- Use a constant, but also a variable
|
||||
def fail2(sequence):
|
||||
for x in sequence:
|
||||
for y in sequence:
|
||||
for y in sequence: # $ Alert[py/unused-loop-variable]
|
||||
do_something(x+1)
|
||||
|
||||
def fail3(sequence):
|
||||
for x in sequence:
|
||||
do_something(x+1)
|
||||
for y in sequence:
|
||||
for y in sequence: # $ Alert[py/unused-loop-variable]
|
||||
do_something(x+1)
|
||||
|
||||
def fail4(coll, sequence):
|
||||
while coll:
|
||||
x = coll.pop()
|
||||
for s in sequence:
|
||||
for s in sequence: # $ Alert[py/unused-loop-variable]
|
||||
do_something(x+1)
|
||||
|
||||
#OK See ODASA-4153 and ODASA-4533
|
||||
@@ -103,7 +103,7 @@ def kwargs_is_a_use(seq):
|
||||
|
||||
#A deletion is a use, but this is almost certainly an error
|
||||
def cleanup(sessions):
|
||||
for sess in sessions:
|
||||
for sess in sessions: # $ Alert[py/unused-loop-variable]
|
||||
# Original code had some comment about deleting sessions
|
||||
del sess
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ __hidden_marker = False
|
||||
|
||||
#Unused parameter, local and global
|
||||
|
||||
def u1(x):
|
||||
def u1(x): # $ Alert[py/unused-parameter]
|
||||
return 0
|
||||
|
||||
def u2():
|
||||
x = 1
|
||||
x = 1 # $ Alert[py/unused-local-variable]
|
||||
return 1
|
||||
|
||||
#These parameters are OK due to (potential overriding)
|
||||
@@ -45,8 +45,8 @@ class D(C):
|
||||
pass
|
||||
|
||||
#Unused module variable
|
||||
not_used_var1 = 17
|
||||
not_used_var2 = 18
|
||||
not_used_var1 = 17 # $ Alert[py/unused-global-variable]
|
||||
not_used_var2 = 18 # $ Alert[py/unused-global-variable]
|
||||
is_used_var1 = 19
|
||||
is_used_var2 = 20
|
||||
|
||||
@@ -83,21 +83,21 @@ def f(t):
|
||||
|
||||
# Entirely unused tuple
|
||||
|
||||
a,b,c = t
|
||||
a,b,c = t # $ Alert[py/unused-global-variable]
|
||||
|
||||
def f(t):
|
||||
a,b,c = t
|
||||
a,b,c = t # $ Alert[py/unused-local-variable]
|
||||
use(t)
|
||||
|
||||
def second_def_undefined():
|
||||
var = 0
|
||||
use(var)
|
||||
var = 1 # unused.
|
||||
var = 1 # $ Alert[py/unused-local-variable] # unused.
|
||||
|
||||
#And gloablly
|
||||
glob_var = 0
|
||||
use(glob_var)
|
||||
glob_var = 1 # unused
|
||||
glob_var = 1 # $ Alert[py/unused-global-variable] # unused
|
||||
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ def decorated_inner_function():
|
||||
#FP observed
|
||||
def test_dict_unpacking(queryset, field_name, value):
|
||||
#True positive
|
||||
for tag in value.split(','):
|
||||
for tag in value.split(','): # $ Alert[py/unused-loop-variable]
|
||||
queryset = queryset.filter(**{field_name + '__name': tag1})
|
||||
return queryset
|
||||
#False positive
|
||||
|
||||
Reference in New Issue
Block a user