JS: Simplify call graph metric

This commit is contained in:
Asger F
2019-09-10 11:21:31 +01:00
parent 327ade1f34
commit 0924de4c56
3 changed files with 11 additions and 3 deletions

View File

@@ -173,12 +173,20 @@ SourceNode nodeLeadingToInvocation() {
)
}
/**
* Holds if there is a call edge `invoke -> f` between a relevant invocation
* and a relevant function.
*/
predicate relevantCall(RelevantInvoke invoke, RelevantFunction f) {
FlowSteps::calls(invoke, f)
}
/**
* A call site that can be resolved to a function in the same project.
*/
class ResolvableCall extends RelevantInvoke {
ResolvableCall() {
FlowSteps::calls(this, _)
relevantCall(this, _)
or
this = resolvableCallback().getAnInvocation()
}

View File

@@ -11,4 +11,4 @@
import javascript
import CallGraphQuality
select projectRoot(), count(NonExternalCall call)
select projectRoot(), count(RelevantInvoke call)

View File

@@ -11,4 +11,4 @@
import javascript
import CallGraphQuality
select projectRoot(), 100.0 * count(ResolvableCall call) / count(NonExternalCall call).(float)
select projectRoot(), 100.0 * count(ResolvableCall call) / count(RelevantInvoke call).(float)