JS: Add model of Map#groupBy

This commit is contained in:
Asger F
2024-12-19 14:25:07 +01:00
parent de5e6ddeed
commit dc2f39c399
4 changed files with 24 additions and 2 deletions

View File

@@ -118,3 +118,23 @@ class MapSet extends SummarizedCallable {
)
}
}
class MapGroupBy extends SummarizedCallable {
MapGroupBy() { this = "Map#groupBy" }
override DataFlow::CallNode getACallSimple() {
result = mapConstructorRef().getAMemberCall("groupBy") and
result.getNumArgument() = 2
}
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
preservesValue = true and
(
input = "Argument[0].ArrayElement" and
output = ["Argument[1].Parameter[0]", "ReturnValue.MapValue.ArrayElement"]
or
input = "Argument[1].ReturnValue" and
output = "ReturnValue.MapKey"
)
}
}