File tree Expand file tree Collapse file tree 3 files changed +31
-5
lines changed
python/ql/test/2/query-tests/Expressions Expand file tree Collapse file tree 3 files changed +31
-5
lines changed Original file line number Diff line number Diff line change 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'. |
Original file line number Diff line number Diff line change
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 ])
Original file line number Diff line number Diff line change 1
-
2
- def use_of_apply (func , args ):
3
- apply (func , args )
4
-
5
1
def use_of_input ():
6
2
return input ()
7
3
You can’t perform that action at this time.
0 commit comments