mirror of
https://github.com/github/codeql.git
synced 2025-12-29 23:26:34 +01:00
Will need subsequent PRs fixing up test failures (due to deprecated methods moving around), but other than that everything should be straight-forward.
27 lines
739 B
Plaintext
27 lines
739 B
Plaintext
/**
|
|
* @name Ratio of jump-to-definitions computed
|
|
*/
|
|
|
|
import python
|
|
import DefinitionTracking
|
|
|
|
predicate want_to_have_definition(Expr e) {
|
|
/* not builtin object like len, tuple, etc. */
|
|
not exists(Value builtin | e.pointsTo(builtin) and builtin.isBuiltin()) and
|
|
(
|
|
e instanceof Name and e.(Name).getCtx() instanceof Load
|
|
or
|
|
e instanceof Attribute and e.(Attribute).getCtx() instanceof Load
|
|
or
|
|
e instanceof ImportMember
|
|
or
|
|
e instanceof ImportExpr
|
|
)
|
|
}
|
|
|
|
from int yes, int no
|
|
where
|
|
yes = count(Expr e | want_to_have_definition(e) and exists(getUniqueDefinition(e))) and
|
|
no = count(Expr e | want_to_have_definition(e) and not exists(getUniqueDefinition(e)))
|
|
select yes, no, yes * 100 / (yes + no) + "%"
|