mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #9846 from tausbn/python-fix-bad-syntactic_call_count-join
Python: Fix bad join in `syntactic_call_count`
This commit is contained in:
@@ -23,13 +23,8 @@ private int max_context_cost() {
|
||||
}
|
||||
|
||||
private int syntactic_call_count(Scope s) {
|
||||
exists(Function f | f = s and f.getName() != "__init__" |
|
||||
result =
|
||||
count(CallNode call |
|
||||
call.getFunction().(NameNode).getId() = f.getName()
|
||||
or
|
||||
call.getFunction().(AttrNode).getName() = f.getName()
|
||||
)
|
||||
exists(Function f, string name | f = s and name = f.getName() and name != "__init__" |
|
||||
result = count(function_call(name)) + count(method_call(name))
|
||||
)
|
||||
or
|
||||
s.getName() = "__init__" and result = 1
|
||||
@@ -37,6 +32,12 @@ private int syntactic_call_count(Scope s) {
|
||||
not s instanceof Function and result = 0
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
private CallNode function_call(string name) { result.getFunction().(NameNode).getId() = name }
|
||||
|
||||
pragma[nomagic]
|
||||
private CallNode method_call(string name) { result.getFunction().(AttrNode).getName() = name }
|
||||
|
||||
private int incoming_call_cost(Scope s) {
|
||||
/*
|
||||
* Syntactic call count will often be a considerable overestimate
|
||||
|
||||
Reference in New Issue
Block a user