Skip to content

Commit e55f01d

Browse files
committed
Adds new UseofApply test case and results to the Python2 tests dir
1 parent d0617ef commit e55f01d

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| expressions_test.py:3:5:3:21 | ControlFlowNode for apply() | Call to the obsolete builtin function 'apply'. |
1+
| UseofApply.py:19:3:19:17 | ControlFlowNode for apply() | Call to the obsolete builtin function 'apply'. |
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#### UseofApply.ql
2+
3+
# Use of the builtin function `apply` is generally considered bad now that the
4+
# ability to destructure lists of arguments is possible, but we should not flag
5+
# cases where the function is merely named `apply` rather than being the actual
6+
# builtin `apply` function.
7+
8+
def useofapply():
9+
10+
def foo():
11+
pass
12+
13+
14+
15+
# Positive Cases
16+
17+
# This use of `apply` is a reference to the builtin function and so SHOULD be
18+
# caught by the query.
19+
apply(foo, [1])
20+
21+
22+
23+
# Negative Cases
24+
25+
# This use of `apply` is a reference to the locally defined function inside of
26+
# `local`, and so SHOULD NOT be caught by the query.
27+
def local():
28+
def apply(f):
29+
pass
30+
apply(foo)([1])
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
2-
def use_of_apply(func, args):
3-
apply(func, args)
4-
51
def use_of_input():
62
return input()
73

0 commit comments

Comments
 (0)