Adds new UseofApply test case and results to the Python2 tests dir

This commit is contained in:
Rebecca Valentine
2020-02-18 12:12:25 -08:00
parent d0617ef7bc
commit e55f01d905
3 changed files with 31 additions and 5 deletions

View File

@@ -1 +1 @@
| expressions_test.py:3:5:3:21 | ControlFlowNode for apply() | Call to the obsolete builtin function 'apply'. |
| UseofApply.py:19:3:19:17 | ControlFlowNode for apply() | Call to the obsolete builtin function 'apply'. |

View File

@@ -0,0 +1,30 @@
#### UseofApply.ql
# Use of the builtin function `apply` is generally considered bad now that the
# ability to destructure lists of arguments is possible, but we should not flag
# cases where the function is merely named `apply` rather than being the actual
# builtin `apply` function.
def useofapply():
def foo():
pass
# Positive Cases
# This use of `apply` is a reference to the builtin function and so SHOULD be
# caught by the query.
apply(foo, [1])
# Negative Cases
# This use of `apply` is a reference to the locally defined function inside of
# `local`, and so SHOULD NOT be caught by the query.
def local():
def apply(f):
pass
apply(foo)([1])

View File

@@ -1,7 +1,3 @@
def use_of_apply(func, args):
apply(func, args)
def use_of_input():
return input()