Skip to content

Commit 69913c0

Browse files
committed
Python: relative line numbers in
MISSING-annotations
1 parent 77da4b0 commit 69913c0

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

python/ql/test/experimental/dataflow/coverage/classes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def test_set_name():
421421
# classmethod object.__init_subclass__(cls)
422422
class With_init_subclass:
423423
def __init_subclass__(cls):
424-
SINK1(cls) #$ MISSING: arg1="Tuple[0], l:429 -> cls"
424+
SINK1(cls) #$ MISSING: arg1="Tuple[0], l:+5 -> cls"
425425
OK() # Call not found
426426

427427

@@ -441,7 +441,7 @@ class With_prepare(type):
441441
def __prepare__(name, bases, **kwds):
442442
SINK3(kwds) # Flow not tested
443443
SINK2(bases) # Flow not tested
444-
SINK1(name) #$ MISSING: arg1="arg1, l:450 -> name"
444+
SINK1(name) #$ MISSING: arg1="arg1, l:+6 -> name"
445445
OK() # Call not found
446446
return kwds
447447

@@ -871,7 +871,7 @@ def test_or():
871871
# object.__radd__(self, other)
872872
class With_radd:
873873
def __radd__(self, other):
874-
SINK2(other) #$ MISSING: arg2="arg2, l:882 -> other"
874+
SINK2(other) #$ MISSING: arg2="arg2, l:+8 -> other"
875875
SINK1(self)
876876
OK() # Call not found
877877
return self

python/ql/test/experimental/dataflow/coverage/test.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def test_nested_comprehension_paren():
203203
# 6.2.8. Generator expressions
204204
def test_generator():
205205
x = (SOURCE for y in [NONSOURCE])
206-
SINK([*x][0]) #$ MISSING:flow="SOURCE, l:205 -> List[0]"
206+
SINK([*x][0]) #$ MISSING:flow="SOURCE, l:-1 -> List[0]"
207207

208208

209209
# 6.2.9. Yield expressions
@@ -213,7 +213,7 @@ def gen(x):
213213

214214
def test_yield():
215215
g = gen(SOURCE)
216-
SINK(next(g)) #$ MISSING:flow="SOURCE, l:215 -> next()"
216+
SINK(next(g)) #$ MISSING:flow="SOURCE, l:-1 -> next()"
217217

218218

219219
def gen_from(x):
@@ -222,7 +222,7 @@ def gen_from(x):
222222

223223
def test_yield_from():
224224
g = gen_from(SOURCE)
225-
SINK(next(g)) #$ MISSING:flow="SOURCE, l:224 -> next()"
225+
SINK(next(g)) #$ MISSING:flow="SOURCE, l:-1 -> next()"
226226

227227

228228
# a statement rather than an expression, but related to generators
@@ -234,7 +234,7 @@ def test_for():
234234
# 6.2.9.1. Generator-iterator methods
235235
def test___next__():
236236
g = gen(SOURCE)
237-
SINK(g.__next__()) #$ MISSING:flow="SOURCE, l:236 -> g.__next__()"
237+
SINK(g.__next__()) #$ MISSING:flow="SOURCE, l:-1 -> g.__next__()"
238238

239239

240240
def gen2(x):
@@ -259,7 +259,7 @@ def gen_ex(x):
259259
def test_throw():
260260
g = gen_ex(SOURCE)
261261
n = next(g)
262-
SINK(g.throw(TypeError)) #$ MISSING:flow="SOURCE, l:260 -> g.throw()"
262+
SINK(g.throw(TypeError)) #$ MISSING:flow="SOURCE, l:-2 -> g.throw()"
263263

264264

265265
# no `test_close` as `close` involves no data flow
@@ -280,7 +280,7 @@ def runa(a):
280280

281281
async def atest___anext__():
282282
g = agen(SOURCE)
283-
SINK(await g.__anext__()) #$ MISSING:flow="SOURCE, l:282 -> g.__anext__()"
283+
SINK(await g.__anext__()) #$ MISSING:flow="SOURCE, l:-1 -> g.__anext__()"
284284

285285

286286
def test___anext__():
@@ -313,7 +313,7 @@ async def agen_ex(x):
313313
async def atest_athrow():
314314
g = agen_ex(SOURCE)
315315
n = await g.__anext__()
316-
SINK(await g.athrow(TypeError)) #$ MISSING:flow="SOURCE, l:314 -> g.athrow()"
316+
SINK(await g.athrow(TypeError)) #$ MISSING:flow="SOURCE, l:-2 -> g.athrow()"
317317

318318

319319
def test_athrow():
@@ -326,7 +326,7 @@ class C:
326326

327327

328328
def test_attribute_reference():
329-
SINK(C.a) #$ MISSING:flow="SOURCE, l:325 -> C.a"
329+
SINK(C.a) #$ MISSING:flow="SOURCE, l:-4 -> C.a"
330330

331331

332332
# overriding __getattr__ should be tested by the class coverage tests
@@ -376,7 +376,7 @@ def test_call_keyword():
376376

377377

378378
def test_call_unpack_iterable():
379-
SINK(second(NONSOURCE, *[SOURCE])) #$ MISSING:flow="SOURCE -> second(..)" MISING:flow="'source', l:20 -> second(..)"
379+
SINK(second(NONSOURCE, *[SOURCE])) #$ MISSING:flow="SOURCE -> second(..)"
380380

381381

382382
def test_call_unpack_mapping():
@@ -547,7 +547,7 @@ def test_dynamic_tuple_creation_1():
547547
tup += (SOURCE,)
548548
tup += (NONSOURCE,)
549549

550-
SINK(tup[0]) #$ MISSING:flow="SOURCE, l:547 -> tup[0]" MISING:flow="'source', l:20 -> tup[0]"
550+
SINK(tup[0]) #$ MISSING:flow="SOURCE, l:-3 -> tup[0]"
551551
SINK_F(tup[1])
552552

553553

@@ -557,7 +557,7 @@ def test_dynamic_tuple_creation_2():
557557
tup += (SOURCE,)
558558
tup += (NONSOURCE,)
559559

560-
SINK(tup[0]) #$ MISSING:flow="SOURCE, l:557 -> tup[0]" MISING:flow="'source', l:20 -> tup[0]"
560+
SINK(tup[0]) #$ MISSING:flow="SOURCE, l:-3 -> tup[0]"
561561
SINK_F(tup[1])
562562

563563

@@ -567,7 +567,7 @@ def test_dynamic_tuple_creation_3():
567567
tup2 = (NONSOURCE,)
568568
tup = tup1 + tup2
569569

570-
SINK(tup[0]) #$ MISSING:flow="SOURCE, l:566 -> tup[0]" MISING:flow="'source', l:20 -> tup[0]"
570+
SINK(tup[0]) #$ MISSING:flow="SOURCE, l:-4 -> tup[0]"
571571
SINK_F(tup[1])
572572

573573

@@ -578,5 +578,5 @@ def test_dynamic_tuple_creation_4():
578578
for item in [SOURCE, NONSOURCE]:
579579
tup += (item,)
580580

581-
SINK(tup[0]) #$ MISSING:flow="SOURCE, l:578 -> tup[0]" MISING:flow="'source', l:20 -> tup[0]"
581+
SINK(tup[0]) #$ MISSING:flow="SOURCE, l:-3 -> tup[0]"
582582
SINK_F(tup[1])

0 commit comments

Comments
 (0)