Python: Allow same function name in call-graph tests

This commit is contained in:
Rasmus Wriedt Larsen
2022-10-24 16:03:04 +02:00
parent 8a56b48357
commit 276a825cd0
2 changed files with 8 additions and 5 deletions

View File

@@ -1,8 +1,5 @@
failures
debug_callableNotUnique
| code/class_properties.py:10:5:10:18 | Function arg | Qualified function name 'Prop.arg' is not unique within its file. Please fix. |
| code/class_properties.py:15:5:15:25 | Function arg | Qualified function name 'Prop.arg' is not unique within its file. Please fix. |
| code/class_properties.py:20:5:20:18 | Function arg | Qualified function name 'Prop.arg' is not unique within its file. Please fix. |
pointsTo_found_typeTracker_notFound
| code/class_attr_assign.py:10:9:10:27 | ControlFlowNode for Attribute() | my_func |
| code/class_attr_assign.py:11:9:11:25 | ControlFlowNode for Attribute() | my_func |

View File

@@ -76,7 +76,13 @@ bindingset[func]
string betterQualName(Function func) {
// note: `target.getQualifiedName` for Lambdas is just "lambda", so is not very useful :|
not func.isLambda() and
result = func.getQualifiedName()
if
strictcount(Function f |
f.getEnclosingModule() = func.getEnclosingModule() and
f.getQualifiedName() = func.getQualifiedName()
) = 1
then result = func.getQualifiedName()
else result = func.getLocation().getStartLine() + ":" + func.getQualifiedName()
or
func.isLambda() and
result =
@@ -88,7 +94,7 @@ query predicate debug_callableNotUnique(Function callable, string message) {
exists(callable.getLocation().getFile().getRelativePath()) and
exists(Function f |
f != callable and
f.getQualifiedName() = callable.getQualifiedName() and
betterQualName(f) = betterQualName(callable) and
f.getLocation().getFile() = callable.getLocation().getFile()
) and
message =