mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
Python: Add consistency tests for class scope
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
# Originally we had module and functions as `DataFlowCallable``, and any call inside a
|
||||
# class scope would not have a result for getEnclosingCallable. Since this was only a
|
||||
# consistency error for calls, originally we added a new `DataFlowClassScope` only for
|
||||
# those classes that had a call in their scope. That's why all the class definitions in
|
||||
# this test do a call to the dummy function `func`.
|
||||
#
|
||||
# Note: this was shortsighted, since most DataFlow::Node use `getCallableScope` helper
|
||||
# to define their .getEnclosingCallable(), which picks the first DataFlowCallable to
|
||||
# contain the node. (so for some classes that would be DataFlowClassScope, and for some
|
||||
# it would be the module/function containing the class definition)
|
||||
|
||||
def func(*args, **kwargs):
|
||||
print("func()")
|
||||
|
||||
class Cls:
|
||||
func()
|
||||
class Inner:
|
||||
func()
|
||||
|
||||
def other_func():
|
||||
class Cls2:
|
||||
func()
|
||||
return Cls2
|
||||
|
||||
x = other_func()
|
||||
@@ -1,5 +1,11 @@
|
||||
uniqueEnclosingCallable
|
||||
uniqueCallEnclosingCallable
|
||||
| class_scope.py:16:5:16:10 | func() | Call should have one enclosing callable but has 0. |
|
||||
| class_scope.py:16:5:16:10 | func() | Call should have one enclosing callable but has 0. |
|
||||
| class_scope.py:18:9:18:14 | func() | Call should have one enclosing callable but has 0. |
|
||||
| class_scope.py:18:9:18:14 | func() | Call should have one enclosing callable but has 0. |
|
||||
| class_scope.py:22:9:22:14 | func() | Call should have one enclosing callable but has 0. |
|
||||
| class_scope.py:22:9:22:14 | func() | Call should have one enclosing callable but has 0. |
|
||||
uniqueType
|
||||
uniqueNodeLocation
|
||||
missingLocation
|
||||
|
||||
Reference in New Issue
Block a user